npcs
This commit is contained in:
parent
6525ea9f65
commit
ce5ad39302
5 changed files with 21 additions and 32 deletions
|
@ -24,7 +24,7 @@ public final class NullValkyrie extends JavaPlugin {
|
|||
Bukkit.getPluginManager().registerEvents(new ScoreboardListener(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new CustomItemEvents(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new DamageEffectEvents(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new NPCEvents(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new CustomEvents(), this);
|
||||
new DiscordClientManager();
|
||||
NPCDataManager.reloadNPC();
|
||||
CryptoMiner.reloadMiner();
|
||||
|
|
|
@ -102,5 +102,7 @@ public class NPCManager {
|
|||
NPCs.put(ep.getId(), ep);
|
||||
}
|
||||
}
|
||||
|
||||
public static ServerPlayer getNPC(int id) {
|
||||
return NPCs.get(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package me.night.nullvalkyrie.events.listeners;
|
||||
|
||||
import me.night.nullvalkyrie.entities.holograms.PerPlayerHologram;
|
||||
import me.night.nullvalkyrie.events.custom.InteractHologramEvent;
|
||||
import me.night.nullvalkyrie.events.custom.RightClickNPCEvent;
|
||||
import me.night.nullvalkyrie.entities.npcs.NPCManager;
|
||||
import me.night.nullvalkyrie.util.Util;
|
||||
import net.minecraft.network.protocol.game.ClientboundMoveEntityPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundRotateHeadPacket;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -13,15 +16,21 @@ import org.bukkit.event.EventHandler;
|
|||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
public class NPCEvents implements Listener {
|
||||
public class CustomEvents implements Listener {
|
||||
@EventHandler
|
||||
public void onClick(RightClickNPCEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
if (e.getNPC().getBukkitEntity().getName().contains("SAI")) {
|
||||
if (e.getNPC().getBukkitEntity().getName().contains("VETTEL")) {
|
||||
player.sendMessage(Util.color("Hi"));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClickHologram(InteractHologramEvent e) {
|
||||
if (e.getHologram().getCustomName() == null) return;
|
||||
if (e.getHologram().getCustomName().equals(ChatColor.GOLD + ChatColor.BOLD.toString() + "CLICK")) {
|
||||
e.getHologram().getNearbyEntities(0, 5, 0).forEach(entity -> new PerPlayerHologram(e.getPlayer(), new String[]{ChatColor.RED + "Player Info:", ChatColor.GOLD + "Name: " + ChatColor.AQUA + e.getPlayer().getName(), ChatColor.BLUE + "IP: " + e.getPlayer().getAddress()}));
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent e) {
|
||||
NPCManager.getNPCs().values().forEach(npc -> {
|
|
@ -1,7 +1,5 @@
|
|||
package me.night.nullvalkyrie.events.listeners;
|
||||
|
||||
import me.night.nullvalkyrie.entities.holograms.PerPlayerHologram;
|
||||
import me.night.nullvalkyrie.events.custom.InteractHologramEvent;
|
||||
import me.night.nullvalkyrie.packets.handle.PacketInjector;
|
||||
import me.night.nullvalkyrie.util.Util;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -49,13 +47,6 @@ public class ServerEvents implements Listener {
|
|||
ee.printStackTrace();
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void onClickHologram(InteractHologramEvent e) {
|
||||
if (e.getHologram().getCustomName() == null) return;
|
||||
if (e.getHologram().getCustomName().equals(ChatColor.GOLD + ChatColor.BOLD.toString() + "CLICK")) {
|
||||
e.getHologram().getNearbyEntities(0, 5, 0).forEach(entity -> new PerPlayerHologram(e.getPlayer(), new String[]{ChatColor.RED + "Player Info:", ChatColor.GOLD + "Name: " + ChatColor.AQUA + e.getPlayer().getName(), ChatColor.BLUE + "IP: " + e.getPlayer().getAddress()}));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWeatherChange(WeatherChangeEvent e) {
|
||||
|
|
|
@ -66,16 +66,6 @@ public class PacketHandler extends ChannelDuplexHandler {
|
|||
if (packet.getClass().getSimpleName().equalsIgnoreCase("PacketPlayInUseEntity")) {
|
||||
ServerboundInteractPacket pk = (ServerboundInteractPacket) packet;
|
||||
int entityID = (int) Util.getFieldValue(packet, "a");
|
||||
// if (pk.getType() == ServerboundInteractPacket.Action.INTERACT) {
|
||||
// Entity entity = ((CraftWorld) player.getWorld()).getHandle().getEntity(entityID);
|
||||
// if (entity == null) return;
|
||||
// if (entity instanceof ArmorStand) {
|
||||
// Bukkit.getPluginManager().callEvent(new InteractHologramEvent(player, entity));
|
||||
// }
|
||||
// if (NPCManager.isNPC(entity)) {
|
||||
// Bukkit.getPluginManager().callEvent(new RightClickNPCEvent(player, entity));
|
||||
// }
|
||||
// }
|
||||
boolean sneak = (boolean) Util.getFieldValue(packet, "c");
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(NullValkyrie.getPlugin(NullValkyrie.class), () -> {
|
||||
net.minecraft.world.entity.decoration.ArmorStand[] stands = PerPlayerHologram.getHolograms().get(entityID);
|
||||
|
@ -86,18 +76,15 @@ public class PacketHandler extends ChannelDuplexHandler {
|
|||
}
|
||||
}, 0);
|
||||
Object data = Util.getFieldValue(pk, "b");
|
||||
if (data.toString().split("\\$")[1].charAt(0) == 'e')
|
||||
return;
|
||||
if (data.toString().split("\\$")[1].charAt(0) == 'e') return;
|
||||
try {
|
||||
Object hand = Util.getFieldValue(data, "a");
|
||||
if (!hand.toString().equals("MAIN_HAND")) return;
|
||||
ServerPlayer npc = NPCManager.getNPC(entityID);
|
||||
if (npc == null) return;
|
||||
//Right Click
|
||||
for (ServerPlayer npcs : NPCManager.getNPCs().values()) {
|
||||
if (npcs.getBukkitEntity().getEntityId() == entityID && sneak) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(NullValkyrie.getPlugin(NullValkyrie.class), () -> Bukkit.getPluginManager().callEvent(new RightClickNPCEvent(player, npcs)), 0);
|
||||
|
||||
}
|
||||
}
|
||||
if (npc.getBukkitEntity().getEntityId() == entityID && sneak)
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(NullValkyrie.getPlugin(NullValkyrie.class), () -> Bukkit.getPluginManager().callEvent(new RightClickNPCEvent(player, npc)), 0);
|
||||
} catch (NoSuchFieldException x) {
|
||||
//Left Click
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue