diff --git a/src/main/java/net/momirealms/customnameplates/ConfigManager.java b/src/main/java/net/momirealms/customnameplates/ConfigManager.java index ad18bb8..604005a 100644 --- a/src/main/java/net/momirealms/customnameplates/ConfigManager.java +++ b/src/main/java/net/momirealms/customnameplates/ConfigManager.java @@ -26,9 +26,10 @@ import net.momirealms.customnameplates.font.FontWidthThin; import net.momirealms.customnameplates.utils.AdventureUtil; import net.momirealms.customnameplates.objects.BackGroundText; import net.momirealms.customnameplates.objects.NameplateText; +import net.momirealms.customnameplates.utils.ConfigUtil; +import net.momirealms.customnameplates.utils.Reflection; import org.bukkit.Bukkit; import org.bukkit.boss.BarColor; -import org.bukkit.configuration.MemorySection; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; @@ -75,6 +76,13 @@ public class ConfigManager { background = module.getBoolean("background", true); bossBar = module.getBoolean("bossbar", true); actionbar = module.getBoolean("actionbar", true); + try { + Reflection.load(); + ConfigUtil.update(); + } + catch (Exception e){ + e.printStackTrace(); + } } } @@ -265,23 +273,15 @@ public class ConfigManager { * 载入BossBar配置 */ public static void loadBossBar() { + bossBars.clear(); YamlConfiguration config = getConfig("bossbar.yml"); Objects.requireNonNull(config.getConfigurationSection("bossbar")).getKeys(false).forEach(key -> { - BossBarConfig bossbarConfig = ConfigManager.bossBars.get(key); - if (bossbarConfig != null) { - bossbarConfig.setColor(BarColor.valueOf(config.getString("bossbar."+key+".color").toUpperCase())); - bossbarConfig.setRate(config.getInt("bossbar." + key + ".refresh-rate") - 1); - bossbarConfig.setText(config.getString("bossbar." + key + ".text")); - bossbarConfig.setOverlay(Overlay.valueOf(config.getString("bossbar."+key+".overlay").toUpperCase())); - } - else { - bossBars.put(key, new BossBarConfig( - config.getString("bossbar." + key + ".text"), - Overlay.valueOf(config.getString("bossbar."+key+".overlay").toUpperCase()), - BarColor.valueOf(config.getString("bossbar."+key+".color").toUpperCase()), - config.getInt("bossbar." + key + ".refresh-rate") - 1 - )); - } + bossBars.put(key, new BossBarConfig( + config.getString("bossbar." + key + ".text"), + Overlay.valueOf(config.getString("bossbar."+key+".overlay","progress").toUpperCase()), + BarColor.valueOf(config.getString("bossbar."+key+".color","white").toUpperCase()), + config.getInt("bossbar." + key + ".refresh-rate") - 1 + )); }); } diff --git a/src/main/java/net/momirealms/customnameplates/CustomNameplates.java b/src/main/java/net/momirealms/customnameplates/CustomNameplates.java index c507a62..5118699 100644 --- a/src/main/java/net/momirealms/customnameplates/CustomNameplates.java +++ b/src/main/java/net/momirealms/customnameplates/CustomNameplates.java @@ -28,6 +28,7 @@ import net.momirealms.customnameplates.data.DataManager; import net.momirealms.customnameplates.data.SqlHandler; import net.momirealms.customnameplates.helper.LibraryLoader; import net.momirealms.customnameplates.hook.PlaceholderManager; +import net.momirealms.customnameplates.nameplates.TeamManager; import net.momirealms.customnameplates.nameplates.TeamPacketManager; import net.momirealms.customnameplates.nameplates.mode.NameplateManager; import net.momirealms.customnameplates.nameplates.mode.rd.RidingTag; @@ -37,7 +38,6 @@ import net.momirealms.customnameplates.nameplates.mode.tmpackets.TeamPacketB; import net.momirealms.customnameplates.nameplates.mode.tmpackets.TeamPacketC; import net.momirealms.customnameplates.nameplates.mode.tp.TeleportingTag; import net.momirealms.customnameplates.resource.ResourceManager; -import net.momirealms.customnameplates.nameplates.TeamManager; import net.momirealms.customnameplates.utils.AdventureUtil; import net.momirealms.customnameplates.utils.ConfigUtil; import org.bukkit.Bukkit; @@ -85,10 +85,6 @@ public final class CustomNameplates extends JavaPlugin { this.resourceManager = new ResourceManager(); this.resourceManager.generateResourcePack(); - if (!Objects.equals(ConfigManager.Main.version, "3")){ - ConfigUtil.update(); - } - AdventureUtil.consoleMessage("[CustomNameplates] Plugin Enabled!"); } diff --git a/src/main/java/net/momirealms/customnameplates/Function.java b/src/main/java/net/momirealms/customnameplates/Function.java index 69374f9..7c4af90 100644 --- a/src/main/java/net/momirealms/customnameplates/Function.java +++ b/src/main/java/net/momirealms/customnameplates/Function.java @@ -9,11 +9,12 @@ public abstract class Function { } public void load() { - // } public void unload() { - // } + public String getName() { + return name; + } } diff --git a/src/main/java/net/momirealms/customnameplates/actionbar/ActionBarManager.java b/src/main/java/net/momirealms/customnameplates/actionbar/ActionBarManager.java index 59e2e1d..f0698e5 100644 --- a/src/main/java/net/momirealms/customnameplates/actionbar/ActionBarManager.java +++ b/src/main/java/net/momirealms/customnameplates/actionbar/ActionBarManager.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.actionbar; import net.momirealms.customnameplates.ConfigManager; diff --git a/src/main/java/net/momirealms/customnameplates/actionbar/ActionBarPacketsListener.java b/src/main/java/net/momirealms/customnameplates/actionbar/ActionBarPacketsListener.java new file mode 100644 index 0000000..deab948 --- /dev/null +++ b/src/main/java/net/momirealms/customnameplates/actionbar/ActionBarPacketsListener.java @@ -0,0 +1,21 @@ +package net.momirealms.customnameplates.actionbar; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.events.ListenerPriority; +import com.comphenix.protocol.events.PacketAdapter; +import com.comphenix.protocol.events.PacketEvent; +import net.momirealms.customnameplates.CustomNameplates; + +public class ActionBarPacketsListener extends PacketAdapter { + + private ActionBarManager manager; + + public ActionBarPacketsListener(ActionBarManager manager) { + super(CustomNameplates.instance, ListenerPriority.HIGHEST, PacketType.Play.Server.SET_ACTION_BAR_TEXT); + this.manager = manager; + } + + public void onPacketSending(PacketEvent event) { + + } +} diff --git a/src/main/java/net/momirealms/customnameplates/bossbar/BossBarConfig.java b/src/main/java/net/momirealms/customnameplates/bossbar/BossBarConfig.java index 0b603ad..240627f 100644 --- a/src/main/java/net/momirealms/customnameplates/bossbar/BossBarConfig.java +++ b/src/main/java/net/momirealms/customnameplates/bossbar/BossBarConfig.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.bossbar; import org.bukkit.boss.BarColor; diff --git a/src/main/java/net/momirealms/customnameplates/bossbar/BossBarManager.java b/src/main/java/net/momirealms/customnameplates/bossbar/BossBarManager.java index b581c04..374b1eb 100644 --- a/src/main/java/net/momirealms/customnameplates/bossbar/BossBarManager.java +++ b/src/main/java/net/momirealms/customnameplates/bossbar/BossBarManager.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.bossbar; import net.momirealms.customnameplates.CustomNameplates; diff --git a/src/main/java/net/momirealms/customnameplates/bossbar/Overlay.java b/src/main/java/net/momirealms/customnameplates/bossbar/Overlay.java index 18e88bb..8e3a754 100644 --- a/src/main/java/net/momirealms/customnameplates/bossbar/Overlay.java +++ b/src/main/java/net/momirealms/customnameplates/bossbar/Overlay.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.bossbar; public enum Overlay { diff --git a/src/main/java/net/momirealms/customnameplates/bossbar/PacketPlayOutBoss.java b/src/main/java/net/momirealms/customnameplates/bossbar/PacketPlayOutBoss.java deleted file mode 100644 index 16f40e1..0000000 --- a/src/main/java/net/momirealms/customnameplates/bossbar/PacketPlayOutBoss.java +++ /dev/null @@ -1,13 +0,0 @@ -package net.momirealms.customnameplates.bossbar; - -public class PacketPlayOutBoss { - - public enum Action { - ADD, - REMOVE, - UPDATE_PCT, - UPDATE_NAME, - UPDATE_STYLE, - UPDATE_PROPERTIES - } -} diff --git a/src/main/java/net/momirealms/customnameplates/bossbar/Sender.java b/src/main/java/net/momirealms/customnameplates/bossbar/Sender.java index e49ea20..1d16e4e 100644 --- a/src/main/java/net/momirealms/customnameplates/bossbar/Sender.java +++ b/src/main/java/net/momirealms/customnameplates/bossbar/Sender.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.bossbar; import com.comphenix.protocol.PacketType; @@ -9,12 +26,15 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.momirealms.customnameplates.objects.TextCache; import net.momirealms.customnameplates.utils.AdventureUtil; import net.momirealms.customnameplates.CustomNameplates; +import net.momirealms.customnameplates.utils.Reflection; import org.bukkit.boss.BarColor; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; +import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; +import java.util.Optional; import java.util.UUID; public class Sender { @@ -50,13 +70,13 @@ public class Sender { internalStructure.getFloat().write(0,1F); internalStructure.getEnumModifier(BarColor.class, 2).write(0, config.getColor()); internalStructure.getEnumModifier(Overlay.class, 3).write(0, config.getOverlay()); + internalStructure.getModifier().write(4, false); internalStructure.getModifier().write(5, false); internalStructure.getModifier().write(6, false); - internalStructure.getModifier().write(4, false); try{ CustomNameplates.protocolManager.sendServerPacket(player, packet); }catch (InvocationTargetException e){ - AdventureUtil.consoleMessage("[CustomNameplates] Failed to display bossbar for " + player.getName()); + AdventureUtil.consoleMessage("[CustomNameplates] Failed to update bossbar for " + player.getName()); } } } @@ -76,9 +96,9 @@ public class Sender { internalStructure.getFloat().write(0,1F); internalStructure.getEnumModifier(BarColor.class, 2).write(0, config.getColor()); internalStructure.getEnumModifier(Overlay.class, 3).write(0, config.getOverlay()); + internalStructure.getModifier().write(4, false); internalStructure.getModifier().write(5, false); internalStructure.getModifier().write(6, false); - internalStructure.getModifier().write(4, false); try{ CustomNameplates.protocolManager.sendServerPacket(player, packet); }catch (InvocationTargetException e){ @@ -92,6 +112,13 @@ public class Sender { } private void remove() { - + PacketContainer packet = new PacketContainer(PacketType.Play.Server.BOSS); + packet.getModifier().write(0, uuid); + packet.getModifier().write(1, Reflection.removeBar); + try{ + CustomNameplates.protocolManager.sendServerPacket(player, packet); + }catch (InvocationTargetException e){ + AdventureUtil.consoleMessage("[CustomNameplates] Failed to remove bossbar for " + player.getName()); + } } } diff --git a/src/main/java/net/momirealms/customnameplates/bossbar/SimpleListener.java b/src/main/java/net/momirealms/customnameplates/bossbar/SimpleListener.java index 39b8a6b..a4753aa 100644 --- a/src/main/java/net/momirealms/customnameplates/bossbar/SimpleListener.java +++ b/src/main/java/net/momirealms/customnameplates/bossbar/SimpleListener.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.bossbar; import org.bukkit.event.EventHandler; @@ -5,15 +22,15 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; -public record SimpleListener(BossBarManager function) implements Listener { +public record SimpleListener(BossBarManager bossBarManager) implements Listener { @EventHandler public void onJoin(PlayerJoinEvent event) { - function.onJoin(event.getPlayer()); + bossBarManager.onJoin(event.getPlayer()); } @EventHandler public void onQuit(PlayerQuitEvent event) { - function.onQuit(event.getPlayer()); + bossBarManager.onQuit(event.getPlayer()); } } diff --git a/src/main/java/net/momirealms/customnameplates/bossbar/TimerTaskP.java b/src/main/java/net/momirealms/customnameplates/bossbar/TimerTaskP.java index 3f00050..e5fb007 100644 --- a/src/main/java/net/momirealms/customnameplates/bossbar/TimerTaskP.java +++ b/src/main/java/net/momirealms/customnameplates/bossbar/TimerTaskP.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.bossbar; import net.momirealms.customnameplates.ConfigManager; diff --git a/src/main/java/net/momirealms/customnameplates/commands/Execute.java b/src/main/java/net/momirealms/customnameplates/commands/Execute.java index fc551ec..f6348d8 100644 --- a/src/main/java/net/momirealms/customnameplates/commands/Execute.java +++ b/src/main/java/net/momirealms/customnameplates/commands/Execute.java @@ -22,6 +22,9 @@ import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.TextColor; import net.kyori.adventure.text.minimessage.MiniMessage; import net.momirealms.customnameplates.ConfigManager; +import net.momirealms.customnameplates.nameplates.mode.ArmorStandManager; +import net.momirealms.customnameplates.nameplates.mode.EntityTag; +import net.momirealms.customnameplates.nameplates.mode.rd.RidingTag; import net.momirealms.customnameplates.resource.ResourceManager; import net.momirealms.customnameplates.utils.AdventureUtil; import net.momirealms.customnameplates.CustomNameplates; @@ -203,7 +206,17 @@ public class Execute implements CommandExecutor { HoloUtil.showHolo(full, player, (int) ConfigManager.Nameplate.preview); } else { - // ArmorStandPacketUtil.sendPreviewToOne(player); + EntityTag entityTag = (EntityTag) CustomNameplates.instance.getNameplateManager(); + ArmorStandManager asm = entityTag.getArmorStandManager(player); + asm.spawn(player); + for (int i = 0; i < ConfigManager.Nameplate.preview * 20; i++) { + Bukkit.getScheduler().runTaskLater(CustomNameplates.instance, ()->{ + asm.teleport(player); + },i); + } + Bukkit.getScheduler().runTaskLater(CustomNameplates.instance, ()->{ + asm.destroy(player); + },ConfigManager.Nameplate.preview * 20); } }else { AdventureUtil.playerMessage((Player) sender, ConfigManager.Message.prefix + ConfigManager.Message.noPerm); @@ -251,7 +264,17 @@ public class Execute implements CommandExecutor { HoloUtil.showHolo(full, player, (int) ConfigManager.Nameplate.preview); } else { - // ArmorStandPacketUtil.sendPreviewToOne(player); + EntityTag entityTag = (EntityTag) CustomNameplates.instance.getNameplateManager(); + ArmorStandManager asm = entityTag.getArmorStandManager(player); + asm.spawn(player); + for (int i = 0; i < ConfigManager.Nameplate.preview * 20; i++) { + Bukkit.getScheduler().runTaskLater(CustomNameplates.instance, ()->{ + asm.teleport(player); + },i); + } + Bukkit.getScheduler().runTaskLater(CustomNameplates.instance, ()->{ + asm.destroy(player); + },ConfigManager.Nameplate.preview * 20); } } diff --git a/src/main/java/net/momirealms/customnameplates/hook/PlaceholderManager.java b/src/main/java/net/momirealms/customnameplates/hook/PlaceholderManager.java index 0ea4e77..e095054 100644 --- a/src/main/java/net/momirealms/customnameplates/hook/PlaceholderManager.java +++ b/src/main/java/net/momirealms/customnameplates/hook/PlaceholderManager.java @@ -18,11 +18,8 @@ package net.momirealms.customnameplates.hook; import me.clip.placeholderapi.PlaceholderAPI; -import net.momirealms.customnameplates.CustomNameplates; import net.momirealms.customnameplates.Function; -import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import org.bukkit.event.HandlerList; import java.util.ArrayList; import java.util.Collections; diff --git a/src/main/java/net/momirealms/customnameplates/hook/TABTeamHook.java b/src/main/java/net/momirealms/customnameplates/hook/TABTeamHook.java index 98189a9..03a1d24 100644 --- a/src/main/java/net/momirealms/customnameplates/hook/TABTeamHook.java +++ b/src/main/java/net/momirealms/customnameplates/hook/TABTeamHook.java @@ -1,17 +1,11 @@ package net.momirealms.customnameplates.hook; -import me.neznamy.tab.api.TabPlayer; import me.neznamy.tab.shared.TAB; public class TABTeamHook { public static String getTABTeam(String playerName){ - TAB tab = TAB.getInstance(); - TabPlayer tabPlayer = tab.getPlayer(playerName); - String name = tabPlayer.getTeamName(); - if (name == null) { - return playerName; - } - return name; + String teamName = TAB.getInstance().getPlayer(playerName).getTeamName(); + return teamName == null ? playerName : teamName; } -} +} \ No newline at end of file diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/ArmorStand.java b/src/main/java/net/momirealms/customnameplates/nameplates/ArmorStand.java index f6317b4..9b807be 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/ArmorStand.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/ArmorStand.java @@ -1,9 +1,25 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates; import net.momirealms.customnameplates.objects.TextCache; import org.bukkit.entity.Player; - public interface ArmorStand { void setOffset(double var1); diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/TeamInfo.java b/src/main/java/net/momirealms/customnameplates/nameplates/TeamInfo.java index e1e942c..0a23fd6 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/TeamInfo.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/TeamInfo.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates; import java.util.Objects; diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/TeamPacketManager.java b/src/main/java/net/momirealms/customnameplates/nameplates/TeamPacketManager.java index 047914f..48b7647 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/TeamPacketManager.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/TeamPacketManager.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates; import org.bukkit.entity.Player; diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/mode/ArmorStandManager.java b/src/main/java/net/momirealms/customnameplates/nameplates/mode/ArmorStandManager.java index 0d788b3..0a6539e 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/mode/ArmorStandManager.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/mode/ArmorStandManager.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates.mode; import com.comphenix.protocol.PacketType; @@ -101,12 +118,8 @@ public class ArmorStandManager { } public void mount(Player receiver) { - int[] passengers = new int[armorStandArray.length]; - for (int i = 0; i < armorStandArray.length; i++) { - passengers[i] = armorStandArray[i].getEntityId(); - } try { - CustomNameplates.protocolManager.sendServerPacket(receiver, getMountPacket(passengers)); + CustomNameplates.protocolManager.sendServerPacket(receiver, getMountPacket(getArmorStandIDs())); } catch (InvocationTargetException e) { e.printStackTrace(); @@ -114,6 +127,14 @@ public class ArmorStandManager { } } + public int[] getArmorStandIDs() { + int[] passengers = new int[armorStandArray.length]; + for (int i = 0; i < armorStandArray.length; i++) { + passengers[i] = armorStandArray[i].getEntityId(); + } + return passengers; + } + private PacketContainer getMountPacket(int[] passengers) { PacketContainer packet = new PacketContainer(PacketType.Play.Server.MOUNT); packet.getIntegers().write(0, owner.getEntityId()); diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/mode/EntityTag.java b/src/main/java/net/momirealms/customnameplates/nameplates/mode/EntityTag.java index 3059857..05439fd 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/mode/EntityTag.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/mode/EntityTag.java @@ -1,9 +1,25 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates.mode; import net.momirealms.customnameplates.ConfigManager; import net.momirealms.customnameplates.CustomNameplates; import org.bukkit.Bukkit; -import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitTask; diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/mode/FakeArmorStand.java b/src/main/java/net/momirealms/customnameplates/nameplates/mode/FakeArmorStand.java index 6bd1bdb..2de1192 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/mode/FakeArmorStand.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/mode/FakeArmorStand.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates.mode; import com.comphenix.protocol.PacketType; @@ -175,7 +192,7 @@ public class FakeArmorStand implements ArmorStand { for (Player viewer : asm.getNearbyPlayers()) { PacketContainer metaPacket = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA); metaPacket.getIntegers().write(0, entityId); - metaPacket.getWatchableCollectionModifier().write(0, createDataWatcher(getText().getViewerText(viewer), viewer).getWatchableObjects()); + metaPacket.getWatchableCollectionModifier().write(0, createDataWatcher(getText().getViewerText(viewer)).getWatchableObjects()); try { CustomNameplates.protocolManager.sendServerPacket(viewer, metaPacket); } @@ -222,7 +239,7 @@ public class FakeArmorStand implements ArmorStand { } //创建实体信息包 - public WrappedDataWatcher createDataWatcher(String text, Player viewer) { + public WrappedDataWatcher createDataWatcher(String text) { WrappedDataWatcher wrappedDataWatcher = new WrappedDataWatcher(); WrappedDataWatcher.Serializer serializer1 = WrappedDataWatcher.Registry.get(Boolean.class); @@ -255,7 +272,7 @@ public class FakeArmorStand implements ArmorStand { PacketContainer metaPacket = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA); metaPacket.getIntegers().write(0, entityId); - metaPacket.getWatchableCollectionModifier().write(0, createDataWatcher(getText().getViewerText(viewer), viewer).getWatchableObjects()); + metaPacket.getWatchableCollectionModifier().write(0, createDataWatcher(getText().getViewerText(viewer)).getWatchableObjects()); return new PacketContainer[] {entityPacket, metaPacket}; } diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/mode/NameplateManager.java b/src/main/java/net/momirealms/customnameplates/nameplates/mode/NameplateManager.java index 8644044..0b1ece5 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/mode/NameplateManager.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/mode/NameplateManager.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates.mode; import net.momirealms.customnameplates.ConfigManager; diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/mode/PacketsHandler.java b/src/main/java/net/momirealms/customnameplates/nameplates/mode/PacketsHandler.java index 35d38ad..fd1773e 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/mode/PacketsHandler.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/mode/PacketsHandler.java @@ -1,5 +1,23 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates.mode; +import com.comphenix.protocol.events.PacketContainer; import net.momirealms.customnameplates.CustomNameplates; import net.momirealms.customnameplates.Function; import net.momirealms.customnameplates.nameplates.mode.listener.BukkitListener; @@ -62,7 +80,7 @@ public abstract class PacketsHandler extends Function { public void onEntityDestroy(Player receiver, int entity) { } - public void onEntityMount(int vehicle, int[] passengers) { + public void onEntityMount(PacketContainer packet) { } public Player getPlayerFromMap(int entityID) { diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/BukkitListener.java b/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/BukkitListener.java index fe6a2d4..08631dc 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/BukkitListener.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/BukkitListener.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates.mode.listener; import net.momirealms.customnameplates.nameplates.mode.PacketsHandler; diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntityDestroyListener.java b/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntityDestroyListener.java index c9cf342..e6199a0 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntityDestroyListener.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntityDestroyListener.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates.mode.listener; import com.comphenix.protocol.PacketType; diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntityLookListener.java b/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntityLookListener.java index 0d7b38f..8237729 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntityLookListener.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntityLookListener.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates.mode.listener; import com.comphenix.protocol.PacketType; diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntityMountListener.java b/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntityMountListener.java index 56b9765..fca1a7c 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntityMountListener.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntityMountListener.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates.mode.listener; import com.comphenix.protocol.PacketType; @@ -18,7 +35,6 @@ public class EntityMountListener extends PacketAdapter { } public void onPacketSending(PacketEvent event) { - PacketContainer packet = event.getPacket(); - handler.onEntityMount(packet.getIntegers().read(0), packet.getIntegerArrays().read(0)); + handler.onEntityMount(event.getPacket()); } } diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntityMoveListener.java b/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntityMoveListener.java index 93627be..5741020 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntityMoveListener.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntityMoveListener.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates.mode.listener; import com.comphenix.protocol.PacketType; diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntitySpawnListener.java b/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntitySpawnListener.java index b22dd56..ef0da5c 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntitySpawnListener.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntitySpawnListener.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates.mode.listener; import com.comphenix.protocol.PacketType; diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntityTeleportListener.java b/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntityTeleportListener.java index 2dfba70..6c7d7fd 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntityTeleportListener.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/mode/listener/EntityTeleportListener.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates.mode.listener; import com.comphenix.protocol.PacketType; diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/mode/rd/RdPacketsHandler.java b/src/main/java/net/momirealms/customnameplates/nameplates/mode/rd/RdPacketsHandler.java index 6fb30d3..c560def 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/mode/rd/RdPacketsHandler.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/mode/rd/RdPacketsHandler.java @@ -1,5 +1,23 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates.mode.rd; +import com.comphenix.protocol.events.PacketContainer; import net.momirealms.customnameplates.ConfigManager; import net.momirealms.customnameplates.CustomNameplates; import net.momirealms.customnameplates.nameplates.mode.ArmorStandManager; @@ -54,9 +72,9 @@ public class RdPacketsHandler extends PacketsHandler { if (spawnedPlayer != null) { ArmorStandManager asm = ridingTag.getArmorStandManager(spawnedPlayer); asm.spawn(receiver); - Bukkit.getScheduler().runTaskLater(CustomNameplates.instance, ()-> { + Bukkit.getScheduler().runTaskAsynchronously(CustomNameplates.instance, ()-> { asm.mount(receiver); - },1); + }); } } @@ -76,6 +94,21 @@ public class RdPacketsHandler extends PacketsHandler { } @Override - public void onEntityMount(int vehicle, int[] passengers) { + public void onEntityMount(PacketContainer packet) { + int[] ids = ridingTag.getArmorStandManager(super.getPlayerFromMap(packet.getIntegers().read(0))).getArmorStandIDs(); + if (ids != null) { + int[] old = packet.getIntegerArrays().read(0); + int[] idArray = new int[ids.length + old.length]; + int i = 0; + while (i < ids.length) { + idArray[i] = ids[i]; + i ++; + } + while (i < ids.length + old.length) { + idArray[i] = old[i - ids.length]; + i ++; + } + packet.getModifier().write(1, idArray); + } } } diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/mode/rd/RidingTag.java b/src/main/java/net/momirealms/customnameplates/nameplates/mode/rd/RidingTag.java index 11577c8..f85dfac 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/mode/rd/RidingTag.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/mode/rd/RidingTag.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates.mode.rd; import net.momirealms.customnameplates.CustomNameplates; @@ -77,9 +94,9 @@ public class RidingTag extends EntityTag { if (viewer.canSee(target)) { ArmorStandManager asm = getArmorStandManager(target); asm.spawn(viewer); - Bukkit.getScheduler().runTaskLater(CustomNameplates.instance, () -> { + Bukkit.getScheduler().runTaskAsynchronously(CustomNameplates.instance, () -> { asm.mount(viewer); - }, 1); + }); } } } diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/mode/tm/TeamTag.java b/src/main/java/net/momirealms/customnameplates/nameplates/mode/tm/TeamTag.java index a396192..ba4f3c7 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/mode/tm/TeamTag.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/mode/tm/TeamTag.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates.mode.tm; import net.momirealms.customnameplates.ConfigManager; @@ -9,7 +26,6 @@ import net.momirealms.customnameplates.nameplates.mode.EventListener; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; -import org.bukkit.event.player.PlayerResourcePackStatusEvent; import org.bukkit.scheduler.BukkitTask; import java.util.HashMap; diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/mode/tmpackets/TeamPacketA.java b/src/main/java/net/momirealms/customnameplates/nameplates/mode/tmpackets/TeamPacketA.java index 02f5a6b..988cd97 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/mode/tmpackets/TeamPacketA.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/mode/tmpackets/TeamPacketA.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates.mode.tmpackets; import com.comphenix.protocol.PacketType; @@ -8,7 +25,6 @@ import com.comphenix.protocol.wrappers.WrappedChatComponent; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.momirealms.customnameplates.ConfigManager; import net.momirealms.customnameplates.CustomNameplates; -import net.momirealms.customnameplates.data.PlayerData; import net.momirealms.customnameplates.hook.TABTeamHook; import net.momirealms.customnameplates.nameplates.NameplatesTeam; import net.momirealms.customnameplates.nameplates.TeamInfo; diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/mode/tmpackets/TeamPacketB.java b/src/main/java/net/momirealms/customnameplates/nameplates/mode/tmpackets/TeamPacketB.java index 72cca00..0b4808d 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/mode/tmpackets/TeamPacketB.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/mode/tmpackets/TeamPacketB.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates.mode.tmpackets; import com.comphenix.protocol.PacketType; @@ -6,7 +23,6 @@ import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.utility.MinecraftReflection; import net.momirealms.customnameplates.ConfigManager; import net.momirealms.customnameplates.CustomNameplates; -import net.momirealms.customnameplates.data.PlayerData; import net.momirealms.customnameplates.nameplates.TeamManager; import net.momirealms.customnameplates.nameplates.TeamPacketManager; import org.bukkit.Bukkit; diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/mode/tmpackets/TeamPacketC.java b/src/main/java/net/momirealms/customnameplates/nameplates/mode/tmpackets/TeamPacketC.java index d3acb4e..b3768c1 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/mode/tmpackets/TeamPacketC.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/mode/tmpackets/TeamPacketC.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates.mode.tmpackets; import com.comphenix.protocol.PacketType; diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/mode/tp/TeleportingTag.java b/src/main/java/net/momirealms/customnameplates/nameplates/mode/tp/TeleportingTag.java index d5f7d3e..728b31e 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/mode/tp/TeleportingTag.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/mode/tp/TeleportingTag.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates.mode.tp; import net.momirealms.customnameplates.CustomNameplates; diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/mode/tp/TpPacketsHandler.java b/src/main/java/net/momirealms/customnameplates/nameplates/mode/tp/TpPacketsHandler.java index 45397d3..c9ce81e 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/mode/tp/TpPacketsHandler.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/mode/tp/TpPacketsHandler.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates.mode.tp; import net.momirealms.customnameplates.CustomNameplates; diff --git a/src/main/java/net/momirealms/customnameplates/nameplates/mode/tp/VehicleChecker.java b/src/main/java/net/momirealms/customnameplates/nameplates/mode/tp/VehicleChecker.java index 74753c2..2013c29 100644 --- a/src/main/java/net/momirealms/customnameplates/nameplates/mode/tp/VehicleChecker.java +++ b/src/main/java/net/momirealms/customnameplates/nameplates/mode/tp/VehicleChecker.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.nameplates.mode.tp; import net.momirealms.customnameplates.CustomNameplates; @@ -11,7 +28,7 @@ import java.util.*; public class VehicleChecker extends Function { - private final WeakHashMap playersInVehicle = new WeakHashMap<>(); + private final WeakHashMap playersOnVehicle = new WeakHashMap<>(); private final TeleportingTag teleportingTag; @@ -27,11 +44,11 @@ public class VehicleChecker extends Function { for (Player all : Bukkit.getOnlinePlayers()) { Entity vehicle = all.getVehicle(); if (vehicle != null) { - playersInVehicle.put(all, vehicle); + playersOnVehicle.put(all, vehicle); } } this.task = Bukkit.getScheduler().runTaskTimerAsynchronously(CustomNameplates.instance, () -> { - for (Player inVehicle : playersInVehicle.keySet()) { + for (Player inVehicle : playersOnVehicle.keySet()) { if (!inVehicle.isOnline() || teleportingTag.getArmorStandManager(inVehicle) == null) continue; teleportingTag.getArmorStandManager(inVehicle).teleport(); } @@ -41,27 +58,27 @@ public class VehicleChecker extends Function { @Override public void unload() { this.task.cancel(); - playersInVehicle.clear(); + playersOnVehicle.clear(); } public void onJoin(Player player) { Entity vehicle = player.getVehicle(); - if (vehicle != null) playersInVehicle.put(player, vehicle); + if (vehicle != null) playersOnVehicle.put(player, vehicle); } public void onQuit(Player player) { - playersInVehicle.remove(player); + playersOnVehicle.remove(player); } public void refresh(Player player) { Entity vehicle = player.getVehicle(); - if (playersInVehicle.containsKey(player) && vehicle == null) { + if (playersOnVehicle.containsKey(player) && vehicle == null) { teleportingTag.getArmorStandManager(player).teleport(); - playersInVehicle.remove(player); + playersOnVehicle.remove(player); } - if (!playersInVehicle.containsKey(player) && vehicle != null) { + if (!playersOnVehicle.containsKey(player) && vehicle != null) { teleportingTag.getArmorStandManager(player).respawn(); - playersInVehicle.put(player, vehicle); + playersOnVehicle.put(player, vehicle); } } } \ No newline at end of file diff --git a/src/main/java/net/momirealms/customnameplates/objects/NMSStorage.java b/src/main/java/net/momirealms/customnameplates/objects/NMSStorage.java deleted file mode 100644 index 7b42199..0000000 --- a/src/main/java/net/momirealms/customnameplates/objects/NMSStorage.java +++ /dev/null @@ -1,10 +0,0 @@ -package net.momirealms.customnameplates.objects; - -public class NMSStorage { - - public Class PacketPlayOutEntity; - - public void loadClasses() throws ClassNotFoundException { - PacketPlayOutEntity = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutEntity"); - } -} diff --git a/src/main/java/net/momirealms/customnameplates/objects/TextCache.java b/src/main/java/net/momirealms/customnameplates/objects/TextCache.java index 7da7b1f..2fa6542 100644 --- a/src/main/java/net/momirealms/customnameplates/objects/TextCache.java +++ b/src/main/java/net/momirealms/customnameplates/objects/TextCache.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.objects; import net.momirealms.customnameplates.ConfigManager; diff --git a/src/main/java/net/momirealms/customnameplates/utils/ConfigUtil.java b/src/main/java/net/momirealms/customnameplates/utils/ConfigUtil.java index 04e1558..e3d5c0a 100644 --- a/src/main/java/net/momirealms/customnameplates/utils/ConfigUtil.java +++ b/src/main/java/net/momirealms/customnameplates/utils/ConfigUtil.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * 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 . + */ + package net.momirealms.customnameplates.utils; import dev.dejvokep.boostedyaml.YamlDocument; diff --git a/src/main/java/net/momirealms/customnameplates/utils/Reflection.java b/src/main/java/net/momirealms/customnameplates/utils/Reflection.java new file mode 100644 index 0000000..b12f7c3 --- /dev/null +++ b/src/main/java/net/momirealms/customnameplates/utils/Reflection.java @@ -0,0 +1,15 @@ +package net.momirealms.customnameplates.utils; + +import java.lang.reflect.Field; + +public class Reflection { + + public static Object removeBar; + + public static void load() throws Exception{ + Class bar = Class.forName("net.minecraft.network.protocol.game.PacketPlayOutBoss"); + Field remove = bar.getDeclaredField("f"); + remove.setAccessible(true); + removeBar = remove.get(null); + } +} diff --git a/src/main/resources/actionbar.yml b/src/main/resources/actionbar.yml index 8e406dc..8eaf1a2 100644 --- a/src/main/resources/actionbar.yml +++ b/src/main/resources/actionbar.yml @@ -1,2 +1,2 @@ -text: '%nameplates_prefix%Hello! %player_name%%nameplates_suffix%' +text: '%nameplates_prefix%%player_name%%nameplates_suffix%' refresh-rate: 5 \ No newline at end of file diff --git a/src/main/resources/background.yml b/src/main/resources/background.yml index 9144eab..ca71189 100644 --- a/src/main/resources/background.yml +++ b/src/main/resources/background.yml @@ -1,7 +1,10 @@ background: + bedrock_1: size: 14 + # x-offset = start + end -1 x-offset: 5 + # y-offset is the vertical position of the background y-offset: 7 start: b0 offset_1: b1 @@ -13,6 +16,7 @@ background: offset_64: b64 offset_128: b128 end: b0 + bedrock_2: size: 14 x-offset: 5 @@ -27,6 +31,7 @@ background: offset_64: b64 offset_128: b128 end: b0 + bedrock_3: size: 14 x-offset: 5 diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 6b6c3b1..f48734d 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,5 +1,5 @@ # don't change -config-version: '3' +config-version: '4' config: # Language diff --git a/src/main/resources/nameplate.yml b/src/main/resources/nameplate.yml index a03f943..80c8c66 100644 --- a/src/main/resources/nameplate.yml +++ b/src/main/resources/nameplate.yml @@ -1,4 +1,4 @@ -config-version: '3' +config-version: '4' nameplate: # mode: Team / Riding / Teleporting @@ -11,7 +11,6 @@ nameplate: # ========================== Teleporting =============================== # Plugin would summon fake armor stands packets teleporting the player # to provide additional tag lines for players - # (requires a restart) mode: Team update: