mirror of
https://codeberg.org/Andre601/AdvancedServerList.git
synced 2026-11-12 20:12:00 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf766ddd9a | ||
|
|
12cd2f5e6b | ||
|
|
04ef50ea91 | ||
|
|
d4c627fa79 | ||
|
|
deffc28ab6 | ||
|
|
833f8f5dbb | ||
|
|
5bdf2fa301 | ||
|
|
d13607873c | ||
|
|
a1f11dac03 | ||
|
|
74f1805441 | ||
|
|
21046d8eee | ||
|
|
0c37e3bb35 | ||
|
|
3f9ea7035f | ||
|
|
b55c56af12 | ||
|
|
498a948605 | ||
|
|
76a1890bba | ||
|
|
8899770518 | ||
|
|
a7d29d292f | ||
|
|
a9ca388f4e | ||
|
|
c42a88142c | ||
|
|
9fe78d3e6e |
No files matched your search
+1
-1
@@ -102,7 +102,7 @@ public class BungeeEventWrapper implements GenericEventWrapper<Favicon, BungeePl
|
||||
String parsed = ComponentParser.text(lines.get(i))
|
||||
.modifyText(text -> StringReplacer.replace(text, player, server))
|
||||
.toString();
|
||||
|
||||
|
||||
ServerPing.PlayerInfo pi = new ServerPing.PlayerInfo(parsed, UUID.randomUUID());
|
||||
players[i] = pi;
|
||||
}
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public class JoinEvent implements Listener{
|
||||
|
||||
BungeeCmdSender sender = new BungeeCmdSender(player, plugin.getAudiences());
|
||||
|
||||
plugin.getCore().getUpdateChecker().performeCachedUpdateCheck(sender);
|
||||
plugin.getCore().getUpdateChecker().performCachedUpdateCheck(sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -131,7 +131,7 @@
|
||||
<dependency>
|
||||
<groupId>net.william278</groupId>
|
||||
<artifactId>papiproxybridge</artifactId>
|
||||
<version>1.5</version>
|
||||
<version>1.6.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -28,6 +28,7 @@ package ch.andre601.advancedserverlist.core.check;
|
||||
import ch.andre601.advancedserverlist.core.AdvancedServerList;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.PluginLogger;
|
||||
import ch.andre601.advancedserverlist.core.interfaces.commands.CmdSender;
|
||||
import ch.andre601.advancedserverlist.core.objects.CacheUtil;
|
||||
import com.google.gson.FieldNamingPolicy;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
@@ -41,6 +42,7 @@ import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -63,7 +65,7 @@ public class UpdateChecker{
|
||||
|
||||
private final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor(new UpdateCheckThread());
|
||||
|
||||
private final VersionCache cache = new VersionCache();
|
||||
private final CacheUtil<ModrinthVersion> cache = new CacheUtil<>(Duration.ofMinutes(5));
|
||||
|
||||
private final AdvancedServerList<?> core;
|
||||
private final PluginLogger logger;
|
||||
@@ -77,7 +79,7 @@ public class UpdateChecker{
|
||||
startUpdateChecker();
|
||||
}
|
||||
|
||||
public void performeCachedUpdateCheck(CmdSender sender){
|
||||
public void performCachedUpdateCheck(CmdSender sender){
|
||||
ModrinthVersion version = cache.get(() -> {
|
||||
try{
|
||||
return performUpdateCheck().join();
|
||||
@@ -172,7 +174,7 @@ public class UpdateChecker{
|
||||
}
|
||||
|
||||
private void printUpdateBanner(ModrinthVersion version){
|
||||
logger.warn("==================================================================");
|
||||
logger.warn("=======================================================================");
|
||||
logger.warn("You are running an outdated version of AdvancedServerList!");
|
||||
logger.warn("");
|
||||
logger.warn("Your version: %s", core.getVersion());
|
||||
@@ -187,7 +189,7 @@ public class UpdateChecker{
|
||||
|
||||
logger.warn("Download the latest version from here:");
|
||||
logger.warn("https://modrinth.com/plugin/advancedserverlist/version/%s", version.id());
|
||||
logger.warn("==================================================================");
|
||||
logger.warn("=======================================================================");
|
||||
}
|
||||
|
||||
public record ModrinthVersion(String id, String versionNumber, String versionType){
|
||||
@@ -199,10 +201,5 @@ public class UpdateChecker{
|
||||
public int compare(String version){
|
||||
return FlexVerComparator.compare(version, versionNumber());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
return String.format("ModrinthVersion{id=%s,versionNumber=%s,versionType=%s}", id, versionNumber, versionType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2022-2023 Andre_601
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.andre601.advancedserverlist.core.compat.papi;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class PAPICache{
|
||||
|
||||
private CacheValue cache = null;
|
||||
|
||||
public PAPICache(){}
|
||||
|
||||
public String get(Supplier<String> supplier){
|
||||
if(cache == null || cache.isExpired())
|
||||
cache = new CacheValue(supplier.get(), System.currentTimeMillis());
|
||||
|
||||
return cache.server();
|
||||
}
|
||||
|
||||
private record CacheValue(String server, long timestamp){
|
||||
// Consider the cache expired if it is older than 5 seconds.
|
||||
public boolean isExpired(){
|
||||
return (timestamp < 0L) || System.currentTimeMillis() - timestamp >= 5000L;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,11 +25,13 @@
|
||||
|
||||
package ch.andre601.advancedserverlist.core.compat.papi;
|
||||
|
||||
import ch.andre601.advancedserverlist.core.objects.CacheUtil;
|
||||
import net.william278.papiproxybridge.api.PlaceholderAPI;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -39,7 +41,7 @@ public class PAPIUtil{
|
||||
|
||||
private final PlaceholderAPI papi;
|
||||
|
||||
private final PAPICache cache = new PAPICache();
|
||||
private final CacheUtil<String> cache = new CacheUtil<>(Duration.ofSeconds(5));
|
||||
|
||||
public PAPIUtil(){
|
||||
this.papi = PlaceholderAPI.createInstance();
|
||||
@@ -49,7 +51,7 @@ public class PAPIUtil{
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
public boolean isCompatible(){
|
||||
try{
|
||||
papi.getClass().getMethod("findServers");
|
||||
papi.getClass().getMethod("getServers");
|
||||
return true;
|
||||
}catch(NoSuchMethodException ex){
|
||||
return false;
|
||||
@@ -59,8 +61,13 @@ public class PAPIUtil{
|
||||
public String getServer(){
|
||||
return cache.get(() -> {
|
||||
List<String> servers;
|
||||
|
||||
try{
|
||||
servers = papi.findServers().getNow(Collections.emptyList());
|
||||
Set<String> value = papi.getServers().getNow(null);
|
||||
if(value == null)
|
||||
return null;
|
||||
|
||||
servers = List.copyOf(value);
|
||||
}catch(CancellationException | CompletionException ex){
|
||||
return null;
|
||||
}
|
||||
|
||||
+6
-2
@@ -118,8 +118,12 @@ public class SLPConfigMigrator{
|
||||
List<String> playerCount = resolvePlayerCounts(conf.Players);
|
||||
|
||||
int size = getMaxListSize(motds, favicons, hovers, maxPlayers, playerCount);
|
||||
for(int i = 0; i < size; i++){
|
||||
profiles.add(ProfileEntry.empty().builder());
|
||||
// Only add profiles entries when there are more than 2 entries of an option.
|
||||
// Avoids a profiles option with a single entry that has no options whatsoever.
|
||||
if(size > 1){
|
||||
for(int i = 0; i < size; i++){
|
||||
profiles.add(ProfileEntry.empty().builder());
|
||||
}
|
||||
}
|
||||
|
||||
apply(motds, builder, profiles, ProfileEntry.Builder::motd);
|
||||
|
||||
+17
-13
@@ -23,26 +23,30 @@
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.andre601.advancedserverlist.core.check;
|
||||
package ch.andre601.advancedserverlist.core.objects;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class VersionCache{
|
||||
public class CacheUtil<T>{
|
||||
|
||||
private CachedValue cachedValue = null;
|
||||
private final Duration duration;
|
||||
private CacheValue<T> cache = null;
|
||||
|
||||
public VersionCache(){}
|
||||
|
||||
public UpdateChecker.ModrinthVersion get(Supplier<UpdateChecker.ModrinthVersion> supplier){
|
||||
if(cachedValue == null || cachedValue.hasExpired())
|
||||
cachedValue = new CachedValue(System.currentTimeMillis(), supplier.get());
|
||||
|
||||
return cachedValue.version();
|
||||
public CacheUtil(Duration duration){
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
private record CachedValue(long timestamp, UpdateChecker.ModrinthVersion version){
|
||||
public boolean hasExpired(){
|
||||
return (timestamp < 0L) || System.currentTimeMillis() - timestamp >= 300_000L;
|
||||
public T get(Supplier<T> supplier){
|
||||
if(cache == null || cache.expired())
|
||||
cache = new CacheValue<>(System.currentTimeMillis(), duration, supplier.get());
|
||||
|
||||
return cache.value();
|
||||
}
|
||||
|
||||
private record CacheValue<T>(long timestamp, Duration duration, T value){
|
||||
public boolean expired(){
|
||||
return (timestamp < 0L) || System.currentTimeMillis() - timestamp >= duration.toMillis();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,23 +8,275 @@ Version `v4.8.0-b1` added support for migrating your existing `ServerListPlus.ym
|
||||
|
||||
## Important notes
|
||||
|
||||
- Migration requires that ServerListPlus is present and running, as AdvancedServerList will use its internal code to process the file.
|
||||
- The files `slp_default.yml`, `slp_personalized.yml` and `slp_banned.yml` will be created, depending on if the corresponding type (`Default`, `Personalized` and `Banned`) are present.
|
||||
Should a file with the same name be found will it be skipped.
|
||||
- The plugin will convert placeholders and color/formatting codes in the following way:
|
||||
|
||||
| Placeholder/Color/Format | Conversion |
|
||||
|--------------------------------------------|-----------------------------------------------------------------------------------|
|
||||
| `%player%` | `${player name}` |
|
||||
| `%uuid%` and `%_uuid_%` | `${player uuid}` |
|
||||
| `%online%` | `${server playersOnline}` |
|
||||
| `%max%` | `${server playersMax}` |
|
||||
| `&<color/format>` | Corresponding color/formatting code in MiniMessage (i.e. `&1 -> <dark_blue>`)[^1] |
|
||||
| `&#<hexcode>` | `<#<hexcode>>` |
|
||||
| `%gradient#<start>#<end>%<text>%gradient%` | `<gradient:#<start>:#<end>><text></gradient>` |
|
||||
Migration requires that ServerListPlus is present and running on the server.
|
||||
This is due to AdvancedServerList using the internal API of ServerListPlus to retrieve the Configuration used.
|
||||
|
||||
## Conversions
|
||||
|
||||
Specific values within the ServerListPlus configuration will be converted into equivalents supported by AdvancedServerListPlus.
|
||||
|
||||
### Placeholders
|
||||
|
||||
The following placeholders get converted:
|
||||
|
||||
| Placeholder | Conversion |
|
||||
|-------------------------|-----------------------------------------------------------------------------------|
|
||||
| `%player%` | `${player name}` |
|
||||
| `%uuid%` and `%_uuid_%` | `${player uuid}` |
|
||||
| `%online%` | `${server playersOnline}` |
|
||||
| `%max%` | `${server playersMax}` |
|
||||
|
||||
### Colors/Formatting
|
||||
|
||||
The following color and formatting codes get converted[^1]:
|
||||
|
||||
| Color/Formatting code | Conversion |
|
||||
|--------------------------------------------|-------------------------------------------------------------------------------|
|
||||
| `&<color/format>` | Corresponding color/formatting code in MiniMessage (i.e. `&1 -> <dark_blue>`) |
|
||||
| `&#<hexcode>` | `<#<hexcode>>` |
|
||||
| `%gradient#<start>#<end>%<text>%gradient%` | `<gradient:#<start>:#<end>><text></gradient>` |
|
||||
|
||||
### Favicon options
|
||||
|
||||
The following Favicon options get converted into an equivalent one:
|
||||
|
||||
| Option | Conversion |
|
||||
|---------|---------------------------------------------------------------------------------|
|
||||
| `Heads` | `https://mc-heads.net/avatar/<entry>/64/nohelm` |
|
||||
| `Helms` | Returned as-is with [placeholders replaced](#placeholders). |
|
||||
| `Files` | Only `.png` files will be included with [placeholders replaced](#placeholders). |
|
||||
|
||||
## How to Migrate
|
||||
|
||||
Execute the command [`/asl migrate serverlistplus`](../commands/index.md#migrate) to start the migration process. Make sure that ServerListPlus is present and enabled.
|
||||
|
||||
[^1]: The color/formatting code conversion is lazy and not context sensitive, meaning that a case like `&1Hello &l%player%&1!` will be converted to `<dark_blue>Hellow <bold>${player name}<dark_blue>` when it should be `<dark_blue>Hello <bold>${player name}</bold>!`. So keep that in mind.
|
||||
## Example
|
||||
|
||||
Below can you find a full example of a ServerListPlus.yml file and the corresponding migrated files from AdvancedServerList:
|
||||
|
||||
/// tab | :octicons-file-code-24: ServerListPlus.yml
|
||||
```yaml
|
||||
--- !Status
|
||||
Default:
|
||||
Description:
|
||||
- |-
|
||||
&aA Minecraft Server.
|
||||
&7Now with [&a&lPvP&7], [&a&lMinigames&7], and much more!
|
||||
- |-
|
||||
&aA Minecraft Server.
|
||||
&eNow running the latest &lMinecraft &eversion!
|
||||
- |-
|
||||
&a-bf55A Minecraft Ġd1Server.
|
||||
&e%gradient#ffbe00#f4511e%Now with RGB colors. Nice!%gradient%
|
||||
Players:
|
||||
Hover:
|
||||
- |-
|
||||
&aWelcome to &lA Minecraft Server&a!
|
||||
&aCurrently &e&l%online%/%max% &aplayers are playing on our server!
|
||||
Personalized:
|
||||
Description:
|
||||
- |-
|
||||
&aA Minecraft Server. &7| &eHello, &l%player%!
|
||||
&7Now with [&a&lPvP&7], [&a&lMinigames&7], and much more!
|
||||
- |-
|
||||
&aA Minecraft Server. &7| &eHello, &l%player%!
|
||||
&eNow running the latest &lMinecraft &eversion!
|
||||
- |-
|
||||
&a-bf55A Minecraft Ġd1Server.
|
||||
&e%gradient#ffbe00#f4511e%Now with RGB colors. Hello %player%!%gradient%
|
||||
Players:
|
||||
Hover:
|
||||
- |-
|
||||
&aWelcome back, &l%player%&a!
|
||||
&aCurrently &e&l%online%/%max% &aplayers are playing on our server!
|
||||
Favicon:
|
||||
Files:
|
||||
- favicon1.png
|
||||
- favicon2.png
|
||||
Banned:
|
||||
Description:
|
||||
- |-
|
||||
&cYou are &4&lBANNED!
|
||||
&cGo away!
|
||||
Players:
|
||||
Hidden: true
|
||||
|
||||
--- !Plugin
|
||||
PlayerTracking:
|
||||
Enabled: true
|
||||
Storage: !JSONStorage
|
||||
Enabled: true
|
||||
SaveDelay: 5m
|
||||
StripRGBIfOutdated: true
|
||||
Unknown:
|
||||
PlayerName: player
|
||||
PlayerCount: ???
|
||||
Date: ???
|
||||
BanReason: some reason
|
||||
BanOperator: somebody
|
||||
BanExpirationDate: never
|
||||
Favicon:
|
||||
Timeout: 10s
|
||||
RecursiveFolderSearch: true
|
||||
ResizeStrategy: SCALE
|
||||
|
||||
--- !Bukkit
|
||||
ProtocolLib: DISABLE
|
||||
```
|
||||
///
|
||||
|
||||
/// tab | :octicons-file-code-24: slp_default.yml
|
||||
```yaml
|
||||
priority: 0
|
||||
profiles:
|
||||
- motd:
|
||||
- <green>A Minecraft Server.
|
||||
- <grey>Now with [<green><bold>PvP<grey>], [<green><bold>Minigames<grey>], and much
|
||||
more!
|
||||
playerCount:
|
||||
hover: []
|
||||
text: ''
|
||||
hidePlayers: false
|
||||
extraPlayers:
|
||||
enabled: false
|
||||
amount: 0
|
||||
maxPlayers:
|
||||
enabled: false
|
||||
amount: 0
|
||||
favicon: ''
|
||||
- motd:
|
||||
- <green>A Minecraft Server.
|
||||
- <yellow>Now running the latest <bold>Minecraft <yellow>version!
|
||||
playerCount:
|
||||
hover: []
|
||||
text: ''
|
||||
hidePlayers: false
|
||||
extraPlayers:
|
||||
enabled: false
|
||||
amount: 0
|
||||
maxPlayers:
|
||||
enabled: false
|
||||
amount: 0
|
||||
favicon: ''
|
||||
- motd:
|
||||
- <green><#45bf55>A Minecraft <#0288d1>Server.
|
||||
- <yellow><gradient:#ffbe00:#f4511e>Now with RGB colors. Nice!</gradient>
|
||||
playerCount:
|
||||
hover: []
|
||||
text: ''
|
||||
hidePlayers: false
|
||||
extraPlayers:
|
||||
enabled: false
|
||||
amount: 0
|
||||
maxPlayers:
|
||||
enabled: false
|
||||
amount: 0
|
||||
favicon: ''
|
||||
motd: []
|
||||
playerCount:
|
||||
hover:
|
||||
- <green>Welcome to <bold>A Minecraft Server<green>!
|
||||
- <green>Currently <yellow><bold>${server playersOnline}/${server playersMax} <green>players
|
||||
are playing on our server!
|
||||
text: ''
|
||||
hidePlayers: false
|
||||
extraPlayers:
|
||||
enabled: false
|
||||
amount: 0
|
||||
maxPlayers:
|
||||
enabled: false
|
||||
amount: 0
|
||||
favicon: ''
|
||||
```
|
||||
///
|
||||
|
||||
/// tab | :octicons-file-code-24: slp_personalized.yml
|
||||
```yaml
|
||||
priority: 1
|
||||
condition: ${player name} != "Someone"
|
||||
profiles:
|
||||
- motd:
|
||||
- <green>A Minecraft Server. <grey>| <yellow>Hello, <bold>${player name}!
|
||||
- <grey>Now with [<green><bold>PvP<grey>], [<green><bold>Minigames<grey>], and much
|
||||
more!
|
||||
playerCount:
|
||||
hover: []
|
||||
text: ''
|
||||
hidePlayers: false
|
||||
extraPlayers:
|
||||
enabled: false
|
||||
amount: 0
|
||||
maxPlayers:
|
||||
enabled: false
|
||||
amount: 0
|
||||
favicon: favicon1.png
|
||||
- motd:
|
||||
- <green>A Minecraft Server. <grey>| <yellow>Hello, <bold>${player name}!
|
||||
- <yellow>Now running the latest <bold>Minecraft <yellow>version!
|
||||
playerCount:
|
||||
hover: []
|
||||
text: ''
|
||||
hidePlayers: false
|
||||
extraPlayers:
|
||||
enabled: false
|
||||
amount: 0
|
||||
maxPlayers:
|
||||
enabled: false
|
||||
amount: 0
|
||||
favicon: favicon2.png
|
||||
- motd:
|
||||
- <green><#45bf55>A Minecraft <#0288d1>Server.
|
||||
- <yellow><gradient:#ffbe00:#f4511e>Now with RGB colors. Hello ${player name}!</gradient>
|
||||
playerCount:
|
||||
hover: []
|
||||
text: ''
|
||||
hidePlayers: false
|
||||
extraPlayers:
|
||||
enabled: false
|
||||
amount: 0
|
||||
maxPlayers:
|
||||
enabled: false
|
||||
amount: 0
|
||||
favicon: ''
|
||||
motd: []
|
||||
playerCount:
|
||||
hover:
|
||||
- <green>Welcome back, <bold>${player name}<green>!
|
||||
- <green>Currently <yellow><bold>${server playersOnline}/${server playersMax} <green>players
|
||||
are playing on our server!
|
||||
text: ''
|
||||
hidePlayers: false
|
||||
extraPlayers:
|
||||
enabled: false
|
||||
amount: 0
|
||||
maxPlayers:
|
||||
enabled: false
|
||||
amount: 0
|
||||
favicon: ''
|
||||
```
|
||||
///
|
||||
|
||||
/// tab | :octicons-file-code-24: slp_banned.yml
|
||||
```yaml
|
||||
priority: 1
|
||||
condition: ${player isBanned}
|
||||
motd:
|
||||
- <red>You are <dark_red><bold>BANNED!
|
||||
- <red>Go away!
|
||||
playerCount:
|
||||
hover: []
|
||||
text: ''
|
||||
hidePlayers: true
|
||||
extraPlayers:
|
||||
enabled: false
|
||||
amount: 0
|
||||
maxPlayers:
|
||||
enabled: false
|
||||
amount: 0
|
||||
favicon: ''
|
||||
```
|
||||
///
|
||||
|
||||
[^1]:
|
||||
Converting of color and formatting codes is done lazely and without context.
|
||||
This means that a text such as `&aHello &l%player%&a!` gets converted into `<aqua>Hello <bold>${player name}<aqua>!` when it actually should be `<aqua>Hello <bold>${player name}</bold>!`
|
||||
@@ -187,8 +187,10 @@ playerCount:
|
||||
|
||||
The `playerCount -> hover` option allows you to define lines of text to show when a player hovers over the player count with their cursor.
|
||||
|
||||
Note that this option only accepts basic colors such as `<blue>` or `<grey>` and that HEX colors are not supported.
|
||||
|
||||
/// info | Notes
|
||||
Only basic color and formatting codes such as `<aqua>` and `<bold>` are accepted. Hex colors will be downsampled to the closest supported color.
|
||||
///
|
||||
|
||||
/// details | Example
|
||||
type: example
|
||||
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@
|
||||
<dependency>
|
||||
<groupId>com.viaversion</groupId>
|
||||
<artifactId>viaversion-api</artifactId>
|
||||
<version>4.10.1</version>
|
||||
<version>4.10.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -59,7 +59,7 @@ public class JoinEvent implements Listener{
|
||||
|
||||
PaperCmdSender sender = new PaperCmdSender(player);
|
||||
|
||||
plugin.getCore().getUpdateChecker().performeCachedUpdateCheck(sender);
|
||||
plugin.getCore().getUpdateChecker().performCachedUpdateCheck(sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -35,6 +35,7 @@ import ch.andre601.advancedserverlist.core.objects.CachedPlayer;
|
||||
import ch.andre601.advancedserverlist.core.parsing.ComponentParser;
|
||||
import ch.andre601.advancedserverlist.core.profiles.replacer.StringReplacer;
|
||||
import ch.andre601.advancedserverlist.paper.PaperCore;
|
||||
import ch.andre601.advancedserverlist.paper.objects.FakePlayerProfile;
|
||||
import ch.andre601.advancedserverlist.paper.objects.impl.PaperPlayerImpl;
|
||||
import ch.andre601.advancedserverlist.paper.objects.impl.PaperServerImpl;
|
||||
import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
|
||||
@@ -47,7 +48,6 @@ import org.bukkit.util.CachedServerIcon;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PaperEventWrapper implements GenericEventWrapper<CachedServerIcon, PaperPlayerImpl>{
|
||||
|
||||
@@ -104,7 +104,7 @@ public class PaperEventWrapper implements GenericEventWrapper<CachedServerIcon,
|
||||
})
|
||||
.toString();
|
||||
|
||||
players.add(Bukkit.createProfile(UUID.randomUUID(), parsed));
|
||||
players.add(FakePlayerProfile.create(parsed));
|
||||
}
|
||||
|
||||
event.getPlayerSample().addAll(players);
|
||||
|
||||
+208
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2022-2024 Andre_601
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.andre601.advancedserverlist.paper.objects;
|
||||
|
||||
import com.destroystokyo.paper.profile.PlayerProfile;
|
||||
import com.destroystokyo.paper.profile.ProfileProperty;
|
||||
import org.bukkit.profile.PlayerTextures;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public record FakePlayerProfile(String name, UUID uuid) implements PlayerProfile{
|
||||
|
||||
public static FakePlayerProfile create(String name){
|
||||
return new FakePlayerProfile(name, UUID.randomUUID());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable UUID getUniqueId(){
|
||||
return uuid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String getName(){
|
||||
return name();
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
@Override
|
||||
public @NotNull String setName(@Nullable String name){
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable UUID getId(){
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
@Override
|
||||
public @Nullable UUID setId(@Nullable UUID uuid){
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull PlayerTextures getTextures(){
|
||||
return new FakePlayeerTextures();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTextures(@Nullable PlayerTextures textures){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<ProfileProperty> getProperties(){
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasProperty(@Nullable String property){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperty(@NotNull ProfileProperty property){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProperties(@NotNull Collection<ProfileProperty> properties){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeProperty(@Nullable String property){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearProperties(){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean completeFromCache(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean completeFromCache(boolean onlineMode){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean completeFromCache(boolean lookupUUID, boolean onlineMode){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean complete(boolean textures){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean complete(boolean textures, boolean onlineMode){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull CompletableFuture<PlayerProfile> update(){
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.profile.@NotNull PlayerProfile clone(){
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Map<String, Object> serialize(){
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
private static record FakePlayeerTextures() implements PlayerTextures{
|
||||
|
||||
@Override
|
||||
public boolean isEmpty(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear(){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable URL getSkin(){
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkin(@Nullable URL skinUrl){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSkin(@Nullable URL skinUrl, @Nullable SkinModel skinModel){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull SkinModel getSkinModel(){
|
||||
return SkinModel.CLASSIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable URL getCape(){
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCape(@Nullable URL capeUrl){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTimestamp(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSigned(){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
<plugin.version>4.8.0-b2</plugin.version>
|
||||
<plugin.version>4.8.0</plugin.version>
|
||||
<plugin.description>Create multiple Server lists based on conditions.</plugin.description>
|
||||
|
||||
<api.version>3.3.0</api.version>
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public class JoinEvent{
|
||||
|
||||
VelocityCmdSender sender = new VelocityCmdSender(player);
|
||||
|
||||
plugin.getCore().getUpdateChecker().performeCachedUpdateCheck(sender);
|
||||
plugin.getCore().getUpdateChecker().performCachedUpdateCheck(sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -103,17 +103,17 @@ public class HangarVersionUploader{
|
||||
Dependency.fromNamespace("ViaVersion", false),
|
||||
Dependency.fromNamespace("Maintenance", false),
|
||||
Dependency.fromNamespace("PlaceholderAPI", false),
|
||||
Dependency.fromUrl("https://github.com/Minecrell/ServerListPlus", false)
|
||||
Dependency.fromUrl("ServerListPlus", "https://github.com/Minecrell/ServerListPlus", false)
|
||||
);
|
||||
final List<Dependency> bungeeDependencies = List.of(
|
||||
Dependency.fromNamespace("PapiProxyBridge", false),
|
||||
Dependency.fromNamespace("Maintenance", false),
|
||||
Dependency.fromUrl("https://github.com/Minecrell/ServerListPlus", false)
|
||||
Dependency.fromUrl("ServerListPlus", "https://github.com/Minecrell/ServerListPlus", false)
|
||||
);
|
||||
final List<Dependency> velocityDependencies = List.of(
|
||||
Dependency.fromNamespace("PapiProxyBridge", false),
|
||||
Dependency.fromNamespace("Maintenance", false),
|
||||
Dependency.fromUrl("https://github.com/Minecrell/ServerListPlus", false)
|
||||
Dependency.fromUrl("ServerListPlus", "https://github.com/Minecrell/ServerListPlus", false)
|
||||
);
|
||||
|
||||
final List<MultipartObject> fileInfo = List.of(
|
||||
@@ -177,7 +177,7 @@ public class HangarVersionUploader{
|
||||
String body = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
|
||||
|
||||
throw new RuntimeException(String.format(
|
||||
"Received non-successful response while uploading release. Code: %d, Message: %s, Body: %s",
|
||||
"Received non-successful response while uploading release.\nCode: %d\nMessage: %s\nBody: %s",
|
||||
response.getCode(),
|
||||
response.getReasonPhrase(),
|
||||
body
|
||||
|
||||
+2
-2
@@ -36,7 +36,7 @@ public record Dependency(String name, String externalUrl, boolean required){
|
||||
return new Dependency(name, null, required);
|
||||
}
|
||||
|
||||
public static Dependency fromUrl(String url, boolean required){
|
||||
return new Dependency(null, url, required);
|
||||
public static Dependency fromUrl(String name, String url, boolean required){
|
||||
return new Dependency(name, url, required);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user