organisation and hologram interaction
This commit is contained in:
parent
f8d85374c9
commit
8441c06a17
19 changed files with 495 additions and 454 deletions
|
@ -2,12 +2,14 @@ package me.night.nullvalkyrie;
|
||||||
|
|
||||||
import com.mongodb.client.MongoDatabase;
|
import com.mongodb.client.MongoDatabase;
|
||||||
import io.github.cdimascio.dotenv.Dotenv;
|
import io.github.cdimascio.dotenv.Dotenv;
|
||||||
|
import me.night.nullvalkyrie.events.listeners.CustomItemEvents;
|
||||||
|
import me.night.nullvalkyrie.events.listeners.DamageEffectEvents;
|
||||||
|
import me.night.nullvalkyrie.events.listeners.NPCEvents;
|
||||||
|
import me.night.nullvalkyrie.events.listeners.ServerEvents;
|
||||||
import me.night.nullvalkyrie.ui.inventory.InventoryListener;
|
import me.night.nullvalkyrie.ui.inventory.InventoryListener;
|
||||||
import me.night.nullvalkyrie.database.NPCDataManager;
|
import me.night.nullvalkyrie.database.NPCDataManager;
|
||||||
import me.night.nullvalkyrie.discord.DiscordClientManager;
|
import me.night.nullvalkyrie.discord.DiscordClientManager;
|
||||||
import me.night.nullvalkyrie.enchantments.EnchantmentManager;
|
import me.night.nullvalkyrie.enchantments.EnchantmentManager;
|
||||||
import me.night.nullvalkyrie.events.*;
|
|
||||||
import me.night.nullvalkyrie.npc.*;
|
|
||||||
import me.night.nullvalkyrie.ui.ScoreboardListener;
|
import me.night.nullvalkyrie.ui.ScoreboardListener;
|
||||||
import me.night.nullvalkyrie.util.*;
|
import me.night.nullvalkyrie.util.*;
|
||||||
import me.night.nullvalkyrie.commands.*;
|
import me.night.nullvalkyrie.commands.*;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package me.night.nullvalkyrie.commands;
|
package me.night.nullvalkyrie.commands;
|
||||||
|
|
||||||
import me.night.nullvalkyrie.database.RankDataManager;
|
import me.night.nullvalkyrie.database.RankDataManager;
|
||||||
import me.night.nullvalkyrie.ui.Rank;
|
import me.night.nullvalkyrie.enums.Rank;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static me.night.nullvalkyrie.npc.NPCManager.*;
|
import static me.night.nullvalkyrie.entities.npcs.NPCManager.*;
|
||||||
|
|
||||||
|
|
||||||
public class NPCDataManager {
|
public class NPCDataManager {
|
||||||
|
|
|
@ -2,7 +2,7 @@ package me.night.nullvalkyrie.database;
|
||||||
|
|
||||||
import com.mongodb.client.MongoCursor;
|
import com.mongodb.client.MongoCursor;
|
||||||
import com.mongodb.client.model.Filters;
|
import com.mongodb.client.model.Filters;
|
||||||
import me.night.nullvalkyrie.ui.Rank;
|
import me.night.nullvalkyrie.enums.Rank;
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.bson.conversions.Bson;
|
import org.bson.conversions.Bson;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package me.night.nullvalkyrie.npc;
|
package me.night.nullvalkyrie.entities.npcs;
|
||||||
|
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import com.mojang.authlib.properties.Property;
|
import com.mojang.authlib.properties.Property;
|
|
@ -1,4 +1,4 @@
|
||||||
package me.night.nullvalkyrie.npc;
|
package me.night.nullvalkyrie.entities.npcs;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
|
@ -11,8 +11,8 @@ import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
public class Skin {
|
public class Skin {
|
||||||
private String texture;
|
private final String texture;
|
||||||
private String signature;
|
private final String signature;
|
||||||
public Skin(String texture, String signature) {
|
public Skin(String texture, String signature) {
|
||||||
this.texture = texture;
|
this.texture = texture;
|
||||||
this.signature = signature;
|
this.signature = signature;
|
|
@ -1,4 +1,4 @@
|
||||||
package me.night.nullvalkyrie.ui;
|
package me.night.nullvalkyrie.enums;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package me.night.nullvalkyrie.items;
|
package me.night.nullvalkyrie.enums;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
public enum Rarity {
|
public enum Rarity {
|
||||||
|
@ -23,25 +23,16 @@ public enum Rarity {
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
public static Rarity getRarity(String str) {
|
public static Rarity getRarity(String str) {
|
||||||
switch(str) {
|
return switch (str) {
|
||||||
case "COMMON":
|
case "COMMON" -> COMMON;
|
||||||
return COMMON;
|
case "UNCOMMON" -> UNCOMMON;
|
||||||
case "UNCOMMON":
|
case "RARE" -> RARE;
|
||||||
return UNCOMMON;
|
case "EPIC" -> EPIC;
|
||||||
case "RARE":
|
case "LEGENDARY" -> LEGENDARY;
|
||||||
return RARE;
|
case "MYTHIC" -> MYTHIC;
|
||||||
case "EPIC":
|
case "ULTRA" -> ULTRA;
|
||||||
return EPIC;
|
case "GRAND" -> GRAND;
|
||||||
case "LEGENDARY":
|
default -> COMMON;
|
||||||
return LEGENDARY;
|
};
|
||||||
case "MYTHIC":
|
|
||||||
return MYTHIC;
|
|
||||||
case "ULTRA":
|
|
||||||
return ULTRA;
|
|
||||||
case "GRAND":
|
|
||||||
return GRAND;
|
|
||||||
default:
|
|
||||||
return COMMON;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package me.night.nullvalkyrie.events.custom;
|
||||||
|
|
||||||
|
import org.bukkit.entity.ArmorStand;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
public class InteractHologramEvent extends Event implements Cancellable {
|
||||||
|
private boolean isCancelled;
|
||||||
|
public Player player;
|
||||||
|
public ArmorStand hologram;
|
||||||
|
private static final HandlerList HANDLERS = new HandlerList();
|
||||||
|
public InteractHologramEvent(Player player, ArmorStand hologram) {
|
||||||
|
this.player = player;
|
||||||
|
this.hologram = hologram;
|
||||||
|
}
|
||||||
|
public Player getPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
public ArmorStand getHologram() {
|
||||||
|
return hologram;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return isCancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
isCancelled = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return HANDLERS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() { return HANDLERS; }
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package me.night.nullvalkyrie.npc;
|
package me.night.nullvalkyrie.events.custom;
|
||||||
|
|
||||||
import net.minecraft.server.level.EntityPlayer;
|
import net.minecraft.server.level.EntityPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -7,12 +7,12 @@ import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class RightClickNPC extends Event implements Cancellable {
|
public class RightClickNPCEvent extends Event implements Cancellable {
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final EntityPlayer npc;
|
private final EntityPlayer npc;
|
||||||
private boolean isCancelled;
|
private boolean isCancelled;
|
||||||
private static final HandlerList HANDLERS = new HandlerList();
|
private static final HandlerList HANDLERS = new HandlerList();
|
||||||
public RightClickNPC(Player player, EntityPlayer npc) {
|
public RightClickNPCEvent(Player player, EntityPlayer npc) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.npc = npc;
|
this.npc = npc;
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package me.night.nullvalkyrie.events;
|
package me.night.nullvalkyrie.events.listeners;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
|
@ -7,7 +7,7 @@ import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
import com.comphenix.protocol.wrappers.BlockPosition;
|
||||||
import me.night.nullvalkyrie.items.CustomItemManager;
|
import me.night.nullvalkyrie.items.CustomItemManager;
|
||||||
import me.night.nullvalkyrie.items.Pickaxe;
|
import me.night.nullvalkyrie.items.Pickaxe;
|
||||||
import me.night.nullvalkyrie.items.Rarity;
|
import me.night.nullvalkyrie.enums.Rarity;
|
||||||
import me.night.nullvalkyrie.Main;
|
import me.night.nullvalkyrie.Main;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
@ -158,8 +158,7 @@ public class CustomItemEvents implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityShoot(EntityShootBowEvent e) {
|
public void onEntityShoot(EntityShootBowEvent e) {
|
||||||
if (e.getProjectile() instanceof Arrow) {
|
if (e.getProjectile() instanceof Arrow) {
|
||||||
if (e.getEntity() instanceof Player) {
|
if (e.getEntity() instanceof Player player) {
|
||||||
Player player = (Player) e.getEntity();
|
|
||||||
if (player.getInventory().getItemInMainHand().getItemMeta() != null) {
|
if (player.getInventory().getItemInMainHand().getItemMeta() != null) {
|
||||||
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
||||||
if (name.equalsIgnoreCase(Rarity.MYTHIC.getColor() + "Terminator")) {
|
if (name.equalsIgnoreCase(Rarity.MYTHIC.getColor() + "Terminator")) {
|
||||||
|
@ -174,8 +173,7 @@ public class CustomItemEvents implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onProjectileHit(ProjectileHitEvent e) {
|
public void onProjectileHit(ProjectileHitEvent e) {
|
||||||
if (e.getEntity().getShooter() instanceof Player) {
|
if (e.getEntity().getShooter() instanceof Player shooter) {
|
||||||
Player shooter = (Player) e.getEntity().getShooter();
|
|
||||||
if (shooter.getInventory().getItemInMainHand().getItemMeta() != null) {
|
if (shooter.getInventory().getItemInMainHand().getItemMeta() != null) {
|
||||||
String name = shooter.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
String name = shooter.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
||||||
if (name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Frag Grenade")) {
|
if (name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Frag Grenade")) {
|
||||||
|
@ -207,8 +205,7 @@ public class CustomItemEvents implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void Projectile(ProjectileLaunchEvent e) {
|
public void Projectile(ProjectileLaunchEvent e) {
|
||||||
if (e.getEntity().getShooter() instanceof Player) {
|
if (e.getEntity().getShooter() instanceof Player player) {
|
||||||
Player player = (Player) e.getEntity().getShooter();
|
|
||||||
if (player.getInventory().getItemInMainHand().getItemMeta() != null) {
|
if (player.getInventory().getItemInMainHand().getItemMeta() != null) {
|
||||||
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName();
|
||||||
if (name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Frag Grenade")) {
|
if (name.equalsIgnoreCase(Rarity.LEGENDARY.getColor() + "Frag Grenade")) {
|
||||||
|
@ -312,13 +309,6 @@ public class CustomItemEvents implements Listener {
|
||||||
p.openMerchant(merchant, true);
|
p.openMerchant(merchant, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// For hologram clicks to change page
|
|
||||||
// @EventHandler
|
|
||||||
// public void onEntityInteract(EntityInteractEvent e) {
|
|
||||||
// System.out.println(e.getEntity().getLocation());
|
|
||||||
// e.getEntity().setCustomName(ChatColor.RED + "Changed name since you ust clicked lol");
|
|
||||||
// }
|
|
||||||
private final HashMap<Location, Integer> blockStages = new HashMap<>();
|
private final HashMap<Location, Integer> blockStages = new HashMap<>();
|
||||||
private final HashMap<UUID, Long> miningCooldown = new HashMap<>();
|
private final HashMap<UUID, Long> miningCooldown = new HashMap<>();
|
||||||
@EventHandler
|
@EventHandler
|
|
@ -1,4 +1,4 @@
|
||||||
package me.night.nullvalkyrie.events;
|
package me.night.nullvalkyrie.events.listeners;
|
||||||
|
|
||||||
import me.night.nullvalkyrie.Main;
|
import me.night.nullvalkyrie.Main;
|
||||||
import me.night.nullvalkyrie.util.Util;
|
import me.night.nullvalkyrie.util.Util;
|
|
@ -1,5 +1,7 @@
|
||||||
package me.night.nullvalkyrie.npc;
|
package me.night.nullvalkyrie.events.listeners;
|
||||||
|
|
||||||
|
import me.night.nullvalkyrie.events.custom.RightClickNPCEvent;
|
||||||
|
import me.night.nullvalkyrie.entities.npcs.NPCManager;
|
||||||
import me.night.nullvalkyrie.util.Util;
|
import me.night.nullvalkyrie.util.Util;
|
||||||
import net.minecraft.network.protocol.game.PacketPlayOutEntity;
|
import net.minecraft.network.protocol.game.PacketPlayOutEntity;
|
||||||
import net.minecraft.network.protocol.game.PacketPlayOutEntityHeadRotation;
|
import net.minecraft.network.protocol.game.PacketPlayOutEntityHeadRotation;
|
||||||
|
@ -13,7 +15,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
public class NPCEvents implements Listener {
|
public class NPCEvents implements Listener {
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onClick(RightClickNPC e) {
|
public void onClick(RightClickNPCEvent e) {
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
if (e.getNPC().getBukkitEntity().getName().equalsIgnoreCase(Util.color("&1&lRB18"))) {
|
if (e.getNPC().getBukkitEntity().getName().equalsIgnoreCase(Util.color("&1&lRB18"))) {
|
||||||
player.sendMessage(Util.color("Hi"));
|
player.sendMessage(Util.color("Hi"));
|
|
@ -1,6 +1,7 @@
|
||||||
package me.night.nullvalkyrie.events;
|
package me.night.nullvalkyrie.events.listeners;
|
||||||
|
|
||||||
import me.night.nullvalkyrie.npc.PacketInjector;
|
import me.night.nullvalkyrie.events.custom.InteractHologramEvent;
|
||||||
|
import me.night.nullvalkyrie.packets.PacketInjector;
|
||||||
import me.night.nullvalkyrie.util.Util;
|
import me.night.nullvalkyrie.util.Util;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
@ -37,6 +38,11 @@ public class ServerEvents implements Listener {
|
||||||
} catch (Exception ee) {
|
} catch (Exception ee) {
|
||||||
ee.printStackTrace();
|
ee.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@EventHandler
|
||||||
|
public void onClickHologram(InteractHologramEvent e) {
|
||||||
|
if (e.getHologram().getCustomName().equals(ChatColor.GOLD + "Click me to change!!!")) {
|
||||||
|
System.out.println(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package me.night.nullvalkyrie.items;
|
package me.night.nullvalkyrie.items;
|
||||||
|
|
||||||
import me.night.nullvalkyrie.Main;
|
import me.night.nullvalkyrie.Main;
|
||||||
|
import me.night.nullvalkyrie.enums.Rarity;
|
||||||
import me.night.nullvalkyrie.util.Util;
|
import me.night.nullvalkyrie.util.Util;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
@ -13,8 +14,6 @@ import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.persistence.PersistentDataContainer;
|
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -102,7 +101,6 @@ public class CustomItemManager {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void setItemRecipe(NamespacedKey key, ItemStack i, int ingredient, String shape1, String shape2, String shape3, List<Material> ingredients) {
|
public static void setItemRecipe(NamespacedKey key, ItemStack i, int ingredient, String shape1, String shape2, String shape3, List<Material> ingredients) {
|
||||||
// ShapedRecipe wither_sword_recipe = new ShapedRecipe(new NamespacedKey(main, "widow_sword"), widow_sword);
|
// ShapedRecipe wither_sword_recipe = new ShapedRecipe(new NamespacedKey(main, "widow_sword"), widow_sword);
|
||||||
// wither_sword_recipe.shape(" A ", " A "," B ");
|
// wither_sword_recipe.shape(" A ", " A "," B ");
|
||||||
|
@ -111,20 +109,6 @@ public class CustomItemManager {
|
||||||
// Bukkit.addRecipe(wither_sword_recipe);
|
// Bukkit.addRecipe(wither_sword_recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static YamlConfiguration loadConfig(String path) {
|
|
||||||
File f = new File(Main.getPlugin(Main.class).getDataFolder(), path);
|
|
||||||
if (!f.exists()) {
|
|
||||||
try {
|
|
||||||
f.createNewFile();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return YamlConfiguration.loadConfiguration(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void updateYamlFilesToPlugin(String path) {
|
public static void updateYamlFilesToPlugin(String path) {
|
||||||
File file = new File(Main.getPlugin(Main.class).getDataFolder(), path);
|
File file = new File(Main.getPlugin(Main.class).getDataFolder(), path);
|
||||||
if (!file.exists()) Main.getPlugin(Main.class).saveResource(path, true);
|
if (!file.exists()) Main.getPlugin(Main.class).saveResource(path, true);
|
||||||
|
|
|
@ -1,47 +1,70 @@
|
||||||
package me.night.nullvalkyrie.npc;
|
package me.night.nullvalkyrie.packets;
|
||||||
|
|
||||||
import io.netty.channel.ChannelDuplexHandler;
|
import io.netty.channel.ChannelDuplexHandler;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.ChannelPromise;
|
import io.netty.channel.ChannelPromise;
|
||||||
import me.night.nullvalkyrie.Main;
|
import me.night.nullvalkyrie.Main;
|
||||||
|
import me.night.nullvalkyrie.entities.npcs.NPCManager;
|
||||||
|
import me.night.nullvalkyrie.events.custom.InteractHologramEvent;
|
||||||
|
import me.night.nullvalkyrie.events.custom.RightClickNPCEvent;
|
||||||
import net.minecraft.network.protocol.game.PacketPlayInUseEntity;
|
import net.minecraft.network.protocol.game.PacketPlayInUseEntity;
|
||||||
import net.minecraft.server.level.EntityPlayer;
|
import net.minecraft.server.level.EntityPlayer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.ArmorStand;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
public class PacketHandler extends ChannelDuplexHandler {
|
public class PacketHandler extends ChannelDuplexHandler {
|
||||||
private final Player player;
|
private final Player player;
|
||||||
|
|
||||||
public PacketHandler(Player player) {
|
public PacketHandler(Player player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
|
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
|
||||||
super.write(ctx, msg, promise);
|
super.write(ctx, msg, promise);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void channelRead(ChannelHandlerContext c, Object packet) throws Exception {
|
public void channelRead(ChannelHandlerContext c, Object packet) throws Exception {
|
||||||
if (packet.getClass().getSimpleName().equalsIgnoreCase("PacketPlayInUseEntity")) {
|
if (packet.getClass().getSimpleName().equalsIgnoreCase("PacketPlayInUseEntity")) {
|
||||||
PacketPlayInUseEntity pk = (PacketPlayInUseEntity) packet;
|
PacketPlayInUseEntity pk = (PacketPlayInUseEntity) packet;
|
||||||
int entityID = (int) PacketInjector.getFieldValue(packet, "a");
|
int entityID = (int) PacketInjector.getFieldValue(packet, "a");
|
||||||
boolean sneak = (boolean) PacketInjector.getFieldValue(packet, "c");
|
boolean sneak = (boolean) PacketInjector.getFieldValue(packet, "c");
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getPlugin(Main.class), new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for (Entity entity : Bukkit.getWorld("world").getEntities()) {
|
||||||
|
if (entity.getEntityId() == entityID && entity.getType() == EntityType.ARMOR_STAND){
|
||||||
|
Bukkit.getPluginManager().callEvent(new InteractHologramEvent(player, (ArmorStand) entity));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
|
||||||
Field type = pk.getClass().getDeclaredField("b");
|
Field type = pk.getClass().getDeclaredField("b");
|
||||||
type.setAccessible(true);
|
type.setAccessible(true);
|
||||||
Object data = type.get(pk);
|
Object data = type.get(pk);
|
||||||
if (data.toString().split("\\$")[1].charAt(0) == 'e') { return; }
|
if (data.toString().split("\\$")[1].charAt(0) == 'e') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
Field hand = data.getClass().getDeclaredField("a");
|
Field hand = data.getClass().getDeclaredField("a");
|
||||||
hand.setAccessible(true);
|
hand.setAccessible(true);
|
||||||
if (!hand.get(data).toString().equals("MAIN_HAND")) { return; }
|
if (!hand.get(data).toString().equals("MAIN_HAND")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
//Right Click
|
//Right Click
|
||||||
for (EntityPlayer npcs : NPCManager.getNPCs()) {
|
for (EntityPlayer npcs : NPCManager.getNPCs()) {
|
||||||
if (npcs.ae() == entityID && sneak) {
|
if (npcs.ae() == entityID && sneak) {
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getPlugin(Main.class), new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getPlugin(Main.class), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Bukkit.getPluginManager().callEvent(new RightClickNPC(player, npcs));
|
Bukkit.getPluginManager().callEvent(new RightClickNPCEvent(player, npcs));
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package me.night.nullvalkyrie.npc;
|
package me.night.nullvalkyrie.packets;
|
||||||
|
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import net.minecraft.server.level.EntityPlayer;
|
import net.minecraft.server.level.EntityPlayer;
|
|
@ -1,6 +1,7 @@
|
||||||
package me.night.nullvalkyrie.ui;
|
package me.night.nullvalkyrie.ui;
|
||||||
|
|
||||||
import me.night.nullvalkyrie.database.RankDataManager;
|
import me.night.nullvalkyrie.database.RankDataManager;
|
||||||
|
import me.night.nullvalkyrie.enums.Rank;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scoreboard.*;
|
import org.bukkit.scoreboard.*;
|
||||||
|
|
|
@ -2,7 +2,8 @@ package me.night.nullvalkyrie.ui;
|
||||||
|
|
||||||
import me.night.nullvalkyrie.Main;
|
import me.night.nullvalkyrie.Main;
|
||||||
import me.night.nullvalkyrie.database.RankDataManager;
|
import me.night.nullvalkyrie.database.RankDataManager;
|
||||||
import me.night.nullvalkyrie.npc.NPCManager;
|
import me.night.nullvalkyrie.enums.Rank;
|
||||||
|
import me.night.nullvalkyrie.entities.npcs.NPCManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
Loading…
Reference in a new issue