9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2025-12-19 15:09:23 +00:00
This commit is contained in:
Xiao-MoMi
2023-04-27 21:39:38 +08:00
parent 5695a63756
commit c21012f09b
30 changed files with 210 additions and 118 deletions

View File

@@ -4,37 +4,39 @@ plugins {
}
group = 'net.momirealms'
version = '2.2.0.4-hotfix'
version = '2.2.0.5'
repositories {
mavenCentral()
maven {name = "aliyun-repo"; url = "https://maven.aliyun.com/repository/public/"}
maven {name = 'papermc-repo'; url = 'https://papermc.io/repo/repository/maven-public/'}
maven {name = 'sonatype'; url = 'https://oss.sonatype.org/content/groups/public/'}
maven {name = "sonatype-oss-snapshots1"; url = "https://s01.oss.sonatype.org/content/repositories/snapshots/"}
maven {name = "dmulloy2-repo"; url = "https://repo.dmulloy2.net/repository/public/"}
maven {name = "clip-repo"; url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/'}
maven {name = "jitpack"; url = 'https://jitpack.io'}
maven {name = "codecrafter47-repo"; url = 'https://nexus.codecrafter47.de/content/repositories/public/'}
maven {name = "opencollab-snapshot-repo"; url = 'https://repo.opencollab.dev/main/'}
}
dependencies {
compileOnly fileTree(dir:'libs',includes:['*.jar'])
compileOnly ('io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT')
compileOnly ('io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT')
compileOnly ('me.clip:placeholderapi:2.11.3')
compileOnly ('com.zaxxer:HikariCP:5.0.1')
compileOnly ('commons-io:commons-io:2.11.0')
compileOnly ('dev.dejvokep:boosted-yaml:1.3')
compileOnly ('org.geysermc.geyser:api:2.1.0-SNAPSHOT')
compileOnly ('org.geysermc.floodgate:api:2.0-SNAPSHOT')
compileOnly ('net.md-5:bungeecord-api:1.19-R0.1-SNAPSHOT')
compileOnly ('com.github.LoneDev6:api-itemsadder:3.2.3c')
implementation ('net.kyori:adventure-api:4.13.0')
implementation ('net.kyori:adventure-api:4.13.1')
implementation ('net.kyori:adventure-platform-bukkit:4.3.0')
implementation ('net.kyori:adventure-text-minimessage:4.13.0')
implementation ('net.kyori:adventure-text-serializer-gson:4.13.0')
implementation ('net.kyori:adventure-text-minimessage:4.13.1')
implementation ('net.kyori:adventure-text-serializer-gson:4.13.1')
implementation ("org.bstats:bstats-bukkit:3.0.1")
}
def targetJavaVersion = 16
def targetJavaVersion = 17
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
@@ -45,9 +47,8 @@ java {
}
tasks.withType(JavaCompile).configureEach {
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
options.release = targetJavaVersion
}
options.encoding = "UTF-8"
}
processResources {
@@ -59,10 +60,6 @@ processResources {
}
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
shadowJar {
relocate ('net.kyori', 'net.momirealms.customnameplates.libs.net.kyori')
relocate ('org.bstats', 'net.momirealms.customnameplates.libs.org.bstats')

View File

@@ -35,6 +35,11 @@ public class CustomNameplatesAPI {
api = this;
}
public static CustomNameplatesAPI getInstance() {
return api;
}
@Deprecated
public static CustomNameplatesAPI getAPI() {
return api;
}

View File

@@ -98,12 +98,12 @@ public abstract class AbstractSubCommand {
protected boolean notExist(CommandSender commandSender, String type, String value) {
if (type.equals("nameplate")) {
if (!CustomNameplatesAPI.getAPI().doesNameplateExist(value)) {
if (!CustomNameplatesAPI.getInstance().doesNameplateExist(value)) {
AdventureUtils.sendMessage(commandSender, MessageManager.prefix + MessageManager.np_not_exist);
return true;
}
} else if (type.equals("bubble")) {
if (!CustomNameplatesAPI.getAPI().doesBubbleExist(value)) {
if (!CustomNameplatesAPI.getInstance().doesBubbleExist(value)) {
AdventureUtils.sendMessage(commandSender, MessageManager.prefix + MessageManager.bb_not_exist);
return true;
}

View File

@@ -43,7 +43,7 @@ public class BubblesEquipCommand extends AbstractSubCommand {
AdventureUtils.playerMessage((Player) sender, MessageManager.prefix + MessageManager.bb_notAvailable);
return true;
}
CustomNameplatesAPI.getAPI().equipBubble((Player) sender, args.get(0));
CustomNameplatesAPI.getInstance().equipBubble((Player) sender, args.get(0));
AdventureUtils.playerMessage((Player) sender, MessageManager.prefix + MessageManager.bb_equip.replace("{Bubble}", CustomNameplates.getInstance().getChatBubblesManager().getBubbleConfig(args.get(0)).display_name()));
return true;
}

View File

@@ -42,7 +42,7 @@ public class BubblesForceEquipCommand extends AbstractSubCommand {
return true;
Player player = Bukkit.getPlayer(args.get(0));
CustomNameplatesAPI.getAPI().equipBubble(player, args.get(1));
CustomNameplatesAPI.getInstance().equipBubble(player, args.get(1));
AdventureUtils.sendMessage(sender, MessageManager.prefix + MessageManager.bb_force_equip.replace("{Bubble}", CustomNameplates.getInstance().getChatBubblesManager().getBubbleConfig(args.get(1)).display_name()).replace("{Player}", args.get(0)));
return true;
}

View File

@@ -40,7 +40,7 @@ public class BubblesForceUnequipCommand extends AbstractSubCommand {
if (lackArgs(sender, 1, args.size()) || playerNotOnline(sender, args.get(0)))
return true;
Player player = Bukkit.getPlayer(args.get(0));
CustomNameplatesAPI.getAPI().unEquipBubble(player);
CustomNameplatesAPI.getInstance().unEquipBubble(player);
AdventureUtils.sendMessage(sender,MessageManager.prefix + MessageManager.bb_force_unEquip.replace("{Player}", args.get(0)));
return true;
}

View File

@@ -38,7 +38,7 @@ public class BubblesUnequipCommand extends AbstractSubCommand {
public boolean onCommand(CommandSender sender, List<String> args) {
if (noConsoleExecute(sender)) return true;
Player player = (Player) sender;
CustomNameplatesAPI.getAPI().unEquipBubble(player);
CustomNameplatesAPI.getInstance().unEquipBubble(player);
AdventureUtils.playerMessage(player, MessageManager.prefix + MessageManager.bb_unEquip);
return true;
}

View File

@@ -43,7 +43,7 @@ public class NameplatesEquipCommand extends AbstractSubCommand {
return true;
}
Player player = (Player) sender;
CustomNameplatesAPI.getAPI().equipNameplate(player, args.get(0));
CustomNameplatesAPI.getInstance().equipNameplate(player, args.get(0));
AdventureUtils.sendMessage(sender, MessageManager.prefix + MessageManager.np_equip.replace("{Nameplate}", CustomNameplates.getInstance().getNameplateManager().getNameplateConfig(args.get(0)).display_name()));
return true;
}

View File

@@ -40,7 +40,7 @@ public class NameplatesForceEquipCommand extends AbstractSubCommand {
public boolean onCommand(CommandSender sender, List<String> args) {
if (lackArgs(sender, 2, args.size()) || playerNotOnline(sender, args.get(0)) || notExist(sender, "nameplate", args.get(1))) return true;
Player player = Bukkit.getPlayer(args.get(0));
CustomNameplatesAPI.getAPI().equipNameplate(player, args.get(1));
CustomNameplatesAPI.getInstance().equipNameplate(player, args.get(1));
AdventureUtils.sendMessage(sender, MessageManager.prefix + MessageManager.np_force_equip.replace("{Nameplate}", CustomNameplates.getInstance().getNameplateManager().getNameplateConfig(args.get(1)).display_name()).replace("{Player}", args.get(0)));
return true;
}

View File

@@ -40,7 +40,7 @@ public class NameplatesForceUnequipCommand extends AbstractSubCommand {
if (lackArgs(sender, 1, args.size()) || playerNotOnline(sender, args.get(0)))
return true;
Player player = Bukkit.getPlayer(args.get(0));
CustomNameplatesAPI.getAPI().unEquipNameplate(player);
CustomNameplatesAPI.getInstance().unEquipNameplate(player);
AdventureUtils.sendMessage(sender, MessageManager.prefix + MessageManager.np_force_unEquip.replace("{Player}", args.get(0)));
return true;
}

View File

@@ -38,7 +38,7 @@ public class NameplatesUnequipCommand extends AbstractSubCommand {
public boolean onCommand(CommandSender sender, List<String> args) {
if (noConsoleExecute(sender)) return true;
Player player = (Player) sender;
CustomNameplatesAPI.getAPI().unEquipNameplate(player);
CustomNameplatesAPI.getInstance().unEquipNameplate(player);
AdventureUtils.playerMessage(player, MessageManager.prefix + MessageManager.np_unEquip);
return true;
}

View File

@@ -28,7 +28,7 @@ package net.momirealms.customnameplates.helper;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import net.momirealms.customnameplates.CustomNameplates;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.io.InputStream;

View File

@@ -144,7 +144,9 @@ public class ActionBarManager extends Function {
if ((overlay != null && overlay || position != null && position == 2)) {
ActionBarTask actionBarTask = getActionBarTask(event.getPlayer().getUniqueId());
if (actionBarTask != null) {
Component component = GsonComponentSerializer.gson().deserialize(packet.getStrings().read(0));
String json = packet.getStrings().read(0);
if (json != null && !json.equals("")) {
Component component = GsonComponentSerializer.gson().deserialize(json);
if (component instanceof ScoreComponent scoreComponent) {
if (scoreComponent.name().equals("nameplates") && scoreComponent.objective().equals("actionbar")) {
return;
@@ -152,6 +154,9 @@ public class ActionBarManager extends Function {
}
event.setCancelled(true);
actionBarTask.setOtherText(AdventureUtils.getMiniMessageFormat(component), System.currentTimeMillis());
} else {
event.setCancelled(true);
}
}
}
}

View File

@@ -27,7 +27,7 @@ import net.momirealms.customnameplates.object.font.OffsetFont;
import net.momirealms.customnameplates.object.font.ThinASCIIWidth;
import net.momirealms.customnameplates.utils.AdventureUtils;
import net.momirealms.customnameplates.utils.ConfigUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang3.StringEscapeUtils;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

View File

@@ -242,10 +242,10 @@ public class NameplateManager extends Function {
String current = getEquippedNameplate(player);
if (!nameplate.equals(current)) {
plugin.getDataManager().equipNameplate(player, nameplate);
CustomNameplatesAPI.getAPI().updateNameplateTeam(player);
CustomNameplatesAPI.getInstance().updateNameplateTeam(player);
Bukkit.getScheduler().runTaskLater(CustomNameplates.getInstance(), ()-> {
plugin.getDataManager().equipNameplate(player, current);
CustomNameplatesAPI.getAPI().updateNameplateTeam(player);
CustomNameplatesAPI.getInstance().updateNameplateTeam(player);
},this.getPreview_time() * 20);
}
showPlayerArmorStandTags(player);

View File

@@ -20,9 +20,6 @@ package net.momirealms.customnameplates.manager;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import io.th0rgal.oraxen.config.Settings;
import io.th0rgal.oraxen.utils.VirtualFile;
import io.th0rgal.oraxen.utils.ZipUtils;
import net.momirealms.customnameplates.CustomNameplates;
import net.momirealms.customnameplates.object.SimpleChar;
import net.momirealms.customnameplates.object.background.BackGroundConfig;
@@ -31,20 +28,14 @@ import net.momirealms.customnameplates.object.font.OffsetFont;
import net.momirealms.customnameplates.object.nameplate.NameplateConfig;
import net.momirealms.customnameplates.utils.AdventureUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.Bukkit;
import java.io.*;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.nio.file.attribute.FileTime;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.zip.Deflater;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
public class ResourceManager {
@@ -300,6 +291,7 @@ public class ResourceManager {
return Character.toString(ch);
}
@SuppressWarnings("ResultOfMethodCallIgnored")
private void saveSplit(String texture_folder_path) {
try {
plugin.saveResource("space_split.png", false);

View File

@@ -19,27 +19,6 @@ package net.momirealms.customnameplates.object.actionbar;
import net.momirealms.customnameplates.object.requirements.Requirement;
public class ActionBarConfig {
public record ActionBarConfig(int interval, String[] texts, Requirement[] conditions) {
private final int interval;
private final String[] texts;
private final Requirement[] conditions;
public ActionBarConfig(int interval, String[] texts, Requirement[] conditions) {
this.texts = texts;
this.conditions = conditions;
this.interval = interval;
}
public String[] getTexts() {
return texts;
}
public Requirement[] getConditions() {
return conditions;
}
public int getInterval() {
return interval;
}
}

View File

@@ -1,3 +1,20 @@
/*
* 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.object.actionbar;
import net.kyori.adventure.text.Component;

View File

@@ -1,3 +1,20 @@
/*
* 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.object.actionbar;
import net.momirealms.customnameplates.CustomNameplates;
@@ -18,9 +35,9 @@ public class ActionBarTask {
for (int i = 0; i < configs.length; i++) {
ActionBarConfig actionBarConfig = configs[i];
this.actionBarSenders[i] = new ActionBarSender(
actionBarConfig.getInterval(),
actionBarConfig.getTexts(),
actionBarConfig.getConditions(),
actionBarConfig.interval(),
actionBarConfig.texts(),
actionBarConfig.conditions(),
player
);
}

View File

@@ -20,39 +20,6 @@ package net.momirealms.customnameplates.object.bossbar;
import net.momirealms.customnameplates.object.requirements.Requirement;
import org.bukkit.boss.BarColor;
public class BossBarConfig {
public record BossBarConfig(String[] texts, Overlay overlay, BarColor color, int interval, Requirement[] conditions) {
private final String[] texts;
private final int interval;
private final Overlay overlay;
private final BarColor color;
private final Requirement[] conditions;
public BossBarConfig(String[] texts, Overlay overlay, BarColor color, int interval, Requirement[] conditions) {
this.texts = texts;
this.overlay = overlay;
this.color = color;
this.interval = interval;
this.conditions = conditions;
}
public String[] getTexts() {
return texts;
}
public int getInterval() {
return interval;
}
public Overlay getOverlay() {
return overlay;
}
public BarColor getColor() {
return color;
}
public Requirement[] getConditions() {
return conditions;
}
}

View File

@@ -1,3 +1,20 @@
/*
* 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.object.bossbar;
import com.comphenix.protocol.PacketType;

View File

@@ -1,3 +1,20 @@
/*
* 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.object.bossbar;
import net.momirealms.customnameplates.CustomNameplates;
@@ -9,19 +26,17 @@ public class BossBarTask {
private BukkitTask timerTask;
private final BossBarSender[] bossBarSenders;
private final Player player;
public BossBarTask(Player player, BossBarConfig[] configs) {
this.bossBarSenders = new BossBarSender[configs.length];
this.player = player;
for (int i = 0; i < configs.length; i++) {
BossBarConfig bossBarConfig = configs[i];
this.bossBarSenders[i] = new BossBarSender(
bossBarConfig.getInterval(),
bossBarConfig.getTexts(),
bossBarConfig.getConditions(),
bossBarConfig.getOverlay(),
bossBarConfig.getColor(),
bossBarConfig.interval(),
bossBarConfig.texts(),
bossBarConfig.conditions(),
bossBarConfig.overlay(),
bossBarConfig.color(),
player
);
}

View File

@@ -1,3 +1,20 @@
/*
* 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.object.nameplate.mode;
import net.momirealms.customnameplates.CustomNameplates;

View File

@@ -1,3 +1,20 @@
/*
* 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.object.nameplate.mode;
public enum DisplayMode {

View File

@@ -17,7 +17,7 @@
package net.momirealms.customnameplates.object.requirements;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.entity.Player;
import java.util.List;

View File

@@ -17,7 +17,7 @@
package net.momirealms.customnameplates.object.requirements;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.bukkit.entity.Player;
import java.util.List;

View File

@@ -1,3 +1,20 @@
/*
* 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.object.team;
import org.bukkit.entity.Player;

View File

@@ -1,3 +1,20 @@
/*
* 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.object.team.name;
import com.comphenix.protocol.PacketType;

View File

@@ -1,3 +1,20 @@
/*
* 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.object.team.name;
import com.google.common.io.ByteArrayDataInput;

View File

@@ -41,13 +41,9 @@ public class ArmorStandUtils {
sendSpawnPacket(player, id);
sendMetaPacket(player, id, component);
for (int i = 1; i < duration * 20 - 1; i++){
Bukkit.getScheduler().runTaskLater(CustomNameplates.getInstance(), ()->{
sendTeleportPacket(player, id);
}, i);
Bukkit.getScheduler().runTaskLater(CustomNameplates.getInstance(), ()-> sendTeleportPacket(player, id), i);
}
Bukkit.getScheduler().runTaskLater(CustomNameplates.getInstance(), ()->{
sendDestroyPacket(player, id);
}, duration * 20L);
Bukkit.getScheduler().runTaskLater(CustomNameplates.getInstance(), ()-> sendDestroyPacket(player, id), duration * 20L);
}
public static void sendSpawnPacket(Player player, int id) {