9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2025-12-24 01:19:17 +00:00
This commit is contained in:
Xiao-MoMi
2023-03-29 19:51:23 +08:00
parent ebd4f44f50
commit b70c7eedef
22 changed files with 53 additions and 44 deletions

View File

@@ -23,8 +23,8 @@ import com.comphenix.protocol.ProtocolManager;
import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketContainer;
import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.momirealms.customnameplates.api.CustomNameplatesAPI; import net.momirealms.customnameplates.api.CustomNameplatesAPI;
import net.momirealms.customnameplates.commands.BubblesCommand; import net.momirealms.customnameplates.command.BubblesCommand;
import net.momirealms.customnameplates.commands.NameplateCommand; import net.momirealms.customnameplates.command.NameplateCommand;
import net.momirealms.customnameplates.helper.LibraryLoader; import net.momirealms.customnameplates.helper.LibraryLoader;
import net.momirealms.customnameplates.helper.VersionHelper; import net.momirealms.customnameplates.helper.VersionHelper;
import net.momirealms.customnameplates.manager.*; import net.momirealms.customnameplates.manager.*;

View File

@@ -36,11 +36,7 @@ public class CustomNameplatesAPI {
} }
private void updateAndSave(Player player) { private void updateAndSave(Player player) {
NameplatesTeam nameplatesTeam = plugin.getTeamManager().getNameplateTeam(player.getUniqueId()); updateNameplateTeam(player);
if (nameplatesTeam != null) {
nameplatesTeam.update(true);
plugin.getTeamManager().sendUpdateToAll(player, true);
}
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
plugin.getDataManager().saveData(player); plugin.getDataManager().saveData(player);
}); });
@@ -64,4 +60,12 @@ public class CustomNameplatesAPI {
plugin.getDataManager().saveData(player); plugin.getDataManager().saveData(player);
}); });
} }
public void updateNameplateTeam(Player player) {
NameplatesTeam nameplatesTeam = plugin.getTeamManager().getNameplateTeam(player.getUniqueId());
if (nameplatesTeam != null) {
nameplatesTeam.update(true);
plugin.getTeamManager().sendUpdateToAll(player, true);
}
}
} }

View File

@@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customnameplates.commands; package net.momirealms.customnameplates.command;
import net.momirealms.customnameplates.manager.MessageManager; import net.momirealms.customnameplates.manager.MessageManager;
import net.momirealms.customnameplates.utils.AdventureUtils; import net.momirealms.customnameplates.utils.AdventureUtils;

View File

@@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customnameplates.commands; package net.momirealms.customnameplates.command;
import net.momirealms.customnameplates.CustomNameplates; import net.momirealms.customnameplates.CustomNameplates;
import net.momirealms.customnameplates.api.CustomNameplatesAPI; import net.momirealms.customnameplates.api.CustomNameplatesAPI;

View File

@@ -15,9 +15,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customnameplates.commands; package net.momirealms.customnameplates.command;
import net.momirealms.customnameplates.commands.subcmd.*; import net.momirealms.customnameplates.command.subcmd.*;
public class BubblesCommand extends AbstractMainCommand { public class BubblesCommand extends AbstractMainCommand {

View File

@@ -15,9 +15,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customnameplates.commands; package net.momirealms.customnameplates.command;
import net.momirealms.customnameplates.commands.subcmd.*; import net.momirealms.customnameplates.command.subcmd.*;
public class NameplateCommand extends AbstractMainCommand { public class NameplateCommand extends AbstractMainCommand {

View File

@@ -15,10 +15,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customnameplates.commands.subcmd; package net.momirealms.customnameplates.command.subcmd;
import net.momirealms.customnameplates.CustomNameplates; import net.momirealms.customnameplates.CustomNameplates;
import net.momirealms.customnameplates.commands.AbstractSubCommand; import net.momirealms.customnameplates.command.AbstractSubCommand;
import net.momirealms.customnameplates.utils.AdventureUtils; import net.momirealms.customnameplates.utils.AdventureUtils;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@@ -15,11 +15,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customnameplates.commands.subcmd; package net.momirealms.customnameplates.command.subcmd;
import net.momirealms.customnameplates.CustomNameplates; import net.momirealms.customnameplates.CustomNameplates;
import net.momirealms.customnameplates.api.CustomNameplatesAPI; import net.momirealms.customnameplates.api.CustomNameplatesAPI;
import net.momirealms.customnameplates.commands.AbstractSubCommand; import net.momirealms.customnameplates.command.AbstractSubCommand;
import net.momirealms.customnameplates.manager.MessageManager; import net.momirealms.customnameplates.manager.MessageManager;
import net.momirealms.customnameplates.utils.AdventureUtils; import net.momirealms.customnameplates.utils.AdventureUtils;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@@ -15,11 +15,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customnameplates.commands.subcmd; package net.momirealms.customnameplates.command.subcmd;
import net.momirealms.customnameplates.CustomNameplates; import net.momirealms.customnameplates.CustomNameplates;
import net.momirealms.customnameplates.api.CustomNameplatesAPI; import net.momirealms.customnameplates.api.CustomNameplatesAPI;
import net.momirealms.customnameplates.commands.AbstractSubCommand; import net.momirealms.customnameplates.command.AbstractSubCommand;
import net.momirealms.customnameplates.manager.MessageManager; import net.momirealms.customnameplates.manager.MessageManager;
import net.momirealms.customnameplates.utils.AdventureUtils; import net.momirealms.customnameplates.utils.AdventureUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;

View File

@@ -15,10 +15,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customnameplates.commands.subcmd; package net.momirealms.customnameplates.command.subcmd;
import net.momirealms.customnameplates.api.CustomNameplatesAPI; import net.momirealms.customnameplates.api.CustomNameplatesAPI;
import net.momirealms.customnameplates.commands.AbstractSubCommand; import net.momirealms.customnameplates.command.AbstractSubCommand;
import net.momirealms.customnameplates.manager.MessageManager; import net.momirealms.customnameplates.manager.MessageManager;
import net.momirealms.customnameplates.utils.AdventureUtils; import net.momirealms.customnameplates.utils.AdventureUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;

View File

@@ -15,10 +15,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customnameplates.commands.subcmd; package net.momirealms.customnameplates.command.subcmd;
import net.momirealms.customnameplates.CustomNameplates; import net.momirealms.customnameplates.CustomNameplates;
import net.momirealms.customnameplates.commands.AbstractSubCommand; import net.momirealms.customnameplates.command.AbstractSubCommand;
import net.momirealms.customnameplates.manager.MessageManager; import net.momirealms.customnameplates.manager.MessageManager;
import net.momirealms.customnameplates.utils.AdventureUtils; import net.momirealms.customnameplates.utils.AdventureUtils;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@@ -15,10 +15,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customnameplates.commands.subcmd; package net.momirealms.customnameplates.command.subcmd;
import net.momirealms.customnameplates.api.CustomNameplatesAPI; import net.momirealms.customnameplates.api.CustomNameplatesAPI;
import net.momirealms.customnameplates.commands.AbstractSubCommand; import net.momirealms.customnameplates.command.AbstractSubCommand;
import net.momirealms.customnameplates.manager.MessageManager; import net.momirealms.customnameplates.manager.MessageManager;
import net.momirealms.customnameplates.utils.AdventureUtils; import net.momirealms.customnameplates.utils.AdventureUtils;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@@ -15,7 +15,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customnameplates.commands.subcmd; package net.momirealms.customnameplates.command.subcmd;
import me.clip.placeholderapi.PlaceholderAPI; import me.clip.placeholderapi.PlaceholderAPI;
import net.kyori.adventure.key.Key; import net.kyori.adventure.key.Key;
@@ -23,7 +23,7 @@ import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextColor; import net.kyori.adventure.text.format.TextColor;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import net.momirealms.customnameplates.CustomNameplates; import net.momirealms.customnameplates.CustomNameplates;
import net.momirealms.customnameplates.commands.AbstractSubCommand; import net.momirealms.customnameplates.command.AbstractSubCommand;
import net.momirealms.customnameplates.manager.MessageManager; import net.momirealms.customnameplates.manager.MessageManager;
import net.momirealms.customnameplates.manager.NameplateManager; import net.momirealms.customnameplates.manager.NameplateManager;
import net.momirealms.customnameplates.object.nameplate.NameplateConfig; import net.momirealms.customnameplates.object.nameplate.NameplateConfig;

View File

@@ -15,9 +15,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customnameplates.commands.subcmd; package net.momirealms.customnameplates.command.subcmd;
import net.momirealms.customnameplates.commands.AbstractSubCommand; import net.momirealms.customnameplates.command.AbstractSubCommand;
import net.momirealms.customnameplates.utils.AdventureUtils; import net.momirealms.customnameplates.utils.AdventureUtils;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@@ -15,11 +15,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customnameplates.commands.subcmd; package net.momirealms.customnameplates.command.subcmd;
import net.momirealms.customnameplates.CustomNameplates; import net.momirealms.customnameplates.CustomNameplates;
import net.momirealms.customnameplates.api.CustomNameplatesAPI; import net.momirealms.customnameplates.api.CustomNameplatesAPI;
import net.momirealms.customnameplates.commands.AbstractSubCommand; import net.momirealms.customnameplates.command.AbstractSubCommand;
import net.momirealms.customnameplates.manager.MessageManager; import net.momirealms.customnameplates.manager.MessageManager;
import net.momirealms.customnameplates.utils.AdventureUtils; import net.momirealms.customnameplates.utils.AdventureUtils;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@@ -15,11 +15,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customnameplates.commands.subcmd; package net.momirealms.customnameplates.command.subcmd;
import net.momirealms.customnameplates.CustomNameplates; import net.momirealms.customnameplates.CustomNameplates;
import net.momirealms.customnameplates.api.CustomNameplatesAPI; import net.momirealms.customnameplates.api.CustomNameplatesAPI;
import net.momirealms.customnameplates.commands.AbstractSubCommand; import net.momirealms.customnameplates.command.AbstractSubCommand;
import net.momirealms.customnameplates.manager.MessageManager; import net.momirealms.customnameplates.manager.MessageManager;
import net.momirealms.customnameplates.utils.AdventureUtils; import net.momirealms.customnameplates.utils.AdventureUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;

View File

@@ -15,10 +15,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customnameplates.commands.subcmd; package net.momirealms.customnameplates.command.subcmd;
import net.momirealms.customnameplates.api.CustomNameplatesAPI; import net.momirealms.customnameplates.api.CustomNameplatesAPI;
import net.momirealms.customnameplates.commands.AbstractSubCommand; import net.momirealms.customnameplates.command.AbstractSubCommand;
import net.momirealms.customnameplates.manager.MessageManager; import net.momirealms.customnameplates.manager.MessageManager;
import net.momirealms.customnameplates.utils.AdventureUtils; import net.momirealms.customnameplates.utils.AdventureUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;

View File

@@ -15,10 +15,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customnameplates.commands.subcmd; package net.momirealms.customnameplates.command.subcmd;
import net.momirealms.customnameplates.CustomNameplates; import net.momirealms.customnameplates.CustomNameplates;
import net.momirealms.customnameplates.commands.AbstractSubCommand; import net.momirealms.customnameplates.command.AbstractSubCommand;
import net.momirealms.customnameplates.manager.MessageManager; import net.momirealms.customnameplates.manager.MessageManager;
import net.momirealms.customnameplates.utils.AdventureUtils; import net.momirealms.customnameplates.utils.AdventureUtils;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@@ -15,10 +15,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customnameplates.commands.subcmd; package net.momirealms.customnameplates.command.subcmd;
import net.momirealms.customnameplates.api.CustomNameplatesAPI; import net.momirealms.customnameplates.api.CustomNameplatesAPI;
import net.momirealms.customnameplates.commands.AbstractSubCommand; import net.momirealms.customnameplates.command.AbstractSubCommand;
import net.momirealms.customnameplates.manager.MessageManager; import net.momirealms.customnameplates.manager.MessageManager;
import net.momirealms.customnameplates.utils.AdventureUtils; import net.momirealms.customnameplates.utils.AdventureUtils;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@@ -15,13 +15,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customnameplates.commands.subcmd; package net.momirealms.customnameplates.command.subcmd;
import net.kyori.adventure.key.Key; import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextColor; import net.kyori.adventure.text.format.TextColor;
import net.momirealms.customnameplates.CustomNameplates; import net.momirealms.customnameplates.CustomNameplates;
import net.momirealms.customnameplates.commands.AbstractSubCommand; import net.momirealms.customnameplates.command.AbstractSubCommand;
import net.momirealms.customnameplates.manager.MessageManager; import net.momirealms.customnameplates.manager.MessageManager;
import net.momirealms.customnameplates.manager.NameplateManager; import net.momirealms.customnameplates.manager.NameplateManager;
import net.momirealms.customnameplates.object.nameplate.NameplatesTeam; import net.momirealms.customnameplates.object.nameplate.NameplatesTeam;

View File

@@ -15,10 +15,10 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package net.momirealms.customnameplates.commands.subcmd; package net.momirealms.customnameplates.command.subcmd;
import net.momirealms.customnameplates.CustomNameplates; import net.momirealms.customnameplates.CustomNameplates;
import net.momirealms.customnameplates.commands.AbstractSubCommand; import net.momirealms.customnameplates.command.AbstractSubCommand;
import net.momirealms.customnameplates.manager.MessageManager; import net.momirealms.customnameplates.manager.MessageManager;
import net.momirealms.customnameplates.utils.AdventureUtils; import net.momirealms.customnameplates.utils.AdventureUtils;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;

View File

@@ -1,6 +1,7 @@
package net.momirealms.customnameplates.manager; package net.momirealms.customnameplates.manager;
import net.momirealms.customnameplates.CustomNameplates; import net.momirealms.customnameplates.CustomNameplates;
import net.momirealms.customnameplates.api.CustomNameplatesAPI;
import net.momirealms.customnameplates.object.ConditionalText; import net.momirealms.customnameplates.object.ConditionalText;
import net.momirealms.customnameplates.object.Function; import net.momirealms.customnameplates.object.Function;
import net.momirealms.customnameplates.object.SimpleChar; import net.momirealms.customnameplates.object.SimpleChar;
@@ -225,7 +226,11 @@ public class NameplateManager extends Function {
String current = getEquippedNameplate(player); String current = getEquippedNameplate(player);
if (!nameplate.equals(current)) { if (!nameplate.equals(current)) {
plugin.getDataManager().equipNameplate(player, nameplate); plugin.getDataManager().equipNameplate(player, nameplate);
Bukkit.getScheduler().runTaskLater(CustomNameplates.getInstance(), ()-> plugin.getDataManager().equipNameplate(player, current),this.getPreview_time() * 20); CustomNameplatesAPI.getAPI().updateNameplateTeam(player);
Bukkit.getScheduler().runTaskLater(CustomNameplates.getInstance(), ()-> {
plugin.getDataManager().equipNameplate(player, current);
CustomNameplatesAPI.getAPI().updateNameplateTeam(player);
},this.getPreview_time() * 20);
} }
showPlayerArmorStandTags(player); showPlayerArmorStandTags(player);
} }