mirror of
https://github.com/Xiao-MoMi/Custom-Nameplates.git
synced 2025-12-22 16:39:24 +00:00
2.4.8
This commit is contained in:
@@ -132,9 +132,10 @@ public interface NameplateManager {
|
|||||||
* The tag would be put into map automatically and you can get it by getNameplatePlayer(uuid)
|
* The tag would be put into map automatically and you can get it by getNameplatePlayer(uuid)
|
||||||
*
|
*
|
||||||
* @param player player
|
* @param player player
|
||||||
|
* @param isJoin
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
NameplatePlayer createNameTag(@NotNull Player player);
|
NameplatePlayer createNameTag(@NotNull Player player, boolean isJoin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Put a nameplater player to map
|
* Put a nameplater player to map
|
||||||
|
|||||||
@@ -57,7 +57,8 @@ public interface UnlimitedTagManager {
|
|||||||
* Create or get a tag instance
|
* Create or get a tag instance
|
||||||
*
|
*
|
||||||
* @param player player
|
* @param player player
|
||||||
|
* @param isJoin
|
||||||
* @return entity tag instance
|
* @return entity tag instance
|
||||||
*/
|
*/
|
||||||
EntityTagPlayer createOrGetTagForPlayer(Player player);
|
EntityTagPlayer createOrGetTagForPlayer(Player player, boolean isJoin);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ plugins {
|
|||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
|
|
||||||
version = "2.4.7"
|
version = "2.4.8"
|
||||||
|
|
||||||
apply<JavaPlugin>()
|
apply<JavaPlugin>()
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
|
|||||||
@@ -157,12 +157,9 @@ public class DependencyManagerImpl implements DependencyManager {
|
|||||||
String forceRepo = dependency.getRepo();
|
String forceRepo = dependency.getRepo();
|
||||||
if (forceRepo == null) {
|
if (forceRepo == null) {
|
||||||
// attempt to download the dependency from each repo in order.
|
// attempt to download the dependency from each repo in order.
|
||||||
for (DependencyRepository repo : DependencyRepository.values()) {
|
for (DependencyRepository repo : DependencyRepository.repos()) {
|
||||||
if (repo.getId().equals("maven") && CNConfig.language.equals("zh_cn")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
LogUtils.info("Downloading dependency(" + fileName + ") from " + repo.getUrl() + dependency.getMavenRepoPath());
|
LogUtils.info("Downloading dependency(" + fileName + ")[" + repo.getUrl() + dependency.getMavenRepoPath() + "]");
|
||||||
repo.download(dependency, file);
|
repo.download(dependency, file);
|
||||||
LogUtils.info("Successfully downloaded " + fileName);
|
LogUtils.info("Successfully downloaded " + fileName);
|
||||||
return file;
|
return file;
|
||||||
@@ -174,7 +171,7 @@ public class DependencyManagerImpl implements DependencyManager {
|
|||||||
DependencyRepository repository = DependencyRepository.getByID(forceRepo);
|
DependencyRepository repository = DependencyRepository.getByID(forceRepo);
|
||||||
if (repository != null) {
|
if (repository != null) {
|
||||||
try {
|
try {
|
||||||
LogUtils.info("Downloading dependency(" + fileName + ") from " + repository.getUrl() + dependency.getMavenRepoPath());
|
LogUtils.info("Downloading dependency(" + fileName + ")[" + repository.getUrl() + dependency.getMavenRepoPath() + "]");
|
||||||
repository.download(dependency, file);
|
repository.download(dependency, file);
|
||||||
LogUtils.info("Successfully downloaded " + fileName);
|
LogUtils.info("Successfully downloaded " + fileName);
|
||||||
return file;
|
return file;
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ import java.net.URL;
|
|||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,15 +57,7 @@ public enum DependencyRepository {
|
|||||||
/**
|
/**
|
||||||
* Maven Central
|
* Maven Central
|
||||||
*/
|
*/
|
||||||
MAVEN_CENTRAL_MIRROR("aliyun", "https://maven.aliyun.com/repository/public/"),
|
MAVEN_CENTRAL_MIRROR("aliyun", "https://maven.aliyun.com/repository/public/");
|
||||||
/**
|
|
||||||
* Code MC
|
|
||||||
*/
|
|
||||||
CODE_MC("codemc", "https://repo.codemc.io/repository/maven-public/"),
|
|
||||||
/**
|
|
||||||
* Jitpack
|
|
||||||
*/
|
|
||||||
JITPACK("jitpack", "https://jitpack.io/");
|
|
||||||
|
|
||||||
private final String url;
|
private final String url;
|
||||||
private final String id;
|
private final String id;
|
||||||
@@ -75,6 +71,14 @@ public enum DependencyRepository {
|
|||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<DependencyRepository> repos() {
|
||||||
|
ArrayList<DependencyRepository> list = new ArrayList<>(List.of(values()));
|
||||||
|
if (Locale.getDefault() == Locale.SIMPLIFIED_CHINESE) {
|
||||||
|
Collections.reverse(list);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
public static DependencyRepository getByID(String id) {
|
public static DependencyRepository getByID(String id) {
|
||||||
for (DependencyRepository repository : values()) {
|
for (DependencyRepository repository : values()) {
|
||||||
if (id.equals(repository.id)) {
|
if (id.equals(repository.id)) {
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
|||||||
}, refreshFrequency * 50, refreshFrequency * 50, TimeUnit.MILLISECONDS);
|
}, refreshFrequency * 50, refreshFrequency * 50, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
for (Player online : Bukkit.getOnlinePlayers()) {
|
for (Player online : Bukkit.getOnlinePlayers()) {
|
||||||
createNameTag(online);
|
createNameTag(online, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,10 +309,7 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
|||||||
if (!CNConfig.isOtherTeamPluginHooked() && !isProxyMode()) {
|
if (!CNConfig.isOtherTeamPluginHooked() && !isProxyMode()) {
|
||||||
plugin.getTeamManager().createTeam(player);
|
plugin.getTeamManager().createTeam(player);
|
||||||
}
|
}
|
||||||
plugin.getScheduler().runTaskAsyncLater(() -> {
|
this.createNameTag(player, true);
|
||||||
if (player.isOnline())
|
|
||||||
this.createNameTag(player);
|
|
||||||
}, 50, TimeUnit.MILLISECONDS);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -424,21 +421,21 @@ public class NameplateManagerImpl implements NameplateManager, Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NameplatePlayer createNameTag(@NotNull Player player) {
|
public NameplatePlayer createNameTag(@NotNull Player player, boolean isJoin) {
|
||||||
if (tagMode == TagMode.TEAM) {
|
if (tagMode == TagMode.TEAM) {
|
||||||
NameplatePlayer nameplatePlayer = this.teamTagManager.createTagForPlayer(player, teamPrefix, teamSuffix);
|
NameplatePlayer nameplatePlayer = this.teamTagManager.createTagForPlayer(player, teamPrefix, teamSuffix);
|
||||||
putNameplatePlayerToMap(nameplatePlayer);
|
putNameplatePlayerToMap(nameplatePlayer);
|
||||||
this.unlimitedTagManager.createOrGetTagForPlayer(player);
|
this.unlimitedTagManager.createOrGetTagForPlayer(player, isJoin);
|
||||||
return nameplatePlayer;
|
return nameplatePlayer;
|
||||||
} else if (tagMode == TagMode.UNLIMITED) {
|
} else if (tagMode == TagMode.UNLIMITED) {
|
||||||
EntityTagPlayer tagPlayer = this.unlimitedTagManager.createOrGetTagForPlayer(player);
|
EntityTagPlayer tagPlayer = this.unlimitedTagManager.createOrGetTagForPlayer(player, isJoin);
|
||||||
for (DynamicTextTagSetting setting : tagSettings) {
|
for (DynamicTextTagSetting setting : tagSettings) {
|
||||||
tagPlayer.addTag(setting);
|
tagPlayer.addTag(setting);
|
||||||
}
|
}
|
||||||
putNameplatePlayerToMap(tagPlayer);
|
putNameplatePlayerToMap(tagPlayer);
|
||||||
return tagPlayer;
|
return tagPlayer;
|
||||||
} else {
|
} else {
|
||||||
this.unlimitedTagManager.createOrGetTagForPlayer(player);
|
this.unlimitedTagManager.createOrGetTagForPlayer(player, isJoin);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,7 +147,6 @@ public class UnlimitedPlayer extends UnlimitedEntity implements EntityTagPlayer
|
|||||||
}
|
}
|
||||||
nearbyPlayers.add(player);
|
nearbyPlayers.add(player);
|
||||||
playerVectorToArray();
|
playerVectorToArray();
|
||||||
setNameInvisibleFor(player);
|
|
||||||
for (StaticTextEntity tag : staticTagArray) {
|
for (StaticTextEntity tag : staticTagArray) {
|
||||||
if (tag.getComeRule().isPassed(player, entity)) {
|
if (tag.getComeRule().isPassed(player, entity)) {
|
||||||
tag.addPlayerToViewers(player);
|
tag.addPlayerToViewers(player);
|
||||||
@@ -158,6 +157,7 @@ public class UnlimitedPlayer extends UnlimitedEntity implements EntityTagPlayer
|
|||||||
tag.addPlayerToViewers(player);
|
tag.addPlayerToViewers(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setNameInvisibleFor(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -167,7 +167,6 @@ public class UnlimitedPlayer extends UnlimitedEntity implements EntityTagPlayer
|
|||||||
}
|
}
|
||||||
nearbyPlayers.remove(player);
|
nearbyPlayers.remove(player);
|
||||||
playerVectorToArray();
|
playerVectorToArray();
|
||||||
setNameVisibleFor(player);
|
|
||||||
for (StaticTextEntity tag : staticTagArray) {
|
for (StaticTextEntity tag : staticTagArray) {
|
||||||
if (tag.getLeaveRule().isPassed(player, entity)) {
|
if (tag.getLeaveRule().isPassed(player, entity)) {
|
||||||
tag.removePlayerFromViewers(player);
|
tag.removePlayerFromViewers(player);
|
||||||
@@ -176,14 +175,17 @@ public class UnlimitedPlayer extends UnlimitedEntity implements EntityTagPlayer
|
|||||||
for (DynamicTextEntity tag : dynamicTagArray) {
|
for (DynamicTextEntity tag : dynamicTagArray) {
|
||||||
tag.removePlayerFromViewers(player);
|
tag.removePlayerFromViewers(player);
|
||||||
}
|
}
|
||||||
|
setNameVisibleFor(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
manager.removeUnlimitedEntityFromMap(entity.getUniqueId());
|
manager.removeUnlimitedEntityFromMap(entity.getUniqueId());
|
||||||
for (Player viewer : getNearbyPlayers()) {
|
for (Player viewer : getNearbyPlayers()) {
|
||||||
|
if (getPlayer().isOnline()) {
|
||||||
setNameVisibleFor(viewer);
|
setNameVisibleFor(viewer);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (DynamicTextEntity tag : dynamicTagArray) {
|
for (DynamicTextEntity tag : dynamicTagArray) {
|
||||||
tag.destroy();
|
tag.destroy();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public class UnlimitedTagManagerImpl implements UnlimitedTagManager {
|
|||||||
@Override
|
@Override
|
||||||
public UnlimitedEntity createOrGetTagForEntity(Entity entity) {
|
public UnlimitedEntity createOrGetTagForEntity(Entity entity) {
|
||||||
if (entity instanceof Player player) {
|
if (entity instanceof Player player) {
|
||||||
return createOrGetTagForPlayer(player);
|
return createOrGetTagForPlayer(player, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
final UUID uuid = entity.getUniqueId();
|
final UUID uuid = entity.getUniqueId();
|
||||||
@@ -158,7 +158,7 @@ public class UnlimitedTagManagerImpl implements UnlimitedTagManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UnlimitedPlayer createOrGetTagForPlayer(Player player) {
|
public UnlimitedPlayer createOrGetTagForPlayer(Player player, boolean isJoin) {
|
||||||
if (!player.isOnline())
|
if (!player.isOnline())
|
||||||
return null;
|
return null;
|
||||||
final UUID uuid = player.getUniqueId();
|
final UUID uuid = player.getUniqueId();
|
||||||
@@ -172,7 +172,7 @@ public class UnlimitedTagManagerImpl implements UnlimitedTagManager {
|
|||||||
unlimitedPlayer
|
unlimitedPlayer
|
||||||
);
|
);
|
||||||
|
|
||||||
if (player.getGameMode() != GameMode.SPECTATOR) {
|
if (player.getGameMode() != GameMode.SPECTATOR && !isJoin) {
|
||||||
unlimitedPlayer.addNearByPlayerToMap(48);
|
unlimitedPlayer.addNearByPlayerToMap(48);
|
||||||
}
|
}
|
||||||
return unlimitedPlayer;
|
return unlimitedPlayer;
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ import com.comphenix.protocol.events.PacketAdapter;
|
|||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
import com.google.common.io.ByteArrayDataOutput;
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
import net.momirealms.customnameplates.api.CustomNameplatesPlugin;
|
||||||
import net.momirealms.customnameplates.api.manager.TeamManager;
|
import net.momirealms.customnameplates.api.manager.TeamManager;
|
||||||
import net.momirealms.customnameplates.api.util.LogUtils;
|
import net.momirealms.customnameplates.api.util.LogUtils;
|
||||||
@@ -43,6 +45,7 @@ import org.bukkit.scoreboard.Scoreboard;
|
|||||||
import org.bukkit.scoreboard.Team;
|
import org.bukkit.scoreboard.Team;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -68,43 +71,43 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
|
|||||||
if (CNConfig.isOtherTeamPluginHooked()) return;
|
if (CNConfig.isOtherTeamPluginHooked()) return;
|
||||||
String team = teamProvider.getTeam(player, null);
|
String team = teamProvider.getTeam(player, null);
|
||||||
if (!team.equals(player.getName())) return;
|
if (!team.equals(player.getName())) return;
|
||||||
if (CNConfig.createRealTeam) {
|
// if (CNConfig.createRealTeam) {
|
||||||
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
||||||
Team playerTeam = scoreboard.getTeam(team);
|
Team playerTeam = scoreboard.getTeam(team);
|
||||||
if (playerTeam == null) {
|
if (playerTeam == null) {
|
||||||
playerTeam = scoreboard.registerNewTeam(team);
|
playerTeam = scoreboard.registerNewTeam(team);
|
||||||
}
|
}
|
||||||
playerTeam.addPlayer(player);
|
playerTeam.addPlayer(player);
|
||||||
} else {
|
// } else {
|
||||||
for (Player online : Bukkit.getOnlinePlayers()) {
|
// for (Player online : Bukkit.getOnlinePlayers()) {
|
||||||
SparrowHeart.getInstance().addClientSideTeam(online, team,
|
// SparrowHeart.getInstance().addClientSideTeam(online, team,
|
||||||
Collections.singletonList(player.getName()),
|
// Collections.singletonList(player.getName()),
|
||||||
"{\"text\":\"\"}",
|
// "{\"text\":\"\"}",
|
||||||
"{\"text\":\"\"}",
|
// "{\"text\":\"\"}",
|
||||||
"{\"text\":\"\"}",
|
// "{\"text\":\"\"}",
|
||||||
TeamVisibility.ALWAYS,
|
// TeamVisibility.ALWAYS,
|
||||||
TeamVisibility.ALWAYS,
|
// TeamVisibility.ALWAYS,
|
||||||
TeamCollisionRule.ALWAYS,
|
// TeamCollisionRule.ALWAYS,
|
||||||
TeamColor.WHITE,
|
// TeamColor.WHITE,
|
||||||
false,
|
// false,
|
||||||
false
|
// false
|
||||||
);
|
// );
|
||||||
if (online == player) continue;
|
// if (online == player) continue;
|
||||||
String onlineTeam = teamProvider.getTeam(online, null);
|
// String onlineTeam = teamProvider.getTeam(online, null);
|
||||||
SparrowHeart.getInstance().addClientSideTeam(player, onlineTeam,
|
// SparrowHeart.getInstance().addClientSideTeam(player, onlineTeam,
|
||||||
Collections.singletonList(online.getName()),
|
// Collections.singletonList(online.getName()),
|
||||||
"{\"text\":\"\"}",
|
// "{\"text\":\"\"}",
|
||||||
"{\"text\":\"\"}",
|
// "{\"text\":\"\"}",
|
||||||
"{\"text\":\"\"}",
|
// "{\"text\":\"\"}",
|
||||||
TeamVisibility.ALWAYS,
|
// TeamVisibility.ALWAYS,
|
||||||
TeamVisibility.ALWAYS,
|
// TeamVisibility.ALWAYS,
|
||||||
TeamCollisionRule.ALWAYS,
|
// TeamCollisionRule.ALWAYS,
|
||||||
TeamColor.WHITE,
|
// TeamColor.WHITE,
|
||||||
false,
|
// false,
|
||||||
false
|
// false
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -119,15 +122,15 @@ public class TeamManagerImpl implements TeamManager, PluginMessageListener {
|
|||||||
String team = teamProvider.getTeam(player, null);
|
String team = teamProvider.getTeam(player, null);
|
||||||
// If the team is created by other plugins
|
// If the team is created by other plugins
|
||||||
if (!team.equals(player.getName())) return;
|
if (!team.equals(player.getName())) return;
|
||||||
if (CNConfig.createRealTeam) {
|
// if (CNConfig.createRealTeam) {
|
||||||
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
Scoreboard scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
|
||||||
Optional.ofNullable(scoreboard.getTeam(team)).ifPresent(Team::unregister);
|
Optional.ofNullable(scoreboard.getTeam(team)).ifPresent(Team::unregister);
|
||||||
} else {
|
// } else {
|
||||||
for (Player online : Bukkit.getOnlinePlayers()) {
|
// for (Player online : Bukkit.getOnlinePlayers()) {
|
||||||
if (player == online) continue;
|
// if (player == online) continue;
|
||||||
SparrowHeart.getInstance().removeClientSideTeam(online, team);
|
// SparrowHeart.getInstance().removeClientSideTeam(online, team);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user