36 Commits
Author SHA1 Message Date
XiaoMoMi a5fd4f237e Fix shaders on 1.20.5+ 2024-08-13 16:49:25 +08:00
XiaoMoMi 5046372177 2.4.6-pre-1 2024-08-11 20:28:22 +08:00
XiaoMoMi df86e4bc33 Merge pull request #38 from DrZoddiak/feature-ignore
[Feature] Support Ignoring for Chat Bubbles
2024-08-10 01:01:07 +08:00
Jesse McKee b5e83ca984 Implements ignoring bubbles
Allows for plugins that allow for ignoring to also ignore chat bubbles.

Carbon was given special attention for this PR, but other plugins will maintain prior behavior.
2024-08-08 01:06:33 -05:00
XiaoMoMi 04bb10cb3d Merge pull request #37 from DrZoddiak/fix-channel-mode
Fix channel-mode
2024-08-08 13:46:41 +08:00
Jesse McKee e7371cc02a Fix JOINED channel-mode for CarbonChatProvider
#selectedChannel only gets the channel current selected by the player if it exists. If a user does NOT select a channel, and is instead put into a default channel, the result is still `null`.

This PR provides a fallback value for channels in this case.
2024-08-08 00:27:00 -05:00
Jesse McKee bee0b26a9f Fix CAN_JOIN channel-mode
the method in question requires 1 argument, and was being passed 0. This error was being swallowed and not shown in console, so it was not immediately obvious.

Reading the JD for #invoke
`If the underlying method is static, then the specified obj argument is ignored. It may be null.`

So in order to pass the arg required, and because the method is indeed static, the first parameter is now null.
2024-08-08 00:21:05 -05:00
XiaoMoMi 343c0e5cb0 Update build.gradle.kts 2024-08-04 16:48:29 +08:00
XiaoMoMi 81d3a888b8 2.4.4 2024-08-04 16:48:02 +08:00
XiaoMoMi 58e16e5376 Fixed nms on 1.18.2 2024-07-27 17:17:42 +08:00
XiaoMoMi cc8c3d6bcd 2.4.2 2024-07-25 22:41:15 +08:00
XiaoMoMi 3000b26bfa Fix async events 2024-07-03 15:56:47 +08:00
XiaoMoMi a800481574 Update NameplateManagerImpl.java 2024-07-03 15:23:46 +08:00
XiaoMoMi 82350ac0c4 Fix some issues 2024-07-03 15:09:39 +08:00
XiaoMoMi 35edd85434 Update en.yml 2024-06-28 22:51:15 +08:00
XiaoMoMi 99bfc28be8 1.21 support 2024-06-28 02:52:20 +08:00
XiaoMoMi 5ee27c126c fix shader on 1.20.5+ 2024-06-28 01:12:39 +08:00
XiaoMoMi 5282d5e8a7 use NMS to send bossbar 2024-06-28 00:21:19 +08:00
XiaoMoMi 0f7a72bf1e Merge pull request #33 from relpia/main
Create kr.yml
2024-06-26 19:45:58 +08:00
XiaoMoMi b36d0c23e1 some changes 2024-06-24 00:14:44 +08:00
Horibin f8219659c4 Add files via upload 2024-06-22 13:01:28 +09:00
XiaoMoMi eb730c8631 Merge pull request #32 from Vondri/patch-2
Create pl.yml
2024-05-25 17:03:59 +08:00
Vondri 12b8b74031 Create pl.yml
Translation for polish
2024-05-18 00:46:15 +02:00
XiaoMoMi 365aae10f5 2.3.3.9 2024-05-07 22:34:39 +08:00
XiaoMoMi 5e299bb0d4 Update build logics 2024-05-04 05:10:53 +08:00
XiaoMoMi 79a0892b09 [Update] Updated dependencies 2024-04-23 03:43:07 +08:00
XiaoMoMi a8bc4d8de5 update shaders 2024-04-22 01:14:48 +08:00
XiaoMoMi 6276d27d57 Merge branch 'main' of https://github.com/Xiao-MoMi/Custom-Nameplates 2024-04-16 23:39:06 +08:00
XiaoMoMi 096e6330d6 2.3.3.8 2024-04-16 23:39:01 +08:00
XiaoMoMi e41686aa31 Merge pull request #30 from Schroddinger/release
Tweaks to Spanish translation
2024-04-16 02:39:05 +08:00
Schroddinger 590b26ac2a Tweaks to Spanish translation 2024-04-14 11:19:13 -05:00
XiaoMoMi a7dc0db15d rename language files 2024-04-14 20:19:37 +08:00
XiaoMoMi c9250fea13 Merge pull request #28 from jhqwqmc/main
small changes
2024-04-07 21:33:26 +08:00
jhqwqmc fa914d52a2 del time-24 2024-04-07 21:12:10 +08:00
jhqwqmc efbf2d3b64 Update config file 2024-04-07 21:03:01 +08:00
jhqwqmc 40672aefb4 small changes
Add a 24-hour time variable
Fix weather detection issue
2024-04-07 21:00:50 +08:00
70 changed files with 765 additions and 1143 deletions

No files matched your search

+1
View File
@@ -1,6 +1,7 @@
# Custom-Nameplates
![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/Xiao-MoMi/Custom-Nameplates)
![Code Size](https://img.shields.io/github/languages/code-size/Xiao-MoMi/Custom-Nameplates)
![bStats Servers](https://img.shields.io/bstats/servers/16649)
![bStats Players](https://img.shields.io/bstats/players/16649)
![GitHub](https://img.shields.io/github/license/Xiao-MoMi/Custom-Nameplates)
+1 -1
View File
@@ -2,7 +2,7 @@ dependencies {
compileOnly("dev.folia:folia-api:1.20.1-R0.1-SNAPSHOT")
compileOnly("me.clip:placeholderapi:2.11.5")
implementation(project(":common"))
implementation("net.kyori:adventure-api:4.15.0")
implementation("net.kyori:adventure-api:4.16.0")
}
tasks {
@@ -26,5 +26,6 @@ public enum StorageType {
MySQL,
MariaDB,
MongoDB,
Redis
Redis,
None
}
@@ -28,13 +28,6 @@ public interface VersionManager {
*/
boolean isFolia();
/**
* Get bukkit version
*
* @return version
*/
String getServerVersion();
/**
* Check update
*
@@ -42,6 +35,8 @@ public interface VersionManager {
*/
CompletionStage<Boolean> checkUpdate();
boolean isVersionNewerThan1_20_5();
/**
* Get plugin version
*
@@ -66,6 +61,8 @@ public interface VersionManager {
boolean isVersionNewerThan1_19();
boolean isMojmap();
boolean isVersionNewerThan1_19_R2();
boolean isVersionNewerThan1_19_R3();
@@ -36,4 +36,6 @@ public abstract class AbstractChatProvider implements Listener {
public abstract boolean hasJoinedChannel(Player player, String channelID);
public abstract boolean canJoinChannel(Player player, String channelID);
public abstract boolean isIgnoring(Player sender, Player receiver);
}
+4 -4
View File
@@ -2,17 +2,17 @@ plugins {
id("java")
id("application")
id("maven-publish")
id("com.github.johnrengelman.shadow") version "8.1.1"
id("io.github.goooler.shadow") version "8.1.7"
}
allprojects {
version = "2.3.3.7"
version = "2.4.7"
apply<JavaPlugin>()
apply(plugin = "java")
apply(plugin = "application")
apply(plugin = "com.github.johnrengelman.shadow")
apply(plugin = "io.github.goooler.shadow")
apply(plugin = "org.gradle.maven-publish")
application {
@@ -20,8 +20,8 @@ allprojects {
}
repositories {
maven("https://maven.aliyun.com/repository/public/")
mavenCentral()
maven("https://maven.aliyun.com/repository/public/")
maven("https://papermc.io/repo/repository/maven-public/")
maven("https://oss.sonatype.org/content/groups/public/")
maven("https://repo.dmulloy2.net/repository/public/")
+3 -3
View File
@@ -10,10 +10,10 @@ dependencies {
compileOnly("net.md-5:bungeecord-event:1.20-R0.2-SNAPSHOT")
compileOnly("net.md-5:bungeecord-proxy:1.20-R0.2-SNAPSHOT")
implementation("net.kyori:adventure-api:4.15.0")
implementation("net.kyori:adventure-api:4.16.0")
implementation("net.kyori:adventure-platform-bungeecord:4.3.2")
implementation("net.kyori:adventure-text-minimessage:4.15.0")
implementation("net.kyori:adventure-text-serializer-legacy:4.15.0")
implementation("net.kyori:adventure-text-minimessage:4.16.0")
implementation("net.kyori:adventure-text-serializer-legacy:4.16.0")
}
tasks {
@@ -1,47 +0,0 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customnameplates.bungeecord.team;
import me.neznamy.tab.api.TabAPI;
import me.neznamy.tab.api.TabPlayer;
import me.neznamy.tab.api.tablist.SortingManager;
import net.md_5.bungee.api.connection.ProxiedPlayer;
public class TABProvider implements TeamProvider {
private final TabAPI api;
private final SortingManager sortingManager;
public TABProvider() {
this.api = TabAPI.getInstance();
this.sortingManager = api.getSortingManager();
}
@Override
public String getTeam(ProxiedPlayer player, ProxiedPlayer ignore) {
TabPlayer tabPlayer = api.getPlayer(player.getUniqueId());
if (tabPlayer == null) {
return null;
}
String forced = sortingManager.getForcedTeamName(tabPlayer);
if (forced != null) {
return forced;
}
return sortingManager.getOriginalTeamName(tabPlayer);
}
}
@@ -1,25 +0,0 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customnameplates.bungeecord.team;
import net.md_5.bungee.api.connection.ProxiedPlayer;
public interface TeamProvider {
String getTeam(ProxiedPlayer player, ProxiedPlayer viewer);
}
@@ -1,115 +0,0 @@
package net.momirealms.customnameplates.bungeecord.team;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
import net.md_5.bungee.netty.PacketHandler;
import net.md_5.bungee.protocol.packet.Team;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
public class UnknownProvider extends PacketHandler implements Listener, TeamProvider {
private final ConcurrentHashMap<UUID, PlayerTeamView> teamViewMap;
public UnknownProvider() {
this.teamViewMap = new ConcurrentHashMap<>();
}
@Override
public void handle(Team team) {
switch (team.getMode()) {
case 0, 3 -> {
}
case 1 -> {
}
}
}
@Override
public String toString() {
return null;
}
@EventHandler
public void onPostLogin(PostLoginEvent event) {
teamViewMap.put(event.getPlayer().getUniqueId(), new PlayerTeamView());
}
@EventHandler
public void onDisConnect(PlayerDisconnectEvent event) {
teamViewMap.remove(event.getPlayer().getUniqueId());
}
@Override
public String getTeam(ProxiedPlayer player, ProxiedPlayer viewer) {
return null;
}
public static class PlayerTeamView {
private final HashMap<String, String> playerToTeamMap;
private final HashMap<String, String[]> teamToPlayerMap;
public PlayerTeamView() {
this.playerToTeamMap = new HashMap<>();
this.teamToPlayerMap = new HashMap<>();
}
public String getTeam(ProxiedPlayer player) {
return playerToTeamMap.get(player.getName());
}
public void removeTeam(String team) {
String[] removedMembers = teamToPlayerMap.remove(team);
if (removedMembers != null) {
for (String member : removedMembers) {
playerToTeamMap.remove(member);
}
}
}
public void addMembers(String team, Collection<String> members) {
String[] oldMembers = teamToPlayerMap.remove(team);
if (oldMembers != null) {
String[] newMembers = new String[members.size() + oldMembers.length];
int i = 0;
for (String m : oldMembers) {
newMembers[i] = m;
i++;
}
for (String m : members) {
newMembers[i] = m;
i++;
}
teamToPlayerMap.put(team, newMembers);
for (String member : newMembers) {
playerToTeamMap.put(member, team);
}
} else {
teamToPlayerMap.put(team, members.toArray(new String[0]));
for (String member : members) {
playerToTeamMap.put(member, team);
}
}
}
public void removeMembers(String team, Collection<String> members) {
String[] oldMembers = teamToPlayerMap.remove(team);
if (oldMembers != null) {
ArrayList<String> newMembers = new ArrayList<>(Arrays.asList(oldMembers));
for (String member : members) {
playerToTeamMap.remove(member);
newMembers.remove(member);
}
teamToPlayerMap.put(team, newMembers.toArray(new String[0]));
}
}
}
}
+1 -2
View File
@@ -1,5 +1,4 @@
name: CustomNameplates
main: net.momirealms.customnameplates.bungeecord.CustomNameplatesBungeeCord
version: '${version}'
author: XiaoMoMi
softDepends: [TAB, BungeeTabListPlus]
author: XiaoMoMi
-8
View File
@@ -1,8 +0,0 @@
#systemProp.socks.proxyHost=127.0.0.1
#systemProp.socks.proxyPort=7890
#
#systemProp.http.proxyHost=127.0.0.1
#systemProp.http.proxyPort=7890
#
#systemProp.https.proxyHost=127.0.0.1
#systemProp.https.proxyPort=7890
+11 -10
View File
@@ -3,16 +3,16 @@ dependencies {
compileOnly("dev.folia:folia-api:1.20.1-R0.1-SNAPSHOT")
// command
compileOnly("dev.jorel:commandapi-bukkit-core:9.3.0")
compileOnly("dev.jorel:commandapi-bukkit-core:9.5.3")
// packet
compileOnly("com.comphenix.protocol:ProtocolLib:5.2.0-SNAPSHOT")
// papi
compileOnly("me.clip:placeholderapi:2.11.5")
compileOnly("me.clip:placeholderapi:2.11.6")
// config
compileOnly("dev.dejvokep:boosted-yaml:1.3.2")
compileOnly("dev.dejvokep:boosted-yaml:1.3.6")
// bStats
compileOnly("org.bstats:bstats-bukkit:3.0.2")
@@ -25,11 +25,11 @@ dependencies {
compileOnly("com.google.code.gson:gson:2.10.1")
// database
compileOnly("org.xerial:sqlite-jdbc:3.43.0.0")
compileOnly("org.xerial:sqlite-jdbc:3.45.3.0")
compileOnly("com.h2database:h2:2.2.224")
compileOnly("org.mongodb:mongodb-driver-sync:4.11.1")
compileOnly("org.mongodb:mongodb-driver-sync:5.0.1")
compileOnly("com.zaxxer:HikariCP:5.0.1")
compileOnly("redis.clients:jedis:5.1.0")
compileOnly("redis.clients:jedis:5.1.3")
// others
compileOnly("com.github.LoneDev6:api-itemsadder:3.5.0c-r5")
@@ -38,28 +38,29 @@ dependencies {
compileOnly("commons-io:commons-io:2.15.1")
compileOnly("org.geysermc.geyser:api:2.2.0-SNAPSHOT")
compileOnly("LibsDisguises:LibsDisguises:10.0.42")
implementation("com.github.Xiao-MoMi:BiomeAPI:0.3")
// chat channels
compileOnly(files("libs/VentureChat-3.7.1.jar"))
compileOnly(files("libs/TrChat-2.0.11.jar"))
compileOnly(files("libs/carbonchat-paper-3.0.0-beta.26.jar"))
compileOnly(files("libs/AdvancedChat-1.3.7.jar"))
compileOnly("net.william278:huskchat:2.7.1")
// api module
implementation(project(":api"))
implementation(project(":common"))
implementation("com.github.Xiao-MoMi:Sparrow-Heart:0.35")
// adventure
implementation("net.kyori:adventure-api:4.15.0")
implementation("net.kyori:adventure-platform-bukkit:4.3.2")
implementation("net.kyori:adventure-api:4.17.0")
implementation("net.kyori:adventure-platform-bukkit:4.3.3")
}
tasks {
shadowJar {
relocate ("net.kyori", "net.momirealms.customnameplates.libraries")
relocate ("org.bstats", "net.momirealms.customnameplates.libraries.bstats")
relocate ("net.momirealms.biomeapi", "net.momirealms.customnameplates.libraries.biomeapi")
relocate ("net.momirealms.sparrow.heart", "net.momirealms.customnameplates.libraries.sparrow")
relocate ("org.apache.commons.pool2", "net.momirealms.customnameplates.libraries.commonspool2")
relocate ("com.mysql", "net.momirealms.customnameplates.libraries.mysql")
relocate ("org.mariadb", "net.momirealms.customnameplates.libraries.mariadb")
Binary file not shown.
@@ -64,16 +64,15 @@ public class CustomNameplatesPluginImpl extends CustomNameplatesPlugin implement
@Override
public void onLoad() {
this.versionManager = new VersionManagerImpl(this);
this.dependencyManager = new DependencyManagerImpl(this, new ReflectionClassPathAppender(this.getClassLoader()));
this.dependencyManager.loadDependencies(new ArrayList<>(
List.of(
Dependency.GSON,
Dependency.SLF4J_API,
Dependency.SLF4J_SIMPLE,
Dependency.COMMAND_API,
versionManager.isMojmap() ? Dependency.COMMAND_API_MOJMAP : Dependency.COMMAND_API,
Dependency.BOOSTED_YAML,
Dependency.ADVENTURE_TEXT_MINIMESSAGE,
Dependency.ADVENTURE_LEGACY_SERIALIZER,
Dependency.MYSQL_DRIVER,
Dependency.MARIADB_DRIVER,
Dependency.MONGODB_DRIVER_SYNC,
@@ -99,7 +98,6 @@ public class CustomNameplatesPluginImpl extends CustomNameplatesPlugin implement
return;
}
this.adventureManager = new AdventureManagerImpl(this);
this.versionManager = new VersionManagerImpl(this);
this.scheduler = new SchedulerImpl(this);
this.storageManager = new StorageManagerImpl(this);
this.requirementManager = new RequirementManagerImpl(this);
@@ -19,7 +19,6 @@ package net.momirealms.customnameplates.paper.adventure;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
@@ -75,8 +74,8 @@ public class AdventureManagerImpl implements AdventureManager {
this.cacheSystem = new CacheSystem(CNConfig.cacheSize);
}
public WrappedChatComponent getWrappedChatComponentFromMiniMessage(String text) {
return cacheSystem.getWrappedChatComponentFromCache(text);
public String getJsonComponentFromMiniMessage(String text) {
return cacheSystem.getJsonComponentFromCache(text);
}
public Object getIChatComponentFromMiniMessage(String text) {
@@ -286,11 +285,15 @@ public class AdventureManagerImpl implements AdventureManager {
}
}
public Audience audience(Player player) {
return adventure.player(player);
}
public class CacheSystem {
private final LoadingCache<String, Object> miniMessageToIChatComponentCache;
private final LoadingCache<String, Component> miniMessageToComponentCache;
private final LoadingCache<String, WrappedChatComponent> miniMessageToWrappedChatComponentCache;
private final LoadingCache<String, String> miniMessageToJsonChatComponentCache;
public CacheSystem(int size) {
miniMessageToIChatComponentCache = CacheBuilder.newBuilder()
@@ -315,15 +318,15 @@ public class AdventureManagerImpl implements AdventureManager {
return fetchComponent(text);
}
});
miniMessageToWrappedChatComponentCache = CacheBuilder.newBuilder()
miniMessageToJsonChatComponentCache = CacheBuilder.newBuilder()
.maximumSize(size)
.expireAfterWrite(10, TimeUnit.MINUTES)
.build(
new CacheLoader<>() {
@NotNull
@Override
public WrappedChatComponent load(@NotNull String text) {
return fetchWrappedChatComponent(text);
public String load(@NotNull String text) {
return fetchJsonChatComponent(text);
}
});
}
@@ -349,11 +352,11 @@ public class AdventureManagerImpl implements AdventureManager {
}
@NotNull
private WrappedChatComponent fetchWrappedChatComponent(String text) {
private String fetchJsonChatComponent(String text) {
if (CNConfig.legacyColorSupport) {
return WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize(legacyToMiniMessage(text))));
return GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize(legacyToMiniMessage(text)));
} else {
return WrappedChatComponent.fromJson(GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize(text)));
return GsonComponentSerializer.gson().serialize(MiniMessage.miniMessage().deserialize(text));
}
}
@@ -375,12 +378,12 @@ public class AdventureManagerImpl implements AdventureManager {
}
}
public WrappedChatComponent getWrappedChatComponentFromCache(String text) {
public String getJsonComponentFromCache(String text) {
try {
return miniMessageToWrappedChatComponentCache.get(text);
return miniMessageToJsonChatComponentCache.get(text);
} catch (ExecutionException e) {
e.printStackTrace();
return WrappedChatComponent.fromText("");
return "{\"text\":\"\"}";
}
}
}
@@ -35,21 +35,21 @@ import java.util.List;
import java.util.Locale;
/**
* The dependencies used by LuckPerms.
* The dependencies used by CustomNameplates.
*/
public enum Dependency {
ASM(
"org.ow2.asm",
"asm",
"9.1",
"9.7",
null,
"asm"
),
ASM_COMMONS(
"org.ow2.asm",
"asm-commons",
"9.1",
"9.7",
null,
"asm-commons"
),
@@ -60,114 +60,26 @@ public enum Dependency {
null,
"jar-relocator"
),
KYORI_OPTION(
"net{}kyori",
"option",
"1.0.0",
null,
"kyori-option",
Relocation.of("option", "net{}kyori{}option")
),
ADVENTURE_API(
"net{}kyori",
"adventure-api",
"4.15.0",
null,
"adventure-api",
Relocation.of("adventure", "net{}kyori{}adventure")
),
ADVENTURE_KEY(
"net{}kyori",
"adventure-key",
"4.15.0",
null,
"adventure-key",
Relocation.of("adventure", "net{}kyori{}adventure")
),
ADVENTURE_NBT(
"net{}kyori",
"adventure-nbt",
"4.15.0",
null,
"adventure-nbt",
Relocation.of("adventure", "net{}kyori{}adventure")
),
ADVENTURE_LEGACY_SERIALIZER(
"net{}kyori",
"adventure-text-serializer-legacy",
"4.15.0",
null,
"adventure-text-serializer-legacy",
Relocation.of("adventure", "net{}kyori{}adventure")
),
ADVENTURE_TEXT_LOGGER(
"net{}kyori",
"adventure-text-logger-slf4j",
"4.15.0",
null,
"adventure-text-logger-slf4j",
Relocation.of("adventure", "net{}kyori{}adventure")
),
ADVENTURE_GSON(
"net{}kyori",
"adventure-text-serializer-gson",
"4.15.0",
null,
"adventure-text-serializer-gson",
Relocation.of("adventure", "net{}kyori{}adventure")
),
ADVENTURE_GSON_LEGACY(
"net{}kyori",
"adventure-text-serializer-gson-legacy-impl",
"4.15.0",
null,
"adventure-text-serializer-gson-legacy-impl",
Relocation.of("adventure", "net{}kyori{}adventure")
),
ADVENTURE_PLATFORM(
"net{}kyori",
"adventure-platform-api",
"4.3.2",
null,
"adventure-platform-api",
Relocation.of("adventure", "net{}kyori{}adventure")
),
ADVENTURE_PLATFORM_BUKKIT(
"net{}kyori",
"adventure-platform-bukkit",
"4.3.2",
null,
"adventure-platform-bukkit",
Relocation.of("adventure", "net{}kyori{}adventure")
),
ADVENTURE_PLATFORM_FACET(
"net{}kyori",
"adventure-platform-facet",
"4.3.2",
null,
"adventure-platform-facet",
Relocation.of("adventure", "net{}kyori{}adventure")
),
ADVENTURE_TEXT_MINIMESSAGE(
"net{}kyori",
"adventure-text-minimessage",
"4.15.0",
null,
"adventure-text-minimessage",
Relocation.of("adventure", "net{}kyori{}adventure")
),
COMMAND_API(
"dev{}jorel",
"commandapi-bukkit-shade",
"9.3.0",
"9.5.3",
null,
"commandapi-bukkit",
Relocation.of("commandapi", "dev{}jorel{}commandapi")
),
COMMAND_API_MOJMAP(
"dev{}jorel",
"commandapi-bukkit-shade-mojang-mapped",
"9.5.3",
null,
"commandapi-bukkit-mojang-mapped",
Relocation.of("commandapi", "dev{}jorel{}commandapi")
),
MARIADB_DRIVER(
"org{}mariadb{}jdbc",
"mariadb-java-client",
"3.3.2",
"3.3.3",
null,
"mariadb-java-client",
Relocation.of("mariadb", "org{}mariadb")
@@ -175,7 +87,7 @@ public enum Dependency {
BOOSTED_YAML(
"dev{}dejvokep",
"boosted-yaml",
"1.3.2",
"1.3.6",
null,
"boosted-yaml",
Relocation.of("boostedyaml", "dev{}dejvokep{}boostedyaml")
@@ -183,7 +95,7 @@ public enum Dependency {
MYSQL_DRIVER(
"com{}mysql",
"mysql-connector-j",
"8.3.0",
"9.0.0",
null,
"mysql-connector-j",
Relocation.of("mysql", "com{}mysql")
@@ -198,14 +110,14 @@ public enum Dependency {
SQLITE_DRIVER(
"org.xerial",
"sqlite-jdbc",
"3.45.1.0",
"3.46.0.1",
null,
"sqlite-jdbc"
),
HIKARI(
"com{}zaxxer",
"HikariCP",
"5.0.1",
"5.1.0",
null,
"HikariCP",
Relocation.of("hikari", "com{}zaxxer{}hikari")
@@ -227,7 +139,7 @@ public enum Dependency {
MONGODB_DRIVER_CORE(
"org{}mongodb",
"mongodb-driver-core",
"4.11.1",
"5.1.0",
null,
"mongodb-driver-core",
Relocation.of("mongodb", "com{}mongodb"),
@@ -236,7 +148,7 @@ public enum Dependency {
MONGODB_DRIVER_SYNC(
"org{}mongodb",
"mongodb-driver-sync",
"4.11.1",
"5.1.0",
null,
"mongodb-driver-sync",
Relocation.of("mongodb", "com{}mongodb"),
@@ -245,7 +157,7 @@ public enum Dependency {
MONGODB_DRIVER_BSON(
"org{}mongodb",
"bson",
"4.11.1",
"5.1.0",
null,
"mongodb-bson",
Relocation.of("mongodb", "com{}mongodb"),
@@ -254,7 +166,7 @@ public enum Dependency {
JEDIS(
"redis{}clients",
"jedis",
"5.1.0",
"5.1.2",
null,
"jedis",
Relocation.of("jedis", "redis{}clients{}jedis"),
@@ -290,14 +202,6 @@ public enum Dependency {
"2.10.1",
null,
"gson"
),
BIOME_API(
"com{}github{}Xiao-MoMi",
"BiomeAPI",
"0.3",
"jitpack",
"biome-api",
Relocation.of("biomeapi", "net{}momirealms{}biomeapi")
);
private final String mavenRepoPath;
@@ -26,6 +26,7 @@
package net.momirealms.customnameplates.paper.libraries.dependencies;
import com.google.common.collect.ImmutableSet;
import net.momirealms.customnameplates.api.util.LogUtils;
import net.momirealms.customnameplates.paper.CustomNameplatesPluginImpl;
import net.momirealms.customnameplates.paper.libraries.classpath.ClassPathAppender;
import net.momirealms.customnameplates.paper.libraries.dependencies.classloader.IsolatedClassLoader;
@@ -64,13 +65,7 @@ public class DependencyManagerImpl implements DependencyManager {
this.registry = new DependencyRegistry();
this.cacheDirectory = setupCacheDirectory(plugin);
this.classPathAppender = classPathAppender;
}
private synchronized RelocationHandler getRelocationHandler() {
if (this.relocationHandler == null) {
this.relocationHandler = new RelocationHandler(this);
}
return this.relocationHandler;
this.relocationHandler = new RelocationHandler(this);
}
@Override
@@ -156,6 +151,7 @@ public class DependencyManagerImpl implements DependencyManager {
DependencyDownloadException lastError = null;
String fileName = dependency.getFileName(null);
String forceRepo = dependency.getRepo();
if (forceRepo == null) {
// attempt to download the dependency from each repo in order.
@@ -164,7 +160,9 @@ public class DependencyManagerImpl implements DependencyManager {
continue;
}
try {
LogUtils.info("Downloading dependency(" + fileName + ") from " + repo.getUrl() + dependency.getMavenRepoPath());
repo.download(dependency, file);
LogUtils.info("Successfully downloaded " + fileName);
return file;
} catch (DependencyDownloadException e) {
lastError = e;
@@ -174,7 +172,9 @@ public class DependencyManagerImpl implements DependencyManager {
DependencyRepository repository = DependencyRepository.getByID(forceRepo);
if (repository != null) {
try {
LogUtils.info("Downloading dependency(" + fileName + ") from " + repository.getUrl() + dependency.getMavenRepoPath());
repository.download(dependency, file);
LogUtils.info("Successfully downloaded " + fileName);
return file;
} catch (DependencyDownloadException e) {
lastError = e;
@@ -197,7 +197,9 @@ public class DependencyManagerImpl implements DependencyManager {
return remappedFile;
}
getRelocationHandler().remap(normalFile, remappedFile, rules);
LogUtils.info("Remapping " + dependency.getFileName(null));
relocationHandler.remap(normalFile, remappedFile, rules);
LogUtils.info("Successfully remapped " + dependency.getFileName(null));
return remappedFile;
}
@@ -28,7 +28,7 @@ package net.momirealms.customnameplates.paper.libraries.dependencies;
import com.google.gson.JsonElement;
/**
* Applies LuckPerms specific behaviour for {@link Dependency}s.
* Applies CustomNameplates specific behaviour for {@link Dependency}s.
*/
public class DependencyRegistry {
@@ -71,6 +71,10 @@ public enum DependencyRepository {
this.id = id;
}
public String getUrl() {
return url;
}
public static DependencyRepository getByID(String id) {
for (DependencyRepository repository : values()) {
if (id.equals(repository.id)) {
@@ -31,7 +31,7 @@ import java.net.URLClassLoader;
/**
* A classloader "isolated" from the rest of the Minecraft server.
*
* <p>Used to load specific LuckPerms dependencies without causing conflicts
* <p>Used to load specific CustomNameplates dependencies without causing conflicts
* with other plugins, or libraries provided by the server implementation.</p>
*/
public class IsolatedClassLoader extends URLClassLoader {
@@ -29,7 +29,6 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
import net.momirealms.customnameplates.api.manager.ActionBarManager;
import net.momirealms.customnameplates.api.util.LogUtils;
import net.momirealms.customnameplates.paper.adventure.AdventureManagerImpl;
import net.momirealms.customnameplates.paper.mechanic.actionbar.listener.ActionBarListener;
import net.momirealms.customnameplates.paper.mechanic.actionbar.listener.ChatMessageListener;
import net.momirealms.customnameplates.paper.mechanic.actionbar.listener.SystemChatListener;
@@ -17,15 +17,12 @@
package net.momirealms.customnameplates.paper.mechanic.bossbar;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.InternalStructure;
import com.comphenix.protocol.events.PacketContainer;
import net.momirealms.customnameplates.paper.adventure.AdventureManagerImpl;
import net.momirealms.customnameplates.paper.mechanic.misc.PacketManager;
import net.momirealms.customnameplates.paper.util.ReflectionUtils;
import net.momirealms.sparrow.heart.SparrowHeart;
import net.momirealms.sparrow.heart.feature.bossbar.BossBarColor;
import net.momirealms.sparrow.heart.feature.bossbar.BossBarOverlay;
import org.bukkit.entity.Player;
import java.lang.reflect.InvocationTargetException;
import java.util.UUID;
public class BossBar {
@@ -46,17 +43,17 @@ public class BossBar {
}
public void show() {
PacketManager.getInstance().send(owner, getCreatePacket());
SparrowHeart.getInstance().createBossBar(owner, uuid, AdventureManagerImpl.getInstance().getJsonComponentFromMiniMessage(latestMiniMessage), BossBarColor.valueOf(barColor.name()), BossBarOverlay.valueOf(overlay.name()), 0f, false, false, false);
this.visible = true;
}
public void hide() {
PacketManager.getInstance().send(owner, getRemovePacket());
SparrowHeart.getInstance().removeBossBar(owner, uuid);
this.visible = false;
}
public void update() {
PacketManager.getInstance().send(owner, getUpdatePacket());
SparrowHeart.getInstance().updateBossBarName(owner, uuid, AdventureManagerImpl.getInstance().getJsonComponentFromMiniMessage(latestMiniMessage));
}
public boolean isVisible() {
@@ -66,38 +63,4 @@ public class BossBar {
public void setMiniMessageText(String text) {
latestMiniMessage = text;
}
private PacketContainer getCreatePacket() {
PacketContainer packet = new PacketContainer(PacketType.Play.Server.BOSS);
packet.getModifier().write(0, uuid);
InternalStructure internalStructure = packet.getStructures().read(1);
internalStructure.getChatComponents().write(0, AdventureManagerImpl.getInstance().getWrappedChatComponentFromMiniMessage(latestMiniMessage));
internalStructure.getFloat().write(0,1F);
internalStructure.getEnumModifier(BarColor.class, 2).write(0, barColor);
internalStructure.getEnumModifier(Overlay.class, 3).write(0, overlay);
internalStructure.getModifier().write(4, false);
internalStructure.getModifier().write(5, false);
internalStructure.getModifier().write(6, false);
return packet;
}
private PacketContainer getUpdatePacket() {
PacketContainer packet = new PacketContainer(PacketType.Play.Server.BOSS);
packet.getModifier().write(0, uuid);
try {
Object chatComponent = AdventureManagerImpl.getInstance().getIChatComponentFromMiniMessage(latestMiniMessage);
Object updatePacket = ReflectionUtils.getUpdateConstructor().newInstance(chatComponent);
packet.getModifier().write(1, updatePacket);
} catch (InvocationTargetException | IllegalAccessException | InstantiationException e) {
throw new RuntimeException(e);
}
return packet;
}
private PacketContainer getRemovePacket() {
PacketContainer packet = new PacketContainer(PacketType.Play.Server.BOSS);
packet.getModifier().write(0, uuid);
packet.getModifier().write(1, ReflectionUtils.getRemoveBossBarPacket());
return packet;
}
}
@@ -164,6 +164,8 @@ public class BubbleManagerImpl implements BubbleManager, Listener {
this.chatProvider = new HuskChatProvider(this);
} else if (CNConfig.carbonChatChannel) {
this.chatProvider = new CarbonChatProvider(this);
} else if (CNConfig.advancedChatChannel) {
this.chatProvider = new AdvancedChatProvider(this);
} else {
try {
Class.forName("io.papermc.paper.event.player.AsyncChatEvent");
@@ -348,17 +350,20 @@ public class BubbleManagerImpl implements BubbleManager, Listener {
return;
StaticTextEntity entity = tagEntity.addTag(StaticTextTagSetting.builder()
.leaveRule((p, e) -> true)
.comeRule((p, e) -> {
.leaveRule((receiver, owner) -> true)
.comeRule((receiver, owner) -> {
if ((owner instanceof Player sender) && chatProvider.isIgnoring(sender, receiver)) {
return false;
}
switch (channelMode) {
case ALL -> {
return true;
}
case JOINED -> {
return channel == null || chatProvider.hasJoinedChannel(p, channel);
return channel == null || chatProvider.hasJoinedChannel(receiver, channel);
}
case CAN_JOIN -> {
return channel == null || chatProvider.canJoinChannel(p, channel);
return channel == null || chatProvider.canJoinChannel(receiver, channel);
}
}
return false;
@@ -0,0 +1,88 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customnameplates.paper.mechanic.bubble.provider;
import net.advancedplugins.chat.api.AdvancedChannelChatEvent;
import net.advancedplugins.chat.api.AdvancedChatAPI;
import net.advancedplugins.chat.channel.ChatChannel;
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
import net.momirealms.customnameplates.api.manager.BubbleManager;
import net.momirealms.customnameplates.api.mechanic.bubble.provider.AbstractChatProvider;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import java.util.List;
public class AdvancedChatProvider extends AbstractChatProvider {
public AdvancedChatProvider(BubbleManager chatBubblesManager) {
super(chatBubblesManager);
}
@Override
public void register() {
Bukkit.getPluginManager().registerEvents(this, CustomNameplatesPlugin.get());
}
@Override
public void unregister() {
HandlerList.unregisterAll(this);
}
@Override
public boolean hasJoinedChannel(Player player, String channelID) {
ChatChannel chatChannel = AdvancedChatAPI.getApi().getPlayerChatChannel(player.getUniqueId());
if (chatChannel == null) {
return false;
}
return chatChannel.getSectionName().equals(channelID);
}
@Override
public boolean canJoinChannel(Player player, String channelID) {
List<ChatChannel> channelList = AdvancedChatAPI.getApi().getAllowedChatChannels(player);
for (ChatChannel chatChannel : channelList) {
if (chatChannel.getSectionName().equals(channelID)) {
return true;
}
}
return false;
}
@Override
public boolean isIgnoring(Player sender, Player receiver) {
return AdvancedChatAPI.getApi().getIgnoredPlayers(receiver).contains(sender.getName());
}
@EventHandler (ignoreCancelled = true)
public void onAdvancedChat(AdvancedChannelChatEvent event) {
String channel = event.getChannel().getSectionName();
for (String black : chatBubblesManager.getBlacklistChannels()) {
if (channel.equals(black)) return;
}
if (event.getSender() instanceof Player player) {
if (!player.isOnline())
return;
CustomNameplatesPlugin.get().getScheduler().runTaskAsync(() -> {
chatBubblesManager.onChat(player, event.getMessage(), channel);
});
}
}
}
@@ -52,6 +52,11 @@ public class AsyncChatProvider extends AbstractChatProvider {
return true;
}
@Override
public boolean isIgnoring(Player sender, Player receiver) {
return false;
}
// This event is not async sometimes
@EventHandler (ignoreCancelled = true)
public void onChat(AsyncPlayerChatEvent event) {
@@ -30,9 +30,11 @@ import net.momirealms.customnameplates.api.util.LogUtils;
import net.momirealms.customnameplates.paper.util.ReflectionUtils;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.checkerframework.checker.nullness.qual.Nullable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.UUID;
public class CarbonChatProvider extends AbstractChatProvider {
@@ -95,10 +97,8 @@ public class CarbonChatProvider extends AbstractChatProvider {
return false;
}
ChatChannel selectedChannel = cPlayer.selectedChannel();
if (selectedChannel == null) {
return false;
}
Object key = getChannelKey(selectedChannel);
ChatChannel currentChannel = selectedChannel != null ? selectedChannel : api.channelRegistry().defaultChannel();
Object key = getChannelKey(currentChannel);
String str = ReflectionUtils.getKeyAsString(key);
return str.equals(channelID);
}
@@ -127,6 +127,28 @@ public class CarbonChatProvider extends AbstractChatProvider {
return player.hasPermission(perm);
}
@Override
public boolean isIgnoring(Player sender, Player receiver) {
CarbonPlayer sPlayer = carbonPlayer(sender.getUniqueId());
CarbonPlayer rPlayer = carbonPlayer(receiver.getUniqueId());
if (sPlayer == null || rPlayer == null) {
return false;
}
return rPlayer.ignoring(sPlayer.uuid());
}
@Nullable
private CarbonPlayer carbonPlayer(UUID uuid) {
CarbonPlayer carbonPlayer = null;
for (CarbonPlayer cPlayer : api.server().players()) {
if (cPlayer.uuid().equals(uuid)) {
carbonPlayer = cPlayer;
break;
}
}
return carbonPlayer;
}
private Object getChannelKey(ChatChannel channel) {
try {
return this.channelKeyMethod.invoke(channel);
@@ -69,6 +69,11 @@ public class HuskChatProvider extends AbstractChatProvider {
return player.hasPermission(receivePerm);
}
@Override
public boolean isIgnoring(Player sender, Player receiver) {
return false;
}
@EventHandler (ignoreCancelled = true)
public void onHuskChat(ChatMessageEvent event) {
String channel = event.getChannelId();
@@ -63,6 +63,11 @@ public class PaperAsyncChatProvider extends AbstractChatProvider {
return true;
}
@Override
public boolean isIgnoring(Player sender, Player receiver) {
return false;
}
@EventHandler (ignoreCancelled = true)
public void onChat(AsyncChatEvent event) {
Object component = getComponentFromEvent(event);
@@ -71,6 +71,11 @@ public class TrChatProvider extends AbstractChatProvider {
}
}
@Override
public boolean isIgnoring(Player sender, Player receiver) {
return false;
}
@EventHandler (ignoreCancelled = true)
public void onTrChat(TrChatEvent event) {
if (!event.getForward()) return;
@@ -65,6 +65,11 @@ public class VentureChatProvider extends AbstractChatProvider {
return true;
}
@Override
public boolean isIgnoring(Player sender, Player receiver) {
return false;
}
@EventHandler (ignoreCancelled = true)
public void onVentureChat(VentureChatEvent event) {
String channelName = event.getChannel().getName();
@@ -22,7 +22,6 @@ import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.PacketContainer;
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
import net.momirealms.customnameplates.api.util.LogUtils;
import org.bukkit.entity.Player;
import java.util.ArrayList;
@@ -47,7 +46,7 @@ public class PacketManager {
public void send(Player player, PacketContainer packet) {
if (!player.isOnline()) {
LogUtils.warn(player.getName() + " not online");
return;
}
this.plugin.debug("Packet sent: " + packet.getType() + " to " + player.getName());
this.protocolManager.sendServerPacket(player, packet);
@@ -22,6 +22,7 @@ import net.momirealms.customnameplates.api.manager.VersionManager;
import net.momirealms.customnameplates.api.util.LogUtils;
import net.momirealms.customnameplates.paper.CustomNameplatesPluginImpl;
import net.momirealms.customnameplates.paper.adventure.AdventureManagerImpl;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@@ -40,14 +41,11 @@ import java.util.concurrent.CompletableFuture;
*/
public class VersionManagerImpl implements VersionManager, Listener {
private final boolean isNewerThan1_19;
private final boolean isNewerThan1_19_R2;
private final boolean isNewerThan1_19_R3;
private final boolean isNewerThan1_20;
private final boolean isNewerThan1_20_R2;
private final String serverVersion;
private final float mcVersion;
private final CustomNameplatesPluginImpl plugin;
private boolean isFolia;
private boolean isMojmap;
private final String pluginVersion;
private boolean isLatest = true;
@@ -55,47 +53,52 @@ public class VersionManagerImpl implements VersionManager, Listener {
public VersionManagerImpl(CustomNameplatesPluginImpl plugin) {
this.plugin = plugin;
// Get the server version
serverVersion = plugin.getServer().getClass().getPackage().getName().split("\\.")[3];
String[] split = serverVersion.split("_");
int main_ver = Integer.parseInt(split[1]);
// Determine if the server version is newer than 1_19_R2 and 1_20_R1
if (main_ver >= 20) {
isNewerThan1_20_R2 = Integer.parseInt(split[2].substring(1)) >= 2;
isNewerThan1_19_R2 = isNewerThan1_19_R3 = true;
isNewerThan1_20 = true;
isNewerThan1_19 = true;
} else if (main_ver == 19) {
isNewerThan1_19_R2 = Integer.parseInt(split[2].substring(1)) >= 2;
isNewerThan1_19_R3 = Integer.parseInt(split[2].substring(1)) >= 3;
isNewerThan1_20 = isNewerThan1_20_R2 = false;
isNewerThan1_19 = true;
} else {
isNewerThan1_19 = isNewerThan1_19_R2= isNewerThan1_19_R3 = false;
isNewerThan1_20 = isNewerThan1_20_R2 = false;
}
// Check if the server is Folia
try {
Class.forName("io.papermc.paper.threadedregions.scheduler.AsyncScheduler");
this.isFolia = true;
} catch (ClassNotFoundException ignored) {
}
String[] split = Bukkit.getServer().getBukkitVersion().split("-")[0].split("\\.");
this.mcVersion = Float.parseFloat(split[1] + "." + (split.length >= 3 ? split[2] : "0"));
// Get the plugin version
this.pluginVersion = plugin.getDescription().getVersion();
// Check if the server is Folia
try {
Class.forName("io.papermc.paper.threadedregions.RegionizedServer");
this.isFolia = true;
} catch (ClassNotFoundException ignored) {
this.isFolia = false;
}
// Check if the server is Mojmap
try {
Class.forName("net.minecraft.network.protocol.game.ClientboundBossEventPacket");
this.isMojmap = true;
} catch (ClassNotFoundException ignored) {
}
}
@Override
public boolean isMojmap() {
return isMojmap;
}
@Override
public boolean isVersionNewerThan1_19_R2() {
return isNewerThan1_19_R2;
return mcVersion >= 19.3;
}
@Override
public boolean isVersionNewerThan1_20() {
return isNewerThan1_20;
return mcVersion >= 20;
}
@Override
public boolean isVersionNewerThan1_20_R2() {
return isNewerThan1_20_R2;
return mcVersion >= 20.2;
}
@Override
public boolean isVersionNewerThan1_20_5() {
return mcVersion >= 20.5;
}
@NotNull
@@ -111,36 +114,42 @@ public class VersionManagerImpl implements VersionManager, Listener {
@Override
public boolean isVersionNewerThan1_19() {
return isNewerThan1_19;
return mcVersion >= 19;
}
@Override
public boolean isVersionNewerThan1_19_R3() {
return isNewerThan1_19_R3;
return mcVersion >= 19.4;
}
@Override
public int getPackFormat() {
switch (serverVersion) {
case "v1_20_R3" -> {
switch (Bukkit.getServer().getBukkitVersion().split("-")[0]) {
case "1.21" -> {
return 34;
}
case "1.20.5", "1.20.6" -> {
return 32;
}
case "1.20.3", "1.20.4" -> {
return 22;
}
case "v1_20_R2" -> {
case "1.20.2" -> {
return 18;
}
case "v1_20_R1" -> {
case "1.20", "1.20.1" -> {
return 15;
}
case "v1_19_R3" -> {
case "1.19.4" -> {
return 13;
}
case "v1_19_R2" -> {
case "1.19.3" -> {
return 12;
}
case "v1_19_R1" -> {
case "1.19", "1.19.1", "1.19.2" -> {
return 9;
}
case "v1_18_R1", "v1_18_R2" -> {
case "1.18", "1.18.1", "1.18.2" -> {
return 8;
}
default -> {
@@ -154,11 +163,6 @@ public class VersionManagerImpl implements VersionManager, Listener {
return isFolia;
}
@Override
public String getServerVersion() {
return serverVersion;
}
// Method to asynchronously check for plugin updates
public CompletableFuture<Boolean> checkUpdate() {
CompletableFuture<Boolean> updateFuture = new CompletableFuture<>();
@@ -327,6 +327,7 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
this.removeEntityIDFromMap(player.getEntityId());
this.teamTagManager.handlePlayerQuit(player);
this.unlimitedTagManager.handlePlayerQuit(player);
this.removeNameplatePlayerFromMap(player.getUniqueId());
// nameplate module part
if (CNConfig.nameplateModule) {
@@ -213,7 +213,7 @@ public class UnlimitedTagManagerImpl implements UnlimitedTagManager {
}
public void handlePlayerQuit(Player quit) {
UnlimitedEntity unlimitedEntity = getUnlimitedObject(quit.getUniqueId());
UnlimitedEntity unlimitedEntity = removeUnlimitedEntityFromMap(quit.getUniqueId());
if (unlimitedEntity != null) {
unlimitedEntity.destroy();
}
@@ -90,8 +90,21 @@ public class ResourcePackManagerImpl implements ResourcePackManager {
// save unicodes
this.saveLegacyUnicodes();
// generate shaders
this.generateShaders();
if (!plugin.getVersionManager().isVersionNewerThan1_20_5()) {
this.generateShaders("ResourcePack" + File.separator + "assets" + File.separator + "minecraft" + File.separator + "shaders" + File.separator + "core" + File.separator, false);
this.generateShaders("ResourcePack" + File.separator + "overlay_1_20_5" + File.separator + "assets" + File.separator + "minecraft" + File.separator + "shaders" + File.separator + "core" + File.separator, true);
} else {
this.generateShaders("ResourcePack" + File.separator + "overlay_1_20_5" + File.separator + "assets" + File.separator + "minecraft" + File.separator + "shaders" + File.separator + "core" + File.separator, true);
try {
FileUtils.copyDirectory(
new File(plugin.getDataFolder(), "ResourcePack" + File.separator + "overlay_1_20_5"),
new File(plugin.getDataFolder(), "ResourcePack")
);
FileUtils.deleteDirectory(new File(plugin.getDataFolder(), "ResourcePack" + File.separator + "overlay_1_20_5"));
} catch (IOException e) {
e.printStackTrace();
}
}
// add offset characters
this.getOffsets(texturesFolder).forEach(providers::add);
// add nameplate characters
@@ -110,9 +123,8 @@ public class ResourcePackManagerImpl implements ResourcePackManager {
this.copyResourcePackToHookedPlugins(resourcePackFolder);
}
private void generateShaders() {
private void generateShaders(String path, boolean v1_20_5) {
if (!CNConfig.enableShader) return;
String path = "ResourcePack" + File.separator + "assets" + File.separator + "minecraft" + File.separator + "shaders" + File.separator + "core" + File.separator;
plugin.saveResource(path + "rendertype_text.fsh", true);
plugin.saveResource(path + "rendertype_text.json", true);
plugin.saveResource(path + "rendertype_text.vsh", true);
@@ -126,11 +138,13 @@ public class ResourcePackManagerImpl implements ResourcePackManager {
} catch (IOException e) {
e.printStackTrace();
}
String mainShader = v1_20_5 ? ShaderConstants.Nameplates_Shader_1_20_5 : ShaderConstants.Nameplates_Shader_1_20_4;
try (BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream(shader1), StandardCharsets.UTF_8))) {
writer.write(sb1.toString()
.replace("%SHADER_0%", !CNConfig.animatedImage ? "" : ShaderConstants.Animated_Text_Out)
.replace("%SHADER_1%", !CNConfig.textEffects ? ShaderConstants.Nameplates_Shader : ShaderConstants.ItemsAdder_Text_Effects + ShaderConstants.Nameplates_Shader)
.replace("%SHADER_1%", !CNConfig.textEffects ? mainShader : ShaderConstants.ItemsAdder_Text_Effects + mainShader)
.replace("%SHADER_2%", !CNConfig.animatedImage ? "" : ShaderConstants.Animated_Text_VSH)
.replace("%SHADER_3%", !CNConfig.hideScoreboardNumber ? "" : ShaderConstants.Hide_ScoreBoard_Numbers)
);
@@ -495,29 +509,57 @@ public class ResourcePackManagerImpl implements ResourcePackManager {
}
private void setPackFormat() {
plugin.saveResource("ResourcePack" + File.separator + "pack.mcmeta", false);
File format_file = new File(plugin.getDataFolder(), "ResourcePack" + File.separator + "pack.mcmeta");
String line;
StringBuilder sb = new StringBuilder();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(format_file), StandardCharsets.UTF_8))) {
while ((line = reader.readLine()) != null) {
sb.append(line).append(System.lineSeparator());
}
} catch (IOException e) {
e.printStackTrace();
}
try (BufferedWriter writer = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream(new File(plugin.getDataFolder(),
"ResourcePack" + File.separator + "pack.mcmeta")), StandardCharsets.UTF_8))) {
writer.write(sb.toString().replace("%version%", String.valueOf(plugin.getVersionManager().getPackFormat())));
} catch (IOException e) {
e.printStackTrace();
if (plugin.getVersionManager().isVersionNewerThan1_20_5()) {
plugin.saveResource("ResourcePack" + File.separator + "pack_1_20_5.mcmeta", false);
File file = new File(plugin.getDataFolder(), "ResourcePack" + File.separator + "pack_1_20_5.mcmeta");
file.renameTo(new File(plugin.getDataFolder(), "ResourcePack" + File.separator + "pack.mcmeta"));
} else {
plugin.saveResource("ResourcePack" + File.separator + "pack.mcmeta", false);
}
// File format_file = new File(plugin.getDataFolder(), "ResourcePack" + File.separator + "pack.mcmeta");
// String line;
// StringBuilder sb = new StringBuilder();
// try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(format_file), StandardCharsets.UTF_8))) {
// while ((line = reader.readLine()) != null) {
// sb.append(line).append(System.lineSeparator());
// }
// } catch (IOException e) {
// e.printStackTrace();
// }
// try (BufferedWriter writer = new BufferedWriter(
// new OutputStreamWriter(new FileOutputStream(new File(plugin.getDataFolder(),
// "ResourcePack" + File.separator + "pack.mcmeta")), StandardCharsets.UTF_8))) {
// writer.write(sb.toString().replace("%version%", String.valueOf(plugin.getVersionManager().getPackFormat())));
// } catch (IOException e) {
// e.printStackTrace();
// }
}
public static class ShaderConstants {
public static final String Nameplates_Shader =
public static final String Nameplates_Shader_1_20_5 =
"if (Color.xyz == vec3(255., 254., 253.) / 255.) {\n" +
" vertexColor = Color*texelFetch(Sampler2, UV2 / 16, 0);\n" +
" vertex.y += 1;\n" +
" vertex.x += 1;\n" +
" gl_Position = ProjMat * ModelViewMat * vertex;\n" +
" } else if (Color.xyz == vec3(254., 254., 254.) / 255.) {\n" +
" vertexColor = Color*texelFetch(Sampler2, UV2 / 16, 0);\n" +
" vertex.z *= 1.001;\n" +
" vertex.x *= 1.001;\n" +
" gl_Position = ProjMat * ModelViewMat * vertex;\n" +
" } else if (Color.xyz == vec3(253., 254., 254.) / 255.) {\n" +
" vertexColor = Color*texelFetch(Sampler2, UV2 / 16, 0);\n" +
" vertex.z *= 1.001001;\n" +
" vertex.x *= 1.001001;\n" +
" gl_Position = ProjMat * ModelViewMat * vertex;\n" +
" } else {\n" +
" vertexColor = Color*texelFetch(Sampler2, UV2 / 16, 0);\n" +
" gl_Position = ProjMat * ModelViewMat * vertex;\n" +
" }";
public static final String Nameplates_Shader_1_20_4 =
"if (Color.xyz == vec3(255., 254., 253.) / 255.) {\n" +
" vertexColor = Color*texelFetch(Sampler2, UV2 / 16, 0);\n" +
" vertex.y += 1;\n" +
@@ -17,6 +17,7 @@
package net.momirealms.customnameplates.paper.mechanic.placeholder;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
import net.momirealms.customnameplates.api.manager.PlaceholderManager;
@@ -124,6 +125,11 @@ public class PluginPlaceholders extends PlaceholderExpansion {
if (switchText == null) return "Switch text not exists: " + mainArg;
return switchText.getValue(offlinePlayer);
}
// fix MagicAvatar's ugly colors
case "magicavatar" -> {
String parsed = PlaceholderAPI.setPlaceholders(offlinePlayer, "%magicavatar_player%");
return parsed.replace("§r", "");
}
}
Player onlinePlayer = offlinePlayer.getPlayer();
@@ -18,7 +18,6 @@
package net.momirealms.customnameplates.paper.mechanic.requirement;
import me.clip.placeholderapi.PlaceholderAPI;
import net.momirealms.biomeapi.BiomeAPI;
import net.momirealms.customnameplates.api.manager.RequirementManager;
import net.momirealms.customnameplates.api.requirement.Requirement;
import net.momirealms.customnameplates.api.requirement.RequirementExpansion;
@@ -32,6 +31,7 @@ import net.momirealms.customnameplates.paper.util.ClassUtils;
import net.momirealms.customnameplates.paper.util.ConfigUtils;
import net.momirealms.customnameplates.paper.util.DisguiseUtils;
import net.momirealms.customnameplates.paper.util.GeyserUtils;
import net.momirealms.sparrow.heart.SparrowHeart;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
@@ -327,14 +327,14 @@ public class RequirementManagerImpl implements RequirementManager {
registerRequirement("biome", (args) -> {
HashSet<String> biomes = new HashSet<>(ConfigUtils.stringListArgs(args));
return condition -> {
String currentBiome = BiomeAPI.getBiomeAt(Objects.requireNonNull(condition.getOfflinePlayer().getPlayer()).getLocation());
String currentBiome = SparrowHeart.getInstance().getBiomeResourceLocation(Objects.requireNonNull(condition.getOfflinePlayer().getPlayer()).getLocation());
return biomes.contains(currentBiome);
};
});
registerRequirement("!biome", (args) -> {
HashSet<String> biomes = new HashSet<>(ConfigUtils.stringListArgs(args));
return condition -> {
String currentBiome = BiomeAPI.getBiomeAt(Objects.requireNonNull(condition.getOfflinePlayer().getPlayer()).getLocation());
String currentBiome = SparrowHeart.getInstance().getBiomeResourceLocation(Objects.requireNonNull(condition.getOfflinePlayer().getPlayer()).getLocation());
return !biomes.contains(currentBiome);
};
});
@@ -378,9 +378,8 @@ public class RequirementManagerImpl implements RequirementManager {
return condition -> {
String currentWeather;
World world = Objects.requireNonNull(condition.getOfflinePlayer().getPlayer()).getWorld();
if (world.hasStorm()) currentWeather = "rainstorm";
if (world.isClearWeather()) currentWeather = "clear";
else if (world.isThundering()) currentWeather = "thunder";
else if (world.isClearWeather()) currentWeather = "clear";
else currentWeather = "rain";
for (String weather : weathers)
if (weather.equalsIgnoreCase(currentWeather))
@@ -19,7 +19,6 @@ package net.momirealms.customnameplates.paper.mechanic.team;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
@@ -27,13 +26,14 @@ import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
import net.momirealms.customnameplates.api.manager.TeamManager;
import net.momirealms.customnameplates.api.util.LogUtils;
import net.momirealms.customnameplates.common.message.MessageType;
import net.momirealms.customnameplates.common.team.TeamCollisionRule;
import net.momirealms.customnameplates.common.team.TeamColor;
import net.momirealms.customnameplates.common.team.TeamTagVisibility;
import net.momirealms.customnameplates.paper.mechanic.misc.PacketManager;
import net.momirealms.customnameplates.paper.mechanic.team.packet.*;
import net.momirealms.customnameplates.paper.adventure.AdventureManagerImpl;
import net.momirealms.customnameplates.paper.mechanic.team.provider.*;
import net.momirealms.customnameplates.paper.setting.CNConfig;
import net.momirealms.sparrow.heart.SparrowHeart;
import net.momirealms.sparrow.heart.feature.team.TeamCollisionRule;
import net.momirealms.sparrow.heart.feature.team.TeamColor;
import net.momirealms.sparrow.heart.feature.team.TeamVisibility;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
@@ -50,13 +50,11 @@ import java.util.Optional;
public class TeamManagerImpl implements TeamManager, PluginMessageListener {
private final CustomNameplatesPlugin plugin;
private final TeamPacketAdaptor teamPacketAdaptor;
private TeamProvider teamProvider;
private static final String CHANNEL = "customnameplates:cnp";
public TeamManagerImpl(CustomNameplatesPlugin plugin) {
this.plugin = plugin;
this.teamPacketAdaptor = new TeamPacket_1_17();
}
/**
@@ -78,35 +76,33 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
}
playerTeam.addPlayer(player);
} else {
PacketContainer createOwner = teamPacketAdaptor.getTeamCreatePacket(
TeamCreate.builder()
.teamName(team)
.color(TeamColor.WHITE)
.display("")
.prefix("")
.suffix("")
.members(Collections.singletonList(player.getName()))
.collisionRule(TeamCollisionRule.ALWAYS)
.tagVisibility(TeamTagVisibility.ALWAYS)
.build()
);
for (Player online : Bukkit.getOnlinePlayers()) {
PacketManager.getInstance().send(online, createOwner);
SparrowHeart.getInstance().addClientSideTeam(online, team,
Collections.singletonList(player.getName()),
"{\"text\":\"\"}",
"{\"text\":\"\"}",
"{\"text\":\"\"}",
TeamVisibility.ALWAYS,
TeamVisibility.ALWAYS,
TeamCollisionRule.ALWAYS,
TeamColor.WHITE,
false,
false
);
if (online == player) continue;
String onlineTeam = teamProvider.getTeam(online, null);
PacketContainer createOther = teamPacketAdaptor.getTeamCreatePacket(
TeamCreate.builder()
.teamName(onlineTeam)
.color(TeamColor.WHITE)
.display("")
.prefix("")
.suffix("")
.members(Collections.singletonList(online.getName()))
.collisionRule(TeamCollisionRule.ALWAYS)
.tagVisibility(TeamTagVisibility.ALWAYS)
.build()
SparrowHeart.getInstance().addClientSideTeam(player, onlineTeam,
Collections.singletonList(online.getName()),
"{\"text\":\"\"}",
"{\"text\":\"\"}",
"{\"text\":\"\"}",
TeamVisibility.ALWAYS,
TeamVisibility.ALWAYS,
TeamCollisionRule.ALWAYS,
TeamColor.WHITE,
false,
false
);
PacketManager.getInstance().send(player, createOther);
}
}
}
@@ -127,28 +123,23 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
Optional.ofNullable(scoreboard.getTeam(team)).ifPresent(Team::unregister);
} else {
PacketContainer packet = teamPacketAdaptor.getTeamRemovePacket(
TeamRemove.builder()
.teamName(team)
.build()
);
for (Player online : Bukkit.getOnlinePlayers()) {
if (player == online) continue;
PacketManager.getInstance().send(online, packet);
SparrowHeart.getInstance().removeClientSideTeam(online, team);
}
}
}
@Override
public void updateTeam(Player owner, Player viewer, String prefix, String suffix, TeamColor color, TeamTagVisibility visibility) {
public void updateTeam(Player owner, Player viewer, String prefix, String suffix, net.momirealms.customnameplates.common.team.TeamColor color, TeamTagVisibility visibility) {
if (CNConfig.disableTeamManage) return;
String team = teamProvider.getTeam(owner, viewer);
if (team == null) {
LogUtils.warn("Failed to get player " + owner.getName() + "'s team for viewer " + viewer.getName());
return;
}
if (color == TeamColor.NONE || color == TeamColor.CUSTOM)
color = TeamColor.WHITE;
if (color == net.momirealms.customnameplates.common.team.TeamColor.NONE || color == net.momirealms.customnameplates.common.team.TeamColor.CUSTOM)
color = net.momirealms.customnameplates.common.team.TeamColor.WHITE;
if (plugin.getNameplateManager().isProxyMode()) {
this.sendPluginMessage(
MessageType.UPDATE,
@@ -160,18 +151,18 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
visibility.name()
);
} else {
PacketContainer packet = teamPacketAdaptor.getTeamUpdatePacket(
TeamUpdate.builder()
.teamName(team)
.color(color)
.display("")
.prefix(prefix)
.suffix(suffix)
.tagVisibility(visibility)
.collisionRule(TeamCollisionRule.ALWAYS)
.build()
SparrowHeart.getInstance().updateClientSideTeam(
viewer, team,
"{\"text\":\"\"}",
AdventureManagerImpl.getInstance().getJsonComponentFromMiniMessage(prefix),
AdventureManagerImpl.getInstance().getJsonComponentFromMiniMessage(suffix),
TeamVisibility.valueOf(visibility.name()),
TeamVisibility.ALWAYS,
TeamCollisionRule.ALWAYS,
TeamColor.valueOf(color.name()),
false,
false
);
PacketManager.getInstance().send(viewer, packet);
}
}
@@ -1,166 +0,0 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customnameplates.paper.mechanic.team.packet;
import net.kyori.adventure.text.Component;
import net.momirealms.customnameplates.common.team.TeamCollisionRule;
import net.momirealms.customnameplates.common.team.TeamColor;
import net.momirealms.customnameplates.common.team.TeamTagVisibility;
import net.momirealms.customnameplates.paper.adventure.AdventureManagerImpl;
import java.util.Collection;
public class TeamCreate {
// String i
private String teamName;
// Collection<String> j
private Collection<String> members;
/*
Optional<b> k
*/
// IChatBaseComponent a
private Object teamDisplay;
// IChatBaseComponent b
private Object teamPrefix;
// IChatBaseComponent c
private Object teamSuffix;
// String d
private TeamTagVisibility tagVisibility;
// String e
private TeamCollisionRule collisionRule;
// Enum f
private TeamColor teamColor;
private TeamCreate() {
}
public TeamCreate(
String teamName,
Collection<String> members,
Component teamDisplay,
Component teamPrefix,
Component teamSuffix,
TeamTagVisibility tagVisibility,
TeamCollisionRule collisionRule,
TeamColor teamColor
) {
this.teamName = teamName;
this.members = members;
this.teamDisplay = teamDisplay;
this.teamPrefix = teamPrefix;
this.teamSuffix = teamSuffix;
this.tagVisibility = tagVisibility;
this.collisionRule = collisionRule;
this.teamColor = teamColor;
}
public String getTeamName() {
return teamName;
}
public Collection<String> getMembers() {
return members;
}
public Object getTeamDisplay() {
return teamDisplay;
}
public Object getTeamPrefix() {
return teamPrefix;
}
public Object getTeamSuffix() {
return teamSuffix;
}
public TeamTagVisibility getTagVisibility() {
return tagVisibility;
}
public TeamCollisionRule getCollisionRule() {
return collisionRule;
}
public TeamColor getTeamColor() {
return teamColor;
}
public static Builder builder() {
return new Builder();
}
public static class Builder {
private final TeamCreate packet;
public Builder() {
this.packet = new TeamCreate();
}
public static Builder of() {
return new Builder();
}
public Builder teamName(String name) {
packet.teamName = name;
return this;
}
public Builder members(Collection<String> members) {
packet.members = members;
return this;
}
public Builder display(String display) {
packet.teamDisplay = AdventureManagerImpl.getInstance().getIChatComponentFromMiniMessage(display);
return this;
}
public Builder prefix(String prefix) {
packet.teamPrefix = AdventureManagerImpl.getInstance().getIChatComponentFromMiniMessage(prefix);
return this;
}
public Builder suffix(String suffix) {
packet.teamSuffix = AdventureManagerImpl.getInstance().getIChatComponentFromMiniMessage(suffix);
return this;
}
public Builder color(TeamColor color) {
packet.teamColor = color;
return this;
}
public Builder tagVisibility(TeamTagVisibility visibility) {
packet.tagVisibility = visibility;
return this;
}
public Builder collisionRule(TeamCollisionRule rule) {
packet.collisionRule = rule;
return this;
}
public TeamCreate build() {
return packet;
}
}
}
@@ -1,29 +0,0 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customnameplates.paper.mechanic.team.packet;
import com.comphenix.protocol.events.PacketContainer;
public interface TeamPacketAdaptor {
PacketContainer getTeamCreatePacket(TeamCreate teamCreate);
PacketContainer getTeamUpdatePacket(TeamUpdate teamUpdate);
PacketContainer getTeamRemovePacket(TeamRemove teamRemove);
}
@@ -1,81 +0,0 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customnameplates.paper.mechanic.team.packet;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.InternalStructure;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.utility.MinecraftReflection;
import net.momirealms.customnameplates.common.team.TeamColor;
import java.util.Optional;
@SuppressWarnings("DuplicatedCode")
public class TeamPacket_1_17 implements TeamPacketAdaptor {
@Override
public PacketContainer getTeamCreatePacket(TeamCreate teamCreate) {
PacketContainer packet = new PacketContainer(PacketType.Play.Server.SCOREBOARD_TEAM);
// 0 = create team
packet.getModifier().write(0,0);
packet.getModifier().write(1, teamCreate.getTeamName());
packet.getModifier().write(2, teamCreate.getMembers());
Optional<InternalStructure> optionalInternalStructure = packet.getOptionalStructures().read(0);
if (optionalInternalStructure.isPresent()) {
InternalStructure is = optionalInternalStructure.get();
// Team
is.getModifier().write(0, teamCreate.getTeamDisplay());
is.getModifier().write(1, teamCreate.getTeamPrefix());
is.getModifier().write(2, teamCreate.getTeamSuffix());
is.getModifier().write(3, teamCreate.getTagVisibility().getId());
is.getModifier().write(4, teamCreate.getCollisionRule().getId());
is.getEnumModifier(TeamColor.class, MinecraftReflection.getMinecraftClass("EnumChatFormat")).write(0, teamCreate.getTeamColor());
is.getModifier().write(6, teamCreate.getMembers().size());
}
return packet;
}
@Override
public PacketContainer getTeamRemovePacket(TeamRemove teamRemove) {
PacketContainer packet = new PacketContainer(PacketType.Play.Server.SCOREBOARD_TEAM);
// 1 = remove team
packet.getModifier().write(0,1);
packet.getStrings().write(0, teamRemove.getTeamName());
return packet;
}
@Override
public PacketContainer getTeamUpdatePacket(TeamUpdate teamUpdate) {
PacketContainer packet = new PacketContainer(PacketType.Play.Server.SCOREBOARD_TEAM);
// 2 = update team
packet.getModifier().write(0,2);
packet.getModifier().write(1, teamUpdate.getTeamName());
Optional<InternalStructure> optionalInternalStructure = packet.getOptionalStructures().read(0);
if (optionalInternalStructure.isPresent()) {
InternalStructure is = optionalInternalStructure.get();
// Team
is.getModifier().write(0, teamUpdate.getTeamDisplay());
is.getModifier().write(1, teamUpdate.getTeamPrefix());
is.getModifier().write(2, teamUpdate.getTeamSuffix());
is.getModifier().write(3, teamUpdate.getTagVisibility().getId());
is.getModifier().write(4, teamUpdate.getCollisionRule().getId());
is.getEnumModifier(TeamColor.class, MinecraftReflection.getMinecraftClass("EnumChatFormat")).write(0, teamUpdate.getTeamColor());
}
return packet;
}
}
@@ -1,56 +0,0 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customnameplates.paper.mechanic.team.packet;
public class TeamRemove {
private String teamName;
private TeamRemove() {
}
public TeamRemove(String teamName) {
this.teamName = teamName;
}
public String getTeamName() {
return teamName;
}
public static Builder builder() {
return new Builder();
}
public static class Builder {
private final TeamRemove packet;
public Builder() {
this.packet = new TeamRemove();
}
public Builder teamName(String teamName) {
packet.teamName = teamName;
return this;
}
public TeamRemove build() {
return packet;
}
}
}
@@ -1,149 +0,0 @@
/*
* Copyright (C) <2022> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customnameplates.paper.mechanic.team.packet;
import net.momirealms.customnameplates.common.team.TeamCollisionRule;
import net.momirealms.customnameplates.common.team.TeamColor;
import net.momirealms.customnameplates.common.team.TeamTagVisibility;
import net.momirealms.customnameplates.paper.adventure.AdventureManagerImpl;
public class TeamUpdate {
private String teamName;
/*
Optional<b> k
*/
// IChatBaseComponent a
private Object teamDisplay;
// IChatBaseComponent b
private Object teamPrefix;
// IChatBaseComponent c
private Object teamSuffix;
// String d
private TeamTagVisibility tagVisibility;
// String e
private TeamCollisionRule collisionRule;
// Enum f
private TeamColor teamColor;
private TeamUpdate() {
}
public TeamUpdate(
String teamName,
Object teamDisplay,
Object teamPrefix,
Object teamSuffix,
TeamTagVisibility tagVisibility,
TeamCollisionRule collisionRule,
TeamColor teamColor
) {
this.teamName = teamName;
this.teamDisplay = teamDisplay;
this.teamPrefix = teamPrefix;
this.teamSuffix = teamSuffix;
this.tagVisibility = tagVisibility;
this.collisionRule = collisionRule;
this.teamColor = teamColor;
}
public String getTeamName() {
return teamName;
}
public Object getTeamDisplay() {
return teamDisplay;
}
public Object getTeamPrefix() {
return teamPrefix;
}
public Object getTeamSuffix() {
return teamSuffix;
}
public TeamTagVisibility getTagVisibility() {
return tagVisibility;
}
public TeamCollisionRule getCollisionRule() {
return collisionRule;
}
public TeamColor getTeamColor() {
return teamColor;
}
public static Builder builder() {
return new Builder();
}
public static class Builder {
private final TeamUpdate packet;
public Builder() {
this.packet = new TeamUpdate();
}
public static Builder of() {
return new Builder();
}
public Builder teamName(String name) {
packet.teamName = name;
return this;
}
public Builder display(String display) {
packet.teamDisplay = AdventureManagerImpl.getInstance().getIChatComponentFromMiniMessage(display);
return this;
}
public Builder prefix(String prefix) {
packet.teamPrefix = AdventureManagerImpl.getInstance().getIChatComponentFromMiniMessage(prefix);
return this;
}
public Builder suffix(String suffix) {
packet.teamSuffix = AdventureManagerImpl.getInstance().getIChatComponentFromMiniMessage(suffix);;
return this;
}
public Builder color(TeamColor color) {
packet.teamColor = color;
return this;
}
public Builder tagVisibility(TeamTagVisibility visibility) {
packet.tagVisibility = visibility;
return this;
}
public Builder collisionRule(TeamCollisionRule rule) {
packet.collisionRule = rule;
return this;
}
public TeamUpdate build() {
return packet;
}
}
}
@@ -39,7 +39,7 @@ import java.util.Objects;
public class CNConfig {
public static String configVersion = "26";
public static String configVersion = "27";
public static int cacheSize;
public static int corePoolSize;
public static long keepAliveTime;
@@ -86,6 +86,7 @@ public class CNConfig {
public static boolean enableShader;
public static boolean huskChatChannel;
public static boolean carbonChatChannel;
public static boolean advancedChatChannel;
public static boolean hasLibsDisguise;
public static void load() {
@@ -136,6 +137,7 @@ public class CNConfig {
ventureChatChannel = integrationSection.getBoolean("chat.VentureChat", false);
huskChatChannel = integrationSection.getBoolean("chat.HuskChat", false);
carbonChatChannel = integrationSection.getBoolean("chat.CarbonChat", false);
advancedChatChannel = integrationSection.getBoolean("chat.AdvancedChat", false);
tabTeam = integrationSection.getBoolean("team.TAB", false);
cmiTeam = integrationSection.getBoolean("team.CMI", false);
velocitab = integrationSection.getBoolean("team.Velocitab", false);
@@ -30,7 +30,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
import java.io.IOException;
import java.util.Objects;
import java.io.InputStream;
public class CNLocale {
@@ -60,23 +60,27 @@ public class CNLocale {
public static String MSG_HAVE_NO_BUBBLE;
public static void load() {
try {
YamlDocument.create(
new File(CustomNameplatesPlugin.getInstance().getDataFolder(), "messages/" + CNConfig.language + ".yml"),
Objects.requireNonNull(CustomNameplatesPlugin.getInstance().getResource("messages/" + CNConfig.language + ".yml")),
GeneralSettings.DEFAULT,
LoaderSettings
.builder()
.setAutoUpdate(true)
.build(),
DumperSettings.DEFAULT,
UpdaterSettings
.builder()
.setVersioning(new BasicVersioning("config-version"))
.build()
);
} catch (IOException e) {
LogUtils.warn(e.getMessage());
InputStream inputStream = CustomNameplatesPlugin.getInstance().getResource("messages/" + CNConfig.language + ".yml");
if (inputStream != null) {
try {
YamlDocument.create(
new File(CustomNameplatesPlugin.getInstance().getDataFolder(), "messages/" + CNConfig.language + ".yml"),
inputStream,
GeneralSettings.DEFAULT,
LoaderSettings
.builder()
.setAutoUpdate(true)
.build(),
DumperSettings.DEFAULT,
UpdaterSettings
.builder()
.setVersioning(new BasicVersioning("config-version"))
.build()
);
inputStream.close();
} catch (IOException e) {
LogUtils.warn(e.getMessage());
}
}
loadSettings(CustomNameplatesPlugin.get().getConfig("messages/" + CNConfig.language + ".yml"));
}
@@ -28,6 +28,7 @@ import net.momirealms.customnameplates.api.event.NameplateDataLoadEvent;
import net.momirealms.customnameplates.api.manager.StorageManager;
import net.momirealms.customnameplates.api.util.LogUtils;
import net.momirealms.customnameplates.paper.CustomNameplatesPluginImpl;
import net.momirealms.customnameplates.paper.storage.method.NoneStorage;
import net.momirealms.customnameplates.paper.storage.method.database.nosql.MongoDBImpl;
import net.momirealms.customnameplates.paper.storage.method.database.nosql.RedisManager;
import net.momirealms.customnameplates.paper.storage.method.database.sql.H2Impl;
@@ -84,8 +85,10 @@ public class StorageManagerImpl implements Listener, StorageManager {
if (player == null || !player.isOnline()) return;
var onlineUser = new OnlineUser(player, playerData);
this.putOnlineUserInMap(onlineUser);
NameplateDataLoadEvent syncEvent = new NameplateDataLoadEvent(uuid, onlineUser);
plugin.getServer().getPluginManager().callEvent(syncEvent);
plugin.getScheduler().runTaskAsync(() -> {
NameplateDataLoadEvent syncEvent = new NameplateDataLoadEvent(uuid, onlineUser);
plugin.getServer().getPluginManager().callEvent(syncEvent);
});
}
});
}
@@ -178,6 +181,7 @@ public class StorageManagerImpl implements Listener, StorageManager {
case MySQL -> this.dataSource = new MySQLImpl(plugin);
case MariaDB -> this.dataSource = new MariaDBImpl(plugin);
case MongoDB -> this.dataSource = new MongoDBImpl(plugin);
case None -> this.dataSource = new NoneStorage(plugin);
}
if (this.dataSource != null) this.dataSource.initialize();
else LogUtils.severe("No storage type is set.");
@@ -0,0 +1,37 @@
package net.momirealms.customnameplates.paper.storage.method;
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
import net.momirealms.customnameplates.api.data.PlayerData;
import net.momirealms.customnameplates.api.data.StorageType;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
public class NoneStorage extends AbstractStorage {
public NoneStorage(CustomNameplatesPlugin plugin) {
super(plugin);
}
@Override
public StorageType getStorageType() {
return StorageType.None;
}
@Override
public CompletableFuture<Optional<PlayerData>> getPlayerData(UUID uuid) {
return CompletableFuture.completedFuture(Optional.of(PlayerData.empty()));
}
@Override
public CompletableFuture<Boolean> updatePlayerData(UUID uuid, PlayerData playerData) {
return CompletableFuture.completedFuture(true);
}
@Override
public Set<UUID> getUniqueUsers(boolean legacy) {
return Set.of();
}
}
@@ -67,9 +67,10 @@ public class MongoDBImpl extends AbstractStorage {
collectionPrefix = section.getString("collection-prefix", "nameplates");
var settings = MongoClientSettings.builder().uuidRepresentation(UuidRepresentation.STANDARD);
if (!section.getString("connection-uri", "").equals("")) {
if (!section.getString("connection-uri", "").isEmpty()) {
settings.applyConnectionString(new ConnectionString(section.getString("connection-uri", "")));
mongoClient = MongoClients.create(settings.build());
this.mongoClient = MongoClients.create(settings.build());
this.database = mongoClient.getDatabase(section.getString("database", "minecraft"));
return;
}
@@ -21,14 +21,20 @@ import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
import net.momirealms.customnameplates.api.data.PlayerData;
import net.momirealms.customnameplates.api.data.StorageType;
import net.momirealms.customnameplates.api.util.LogUtils;
import net.momirealms.customnameplates.paper.CustomNameplatesPluginImpl;
import net.momirealms.customnameplates.paper.libraries.dependencies.Dependency;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.sqlite.SQLiteConfig;
import java.io.File;
import java.io.IOException;
import java.sql.*;
import java.lang.reflect.Constructor;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.EnumSet;
import java.util.Optional;
import java.util.Properties;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
@@ -39,6 +45,7 @@ public class SQLiteImpl extends AbstractSQLDatabase {
private Connection connection;
private File databaseFile;
private Constructor<?> connectionConstructor;
public SQLiteImpl(CustomNameplatesPlugin plugin) {
super(plugin);
@@ -49,6 +56,14 @@ public class SQLiteImpl extends AbstractSQLDatabase {
*/
@Override
public void initialize() {
ClassLoader classLoader = ((CustomNameplatesPluginImpl) plugin).getDependencyManager().obtainClassLoaderWith(EnumSet.of(Dependency.SQLITE_DRIVER, Dependency.SLF4J_SIMPLE, Dependency.SLF4J_API));
try {
Class<?> connectionClass = classLoader.loadClass("org.sqlite.jdbc4.JDBC4Connection");
connectionConstructor = connectionClass.getConstructor(String.class, String.class, Properties.class);
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
YamlConfiguration config = plugin.getConfig("database.yml");
this.databaseFile = new File(plugin.getDataFolder(), config.getString("SQLite.file", "data") + ".db");
super.tablePrefix = config.getString("SQLite.table-prefix", "nameplates");
@@ -143,34 +158,21 @@ public class SQLiteImpl extends AbstractSQLDatabase {
*/
@Override
public Connection getConnection() throws SQLException {
if (connection == null || connection.isClosed()) {
setConnection();
if (connection != null && !connection.isClosed()) {
return connection;
}
return connection;
}
/**
* Set up the connection to the SQLite database.
*/
@SuppressWarnings("ResultOfMethodCallIgnored")
private void setConnection() {
try {
if (!databaseFile.exists()) databaseFile.createNewFile();
Class.forName("org.sqlite.JDBC");
SQLiteConfig config = new SQLiteConfig();
config.enforceForeignKeys(true);
config.setEncoding(SQLiteConfig.Encoding.UTF8);
config.setSynchronous(SQLiteConfig.SynchronousMode.FULL);
connection = DriverManager.getConnection(
String.format("jdbc:sqlite:%s", databaseFile.getAbsolutePath()),
config.toProperties()
);
} catch (IOException e) {
LogUtils.warn("Failed to create the SQLite database.");
} catch (SQLException e) {
LogUtils.warn("Failed to initialize SQLite database.");
} catch (ClassNotFoundException e) {
LogUtils.warn("Failed to find SQLite driver.");
var properties = new Properties();
properties.setProperty("foreign_keys", Boolean.toString(true));
properties.setProperty("encoding", "'UTF-8'");
properties.setProperty("synchronous", "FULL");
connection = (Connection) this.connectionConstructor.newInstance("jdbc:sqlite:" + databaseFile.toString(), databaseFile.toString(), properties);
return connection;
} catch (ReflectiveOperationException e) {
if (e.getCause() instanceof SQLException) {
throw (SQLException) e.getCause();
}
throw new RuntimeException(e);
}
}
}
@@ -19,6 +19,7 @@ package net.momirealms.customnameplates.paper.util;
import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
import com.comphenix.protocol.wrappers.WrappedDataValue;
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
import com.google.common.collect.Lists;
@@ -55,7 +56,7 @@ public class FakeEntityUtils {
WrappedDataWatcher wrappedDataWatcher = new WrappedDataWatcher();
WrappedDataWatcher.Serializer serializer1 = WrappedDataWatcher.Registry.get(Boolean.class);
WrappedDataWatcher.Serializer serializer2 = WrappedDataWatcher.Registry.get(Byte.class);
wrappedDataWatcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(2, WrappedDataWatcher.Registry.getChatComponentSerializer(true)), Optional.of(AdventureManagerImpl.getInstance().getWrappedChatComponentFromMiniMessage(miniMessage).getHandle()));
wrappedDataWatcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(2, WrappedDataWatcher.Registry.getChatComponentSerializer(true)), Optional.of(WrappedChatComponent.fromJson(AdventureManagerImpl.getInstance().getJsonComponentFromMiniMessage(miniMessage)).getHandle()));
wrappedDataWatcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(3, serializer1), true);
byte flag = 0x20;
if (sneak) flag += (byte) 0x02;
@@ -18,6 +18,7 @@
package net.momirealms.customnameplates.paper.util;
import com.comphenix.protocol.utility.MinecraftReflection;
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
import net.momirealms.customnameplates.api.util.LogUtils;
import java.lang.reflect.Constructor;
@@ -42,23 +43,43 @@ public class ReflectionUtils {
private static boolean isPaper;
public static void load() {
try {
Class<?> bar = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss");
Field remove = bar.getDeclaredField("f");
remove.setAccessible(true);
removeBossBarPacket = remove.get(null);
Class<?> packetBossClassF = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss$f");
progressConstructor = packetBossClassF.getDeclaredConstructor(float.class);
progressConstructor.setAccessible(true);
Class<?> packetBossClassE = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss$e");
updateConstructor = packetBossClassE.getDeclaredConstructor(MinecraftReflection.getIChatBaseComponentClass());
updateConstructor.setAccessible(true);
iChatComponentMethod = MinecraftReflection.getChatSerializerClass().getMethod("a", String.class);
iChatComponentMethod.setAccessible(true);
emptyComponent = iChatComponentMethod.invoke(null, "{\"text\":\"\"}");
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException | NoSuchMethodException | InvocationTargetException exception) {
LogUtils.severe("Error occurred when loading reflections", exception);
exception.printStackTrace();
if (CustomNameplatesPlugin.get().getVersionManager().isMojmap()) {
try {
Class<?> bar = Class.forName("net.minecraft.network.protocol.game.ClientboundBossEventPacket");
Field remove = bar.getDeclaredField("REMOVE_OPERATION");
remove.setAccessible(true);
removeBossBarPacket = remove.get(null);
Class<?> packetBossClassF = Class.forName("net.minecraft.network.protocol.game.ClientboundBossEventPacket$UpdateProgressOperation");
progressConstructor = packetBossClassF.getDeclaredConstructor(float.class);
progressConstructor.setAccessible(true);
Class<?> packetBossClassE = Class.forName("net.minecraft.network.protocol.game.ClientboundBossEventPacket$UpdateNameOperation");
updateConstructor = packetBossClassE.getDeclaredConstructor(MinecraftReflection.getIChatBaseComponentClass());
updateConstructor.setAccessible(true);
Class<?> craftChatMessageClass = Class.forName("org.bukkit.craftbukkit.util.CraftChatMessage");
iChatComponentMethod = craftChatMessageClass.getDeclaredMethod("fromJSON", String.class);
iChatComponentMethod.setAccessible(true);
emptyComponent = iChatComponentMethod.invoke(null, "{\"text\":\"\"}");
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException | NoSuchMethodException | InvocationTargetException exception) {
LogUtils.severe("Error occurred while loading reflections", exception);
}
} else {
try {
Class<?> bar = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss");
Field remove = bar.getDeclaredField("f");
remove.setAccessible(true);
removeBossBarPacket = remove.get(null);
Class<?> packetBossClassF = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss$f");
progressConstructor = packetBossClassF.getDeclaredConstructor(float.class);
progressConstructor.setAccessible(true);
Class<?> packetBossClassE = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss$e");
updateConstructor = packetBossClassE.getDeclaredConstructor(MinecraftReflection.getIChatBaseComponentClass());
updateConstructor.setAccessible(true);
iChatComponentMethod = MinecraftReflection.getChatSerializerClass().getMethod("a", String.class);
iChatComponentMethod.setAccessible(true);
emptyComponent = iChatComponentMethod.invoke(null, "{\"text\":\"\"}");
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException | NoSuchMethodException | InvocationTargetException exception) {
LogUtils.severe("Error occurred while loading reflections", exception);
}
}
try {
Class<?> componentClass = Class.forName("net;kyori;adventure;text;Component".replace(";", "."));
@@ -114,7 +135,7 @@ public class ReflectionUtils {
public static Object getKerFromString(String key) {
try {
return keyFromStringMethod.invoke(key);
return keyFromStringMethod.invoke(null, key);
} catch (InvocationTargetException | IllegalAccessException e) {
e.printStackTrace();
}
@@ -0,0 +1,31 @@
#version 150
#moj_import<fog.glsl>
uniform sampler2D Sampler0;
uniform vec4 ColorModulator;
uniform float FogStart,FogEnd;
uniform vec4 FogColor;
uniform float GameTime;
in float vertexDistance;
in vec4 vertexColor;
in vec2 texCoord0;
in float depthLevel;
%SHADER_0%
out vec4 fragColor;
void main() {
vec4 texColor = texture(Sampler0, texCoord0);
vec4 color = texColor * vertexColor * ColorModulator;%SHADER_1%
if (color.a < 0.1) {
discard;
}
if (texColor.a == 254.0/255.0) {
if (depthLevel == 1000.00) {
discard;
} else {
color = vec4(texColor.rgb, 1.0) * vertexColor * ColorModulator;
}
}
fragColor = linear_fog(color, vertexDistance, FogStart, FogEnd, FogColor);
}
@@ -0,0 +1,28 @@
{
"blend": {
"func": "add",
"srcrgb": "srcalpha",
"dstrgb": "1-srcalpha"
},
"vertex": "rendertype_text",
"fragment": "rendertype_text",
"attributes": [
"Position",
"Color",
"UV0",
"UV2"
],
"samplers": [
{ "name": "Sampler0" },
{ "name": "Sampler2" }
],
"uniforms": [
{ "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
{ "name": "ColorModulator", "type": "float", "count": 4, "values": [ 1.0, 1.0, 1.0, 1.0 ] },
{ "name": "FogStart", "type": "float", "count": 1, "values": [ 0.0 ] },
{ "name": "FogEnd", "type": "float", "count": 1, "values": [ 1.0 ] },
{ "name": "GameTime", "type": "float", "count": 1, "values": [ 1.0 ] },
{ "name": "FogColor", "type": "float", "count": 4, "values": [ 0.0, 0.0, 0.0, 0.0 ] }
]
}
@@ -0,0 +1,27 @@
#version 150
#moj_import <fog.glsl>
in vec3 Position;
in vec4 Color;
in vec2 UV0;
in ivec2 UV2;
uniform sampler2D Sampler2;
uniform mat4 ModelViewMat;
uniform mat4 ProjMat;
uniform float GameTime;
uniform int FogShape;
uniform vec2 ScreenSize;
out float vertexDistance;
out vec4 vertexColor;
out vec2 texCoord0;
out float depthLevel;
%SHADER_0%
void main() {
vec4 vertex = vec4(Position, 1.0);
vertexDistance = fog_distance(Position, FogShape);
depthLevel = Position.z;
texCoord0 = UV0;
%SHADER_1%%SHADER_2%%SHADER_3%
}
@@ -1 +1,21 @@
{"pack":{"pack_format":%version%,"description":"CustomNameplates"}}
{
"pack":{
"pack_format": 8,
"description":"CustomNameplates",
"supported_formats": {
"min_inclusive": 8,
"max_inclusive": 34
}
},
"overlays": {
"entries": [
{
"formats": {
"min_inclusive": 32,
"max_inclusive": 34
},
"directory": "overlay_1_20_5"
}
]
}
}
@@ -0,0 +1,10 @@
{
"pack":{
"pack_format": 32,
"description":"CustomNameplates",
"supported_formats": {
"min_inclusive": 32,
"max_inclusive": 34
}
}
}
+4 -3
View File
@@ -1,5 +1,5 @@
# Do not change
config-version: '26'
config-version: '27'
# Debug mode
debug: false
@@ -11,8 +11,8 @@ metrics: true
update-checker: true
# Language
# english/chinese/spanish/russian/turkish/french
lang: english
# https://github.com/Xiao-MoMi/Custom-Nameplates/tree/main/paper/src/main/resources/messages
lang: en
# Modules
modules:
@@ -40,6 +40,7 @@ integrations:
VentureChat: false
HuskChat: false
CarbonChat: false
AdvancedChat: false
resource-pack:
# disable resource pack generation on server start
@@ -33,11 +33,6 @@ conditional-text:
conditions:
weather:
- thunder
priority_4:
text: 'Rainstorm'
conditions:
weather:
- rainstorm
# https://mo-mi.gitbook.io/xiaomomi-plugins/plugin-wiki/customnameplates/custom-placeholders/nameplate-text
nameplate-text:
@@ -4,7 +4,7 @@ messages:
prefix: '<gradient:#2E8B57:#48D1CC>[CustomNameplates] </gradient>'
reload: '<white>Reloaded! </white>'
cooldown: '<white>Previewing is still Ongoing!</white>'
generate: '<white>Resource Pack is generating...</white>'
generate: '<white>Generating resource pack...</white>'
generate-done: '<white>Resource Pack has been generated! Don''t forget to reinstall your resource pack.</white>'
no-nameplate: 'No Nameplate'
preview: '<white>Now previewing your nameplate (go to third person to view)!</white>'
+29
View File
@@ -0,0 +1,29 @@
config-version: "23"
messages:
prefix: '<gradient:#2E8B57:#48D1CC>[CustomNameplates] </gradient>'
reload: '<white>Recargado! </white>'
cooldown: '<white>¡La previsualización sigue en curso!</white>'
generate: '<white>Generando paquete de recursos...</white>'
generate-done: '<white>Se ha generado el paquete de recursos. No olvides reinstalarlo!</white>'
no-nameplate: 'Sin Nameplate'
preview: '<white>¡Ya puedes ver tu Nameplate (cambia a tercera persona <F5> para ver)!</white>'
equip-nameplates: '<white>Se ha equipado la Nameplate {Nameplate}. </white><yellow><click:run_command:/nameplates preview>[click para preview]'
force-equip-nameplates: '<white>Se le ha equipado la Nameplate {Nameplate} a {Player}.</white>'
unequip-nameplates: '<white>Has quitado tu nameplate</white>'
force-unequip-nameplates: '<white>Le has quitado su nameplate a {Player}!</white>'
not-exist-nameplates: '<white>Esta nameplate no existe!</white>'
not-available-nameplates: '<white>Esta nameplate no está disponible!</white>'
available-nameplates: '<white>Nameplates Disponibles: {Nameplate}.</white>'
have-no-nameplates: '<white>Aún no tienes una nameplate'
force-preview: '<white>Forzaste a {Player} a ver su nameplate</white>'
equip-bubbles: '<white>Has activado los globos de diálogo {Bubble}</white>'
force-equip-bubbles: '<white>Has activado los globos de diálogo {Bubble}</white>'
unequip-bubbles: '<white>Se han desactivado los globos de diálogo</white>'
force-unequip-bubbles: '<white>Has desactivado los globos de diálogo de {Player}!</white>'
not-exist-bubbles: '<white>Este globo no existe!</white>'
not-available-bubbles: '<white>Este globo no está disponible!</white>'
available-bubbles: '<white>Globos Disponibles: {Bubble}</white>'
have-no-bubbles: '<white>Aún no tienes un globo de diálogo'
+29
View File
@@ -0,0 +1,29 @@
config-version: "23"
messages:
prefix: '<gradient:#2E8B57:#48D1CC>[CustomNameplates] </gradient>'
reload: '<white>리로드 했습니다! </white>'
cooldown: '<white>미리보기가 아직 켜져있습니다!</white>'
generate: '<white>리소스팩을 생성하는 중입니다...</white>'
generate-done: '<white>리소스팩이 생성되었습니다! 리소스팩을 재설치하는것을 잊지 마세요.</white>'
no-nameplate: '이름표 없음'
preview: '<white>이제 이름표 미리보기가 표시됩니다 (3인칭 보기로 전환하세요)!</white>'
equip-nameplates: '<white>이름표 {Nameplate}을(를) 착용했습니다. </white><yellow><click:run_command:/nameplates preview>[클릭하여 미리보기]'
force-equip-nameplates: '<white>이름표 {Nameplate}을(를) {Player}에게 착용시켰습니다.</white>'
unequip-nameplates: '<white>이름표를 착용 해제했습니다</white>'
force-unequip-nameplates: '<white>{Player}의 이름표를 제거했습니다!</white>'
not-exist-nameplates: '<white>해당 이름표가 존재하지 않습니다!</white>'
not-available-nameplates: '<white>해당 이름표는 현재 이용할 수 없습니다!</white>'
available-nameplates: '<white>이용 가능한 이름표: {Nameplate}.</white>'
have-no-nameplates: '<white>아직 아무 이름표도 가지고 있지 않습니다'
force-preview: '<white>{Player}에게 이름표 미리보기를 표시했습니다</white>'
equip-bubbles: '<white>대화 말풍선 {Bubble}을(를) 착용했습니다</white>'
force-equip-bubbles: '<white>말풍선 {Bubble}을(를) 착용했습니다</white>'
unequip-bubbles: '<white>말풍선을 착용 해제했습니다</white>'
force-unequip-bubbles: '<white>{Player}의 말풍선을 착용 해제했습니다!</white>'
not-exist-bubbles: '<white>해당 말풍선이 존재하지 않습니다!</white>'
not-available-bubbles: '<white>해당 말풍선은 현재 이용할 수 없습니다!</white>'
available-bubbles: '<white>이용 가능한 말풍선: {Bubble}</white>'
have-no-bubbles: '<white>아직 아무 말풍선도 가지고 있지 않습니다'
+29
View File
@@ -0,0 +1,29 @@
config-version: "23"
messages:
prefix: '<gradient:#2E8B57:#48D1CC>[CustomNameplates] </gradient>'
reload: '<white>Pliki konfiguracyjne przeładowane! </white>'
cooldown: '<white>Podgląd nadal trwa!</white>'
generate: '<white>Generowanie resource packa...</white>'
generate-done: '<white>Resource Pack został wygenerowany! Nie zapomnij go zainstalować jeszcze raz.</white>'
no-nameplate: 'Bez nameplate''a'
preview: '<white>Podgląd nameplate''a (zobacz w trybie trzecioosobowym)!</white>'
equip-nameplates: '<white>Pomyślnie założono nameplate''a: {Nameplate}. </white><yellow><click:run_command:/nameplates preview>[Kliknij aby zobaczyć]'
force-equip-nameplates: '<white>Pomyślnie założono nameplat''a {Nameplate} graczowi {Player}.</white>'
unequip-nameplates: '<white>Zdjąłeś nameplate''a</white>'
force-unequip-nameplates: '<white>Pomyślnie usunięto nameplate''a graczowi {Player}</white>'
not-exist-nameplates: '<white>Nie istnieje taki nameplate!</white>'
not-available-nameplates: '<white>Ten nameplate obecnie nie jest dostępny!</white>'
available-nameplates: '<white>Dostępne nameplate''y: {Nameplate}.</white>'
have-no-nameplates: '<white>Na razie nie posiadasz żadnych nameplat''ów'
force-preview: '<white>Zmuszono {Player} do podglądu nameplate''a</white>'
equip-bubbles: '<white>Pomyślnie założono bąbelki {Bubble}</white>'
force-equip-bubbles: '<white>Pomyślnie założono bąbelki dla chatu {Bubble}</white>'
unequip-bubbles: '<white>Usunąłeś bąbelki dla chatu</white>'
force-unequip-bubbles: '<white>Usunąłeś bąbelki gracza {Player}</white>'
not-exist-bubbles: '<white>Nie istnieją takie bąbelki!</white>'
not-available-bubbles: '<white>Te bąbelki na razie nie są dostępne!</white>'
available-bubbles: '<white>Dostępne bąbelki: {Bubble}</white>'
have-no-bubbles: '<white>Nie posiadasz na razie żadnych bąbelków'
@@ -1,29 +0,0 @@
config-version: "23"
messages:
prefix: '<gradient:#2E8B57:#48D1CC>[CustomNameplates] </gradient>'
reload: '<white>Recargado! </white>'
cooldown: '<white>¡El preestreno sigue en curso!</white>'
generate: '<white>El paquete de recursos está generando...</white>'
generate-done: '<white>Se ha generado un paquete de recursos. No olvides reinstalar el paquete de recursos.</white>'
no-nameplate: 'No Nameplate'
preview: '<white>¡Ahora, la vista previa de su placa de identificación (ir a la tercera persona para ver)!</white>'
equip-nameplates: '<white>Placa de identificación equipada con éxito {Nameplate}. </white><yellow><click:run_command:/nameplates preview>[click para preview]'
force-equip-nameplates: '<white>Equipado con éxito nameplate {Nameplate} a {Player}.</white>'
unequip-nameplates: '<white>Has quitado tu nameplate</white>'
force-unequip-nameplates: '<white>Eliminado con éxito {Player}''s nameplate!</white>'
not-exist-nameplates: '<white>Este nameplate no existe!</white>'
not-available-nameplates: '<white>Este nameplate no esta actualmente disponible!</white>'
available-nameplates: '<white>Nameplates Disponibles: {Nameplate}.</white>'
have-no-nameplates: '<white>No tienes ningun nameplate aun'
force-preview: '<white>Forced {Player} to preview the nameplate</white>'
equip-bubbles: '<white>Correctamente equipado chatting bubbles {Bubble}</white>'
force-equip-bubbles: '<white>Correctamente equipdo chatting bubbles {Bubble}</white>'
unequip-bubbles: '<white>Se ha removido tu chatting bubbles</white>'
force-unequip-bubbles: '<white>Se ha removido tu chatting bubbles</white>'
not-exist-bubbles: '<white>Este bubble no existe</white>'
not-available-bubbles: '<white>Este bubble no esta actualmente disponible!</white>'
available-bubbles: '<white>Bubbles Disponibles: {Bubble}</white>'
have-no-bubbles: '<white>Todavía no tienes ningun bubble'
+1 -1
View File
@@ -5,7 +5,7 @@ api-version: 1.17
authors: [ XiaoMoMi ]
folia-supported: true
depend: [ ProtocolLib ,PlaceholderAPI ]
softdepend: [ MagicCosmetics, TAB, CMI, TrChat, ItemsAdder, Oraxen, CarbonChat, HuskChat ]
softdepend: [ MagicCosmetics, TAB, CMI, TrChat, ItemsAdder, Oraxen, CarbonChat, HuskChat, AdvancedChat ]
permissions:
nameplates.command.*:
description: Gives access to all nameplate user commands
+1 -1
View File
@@ -10,7 +10,7 @@ tasks {
shadowJar {
relocate ("net.kyori", "net.momirealms.customnameplates.libraries")
relocate ("org.bstats", "net.momirealms.customnameplates.libraries.bstats")
relocate ("net.momirealms.biomeapi", "net.momirealms.customnameplates.libraries.biomeapi")
relocate ("net.momirealms.sparrow.heart", "net.momirealms.customnameplates.libraries.sparrow")
relocate ("org.apache.commons.pool2", "net.momirealms.customnameplates.libraries.commonspool2")
relocate ("com.mysql", "net.momirealms.customnameplates.libraries.mysql")
relocate ("org.mariadb", "net.momirealms.customnameplates.libraries.mariadb")