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