Compare commits

..

No commits in common. "0368b5f86f553ccb5aefd8b65b45bd4aedbe80f7" and "ddd2786606b945951c0442a2f68b506d0b033aeb" have entirely different histories.

44 changed files with 845 additions and 1053 deletions

1111
LICENSE

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
# NullValkyrie
NullValkyrie is multipurpose Minecraft plugin with a lot of features where most modern servers have.
Welcome to the NullValkyrie repository! This project is designed to a multipurpose plugin with a lot of cool features which most of the modern servers have.
## Features
@ -14,7 +14,7 @@ NullValkyrie is multipurpose Minecraft plugin with a lot of features where most
## Getting Started
To get started with the project, simply clone the repository and install the dependencies using Maven:
To get started with NullValkyrie, simply clone the repository and install the dependencies using Maven:
```cmd
git clone https://github.com/night0721/NullValkyrie.git
@ -26,13 +26,17 @@ Then, you can add the plugin to your plugin folder and start the server to use i
## Support
If you need support, you can join the [Discord server](https://discord.gg/SbQHChmGcp) or DM me on Discord: night.dev
If you need support, you can join the Discord server: https://discord.gg/qTfXU3yuuN or DM me on Discord: Ń1ght#4004
## License
NullValkyrie is licensed under the GNU Public License v3.0. See [LICENSE](https://github.com/night0721/NullValkyrie/blob/master/LICENSE) for more information.
NullValkyrie is licensed under the CC-BY-NC-SA-4.0. See [LICENSE](https://github.com/night0721/NullValkyrie/blob/master/LICENSE) for more information.
## Credits
- [night0721] - Discord: Ń1ght#4004
## Contribution
If you have any ideas for improvements or new features, please feel free to fork the project and create a pull request or open an issue.
We welcome contributions to the NullValkyrie project! If you have any ideas for improvements or new features, please feel free to fork the project and create a pull request or open an issue.
All contributions are welcome, including translations, documentation, and code.

12
pom.xml
View file

@ -6,7 +6,7 @@
<groupId>me.night</groupId>
<artifactId>NullValkyrie</artifactId>
<version>1.1.1</version>
<version>1.1.02</version>
<packaging>jar</packaging>
<name>NullValkyrie</name>
@ -67,9 +67,9 @@
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:1.19.2-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<srgIn>org.spigotmc:minecraft-server:1.19.3-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:1.19.2-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
<remappedDependencies>org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
@ -82,8 +82,8 @@
<id>remap-spigot</id>
<configuration>
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar</inputFile>
<srgIn>org.spigotmc:minecraft-server:1.19.2-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:1.19.2-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
<srgIn>org.spigotmc:minecraft-server:1.19.3-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT:jar:remapped-obf</remappedDependencies>
</configuration>
</execution>
</executions>
@ -115,7 +115,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version>
<version>1.19.3-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>

100
src/main/java/IDEAS Normal file
View file

@ -0,0 +1,100 @@
A teleportation plugin that allows players to easily and quickly travel to different locations on the server.
A rewards system that gives players rewards for reaching certain milestones, such as reaching a certain level or completing specific tasks.
A custom enchantments plugin that allows players to add unique enchantments to their gear.
A custom crafting system that adds new recipes and allows players to create unique items.
A minigame plugin that adds fun, engaging minigames for players to enjoy.
A player-run economy plugin that allows players to trade and sell items with one another.
A chat enhancement plugin that adds fun emotes, chat formatting options, and other features to improve the chat experience.
A pet plugin that allows players to tame and care for their own pets.
A player-run shop plugin that allows players to create their own shops and sell items to other players.
A dungeon generator plugin that randomly generates challenging dungeon experiences for players to explore.
A chat enhancement plugin that allows players to use custom emotes and chat formatting.
A teleportation plugin that allows players to set and teleport to waypoints.
A death tracker plugin that keeps track of how many times a player has died and displays it in chat.
A farming plugin that makes it easier for players to plant and grow crops.
A minigame plugin that adds new games for players to play, such as parkour challenges or capture the flag.
A voting plugin that allows players to vote on different options, such as which game mode to play next or which map to use.
A recipe book plugin that allows players to access a comprehensive list of all the crafting recipes in the game.
An economy plugin that adds a virtual currency and trading system to the game, allowing players to buy and sell items with one another.
A permissions plugin that allows server administrators to manage player permissions and control who can do what on the server.
A game mode plugin that adds new game modes, such as creative mode or adventure mode, for players to choose from.
A dungeon generation plugin that automatically generates new dungeon structures for players to explore and conquer.
A parkour plugin that adds new parkour maps and challenges for players to complete.
A mob spawning control plugin that allows players to customize mob spawning behavior on the server.
A music plugin that allows players to play music in-game using note blocks.
A custom crafting plugin that allows players to create their own custom crafting recipes.
A loot table editor plugin that allows players to customize the loot that mobs drop when they are killed.
A scoreboard plugin that allows players to create and customize their own in-game scoreboard.
A grief prevention plugin that allows players to protect their builds from being destroyed by other players.
A teleport request plugin that allows players to request teleportations to other players and requires the other player to accept the request before the teleportation occurs.
A weather control plugin that allows players to change the weather on the server, such as making it rain or clearing up the skies.
A plugin that adds new types of blocks, items, or mobs to the game.
A plugin that allows players to create and customize their own in-game homes or shops.
A plugin that introduces a new type of game mechanic, such as a crafting system or a trading system.
A plugin that adds new mini-games or challenges for players to complete.
A plugin that allows players to use custom skins or textures for their characters.
A plugin that introduces a new level of difficulty for players to experience, such as a "hardcore" mode.
A plugin that adds new, themed environments for players to explore, such as a jungle or a desert.
A plugin that allows players to create and manage their own in-game economy, with the ability to buy and sell items with each other.
A plugin that introduces new forms of transportation, such as minecart rail networks or boats.
A plugin that allows players to create and customize their own in-game maps, which can be shared with other players.
A plugin that allows players to create and customize their own in-game characters, including appearance, abilities, and stats.
A plugin that introduces new forms of combat, such as ranged weapons or magic spells.
A plugin that adds new dungeons or boss battles for players to challenge.
A plugin that allows players to create and join different factions or clans, and compete against each other in in-game events or challenges.
A plugin that adds new biomes or dimensions for players to explore, such as a Nether or a End-like dimension.
A plugin that introduces new environmental hazards or challenges, such as weather effects or dangerous mobs.
A plugin that allows players to create and customize their own in-game weapons, armor, or tools.
A plugin that adds new types of crops, food, or farming tools for players to use.
A plugin that allows players to create and customize their own in-game quests or objectives, which can be shared with other players.
A plugin that introduces new forms of transportation, such as flying mounts or teleportation spells.
A plugin that adds new forms of currency, such as virtual coins or tokens, which players can earn and spend in-game.
A plugin that introduces new forms of resource gathering or processing, such as mining, smelting, or crafting.
A plugin that allows players to create and customize their own in-game shops or markets, where they can buy and sell items with each other.
A plugin that adds new challenges or events for players to participate in, such as races, tournaments, or scavenger hunts.
A plugin that allows players to create and customize their own in-game pets or companions, which can provide various benefits or abilities.
A plugin that adds new environmental effects, such as day/night cycles or changing seasons.
A plugin that allows players to create and customize their own in-game vehicles, such as cars, planes, or boats.
A plugin that introduces new forms of player-versus-player (PvP) combat, such as team battles or capture the flag.
A plugin that allows players to create and customize their own in-game skills or abilities, which can be leveled up and improved over time.
A plugin that adds new types of terrain or structures for players to explore, such as caves, ruins, or abandoned buildings.
A player teleportation plugin
A plugin that adds custom crafting recipes
A plugin that adds new types of enemies and boss battles
A plugin that allows players to create and join guilds
A plugin that adds new types of weapons and armor
A plugin that allows players to create and customize their own houses
A plugin that adds a quest and adventure system
A plugin that adds new types of biomes and dimensions
A plugin that allows players to ride and breed different types of horses
A plugin that adds new types of crops and plants for players to farm
A plugin that allows players to fish and cook different types of food
A plugin that adds new types of pets and companions for players to tame
A plugin that allows players to create and customize their own NPC characters
A plugin that adds new types of weather and environmental effects
A plugin that allows players to craft and use magic spells
A plugin that adds new types of transportation, such as minecarts or boats
A plugin that allows players to build and customize their own vehicles
A plugin that adds new types of trades and professions for players to pursue
A plugin that allows players to play mini-games and challenges with other players
A plugin that adds new types of items and resources for players to collect and use.
A plugin that adds a new type of energy system for players to manage and use
A plugin that allows players to build and customize their own multi-block structures
A plugin that adds new types of dimensions, each with their own unique features and challenges
A plugin that allows players to build and customize their own custom weapons and armor
A plugin that adds new types of resources, such as ores, gems, and fluids, that players can extract and use
A plugin that allows players to create and customize their own custom enchantments and potion effects
A plugin that adds new types of machines and technology for players to build and use
A plugin that allows players to create and customize their own custom items and blocks
A plugin that adds new types of hazards and challenges, such as natural disasters or enemy attacks, for players to face
A plugin that allows players to build and customize their own transportation networks, such as railways or highways
A plugin that adds new types of terrain and landscape features, such as caves, ravines, and mountains
A plugin that allows players to create and customize their own custom game modes and rules
A plugin that adds new types of interactive objects and mechanisms for players to use and explore
A plugin that allows players to build and customize their own custom AI entities, such as guards or pets
A plugin that adds new types of environmental effects and physics, such as dynamic lighting or water simulation
A plugin that allows players to create and customize their own custom dimension and world generation settings
A plugin that adds new types of resources and materials for players to collect and use in their builds
A plugin that allows players to create and customize their own custom multiplayer game modes and rules
A plugin that adds new types of challenges and rewards for players to earn and unlock
A plugin that allows players to create and customize their own custom adventure maps and scenarios.

View file

@ -1,8 +1,7 @@
package me.night.nullvalkyrie;
import me.night.nullvalkyrie.entities.miners.CryptoMiner;
import me.night.nullvalkyrie.events.listeners.*;
import me.night.nullvalkyrie.game.tasks.AlwaysDayTask;
import me.night.nullvalkyrie.tasks.AlwaysDayTask;
import me.night.nullvalkyrie.ui.inventory.InventoryListener;
import me.night.nullvalkyrie.database.NPCDataManager;
import me.night.nullvalkyrie.discord.DiscordClientManager;
@ -13,7 +12,9 @@ import me.night.nullvalkyrie.database.DatabaseManager;
import org.bukkit.*;
import org.bukkit.plugin.java.JavaPlugin;
public final class NullValkyrie extends JavaPlugin {
public final class Main extends JavaPlugin {
@Override
public void onEnable() {
EnchantmentManager.register();
@ -24,25 +25,9 @@ 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 CustomEvents(), this);
Bukkit.getPluginManager().registerEvents(new NPCEvents(), this);
new DiscordClientManager();
NPCDataManager.reloadNPC();
CryptoMiner.reloadMiner();
new AlwaysDayTask().runTaskTimer(this, 0, 100);
}
}
// TODO: Add corpse body when player dies
// TODO: vault to store item
// TODO: withdraw command
// TODO: deposit command
// TODO: add more items using player heads, scraping textures from https://www.freshcoal.com/search.php
// TODO: custom recipes using exactChoice
// TODO: pets using player heads, giving abilities to player
// TODO: market command to show items a player is selling
// TODO: custom model data on block, such as mithril ore to mine
// TODO: skills and abilities system
// TODO: auto generated mobs in dungeons
// TODO: rewards when reached milestones, quests
// TODO: teleportation to different places, to different npcs, hub
// TODO: using pdc to store quests, skills, abilities, etc
// TODO: guilds

View file

@ -1,9 +1,10 @@
package me.night.nullvalkyrie.commands;
import me.night.nullvalkyrie.entities.npcs.NPCManager;
import me.night.nullvalkyrie.entities.pets.ZombiePet;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@ -33,6 +34,7 @@ public class BetaCommand extends Command {
itemMeta2.setCustomModelData(1010101);
item2.setItemMeta(itemMeta2);
player.getInventory().addItem(item2);
NPCManager.createNPC(player, args[0]);
}
}

View file

@ -18,6 +18,5 @@ public class CommandManager {
new BetaCommand();
new MinerCommand();
new LuckyDrawCommand();
new NPCCommand();
}
}

View file

@ -1,8 +1,9 @@
package me.night.nullvalkyrie.commands;
import me.night.nullvalkyrie.entities.holograms.PerPlayerHologram;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import java.util.List;
@ -15,8 +16,16 @@ public class HologramCommand extends Command {
@Override
public void onCommand(CommandSender sender, String[] args) {
if (sender instanceof Player player) {
String[] ar = new String[]{ChatColor.AQUA + "Hi", ChatColor.DARK_PURPLE + "What", ChatColor.GOLD + "Hello World", ChatColor.GOLD + ChatColor.BOLD.toString() + "CLICK"};
new PerPlayerHologram(player, ar);
String[] ar = new String[]{ChatColor.AQUA + "Hi", ChatColor.DARK_PURPLE + "What", ChatColor.GOLD + "Hello World"};
Location location = player.getLocation();
for (String line : ar) {
ArmorStand stand = location.getWorld().spawn(location.subtract(0, 0.3, 0), ArmorStand.class);
stand.setVisible(false);
stand.setGravity(false);
stand.setInvulnerable(true);
stand.setCustomNameVisible(true);
stand.setCustomName(line);
}
}
}

View file

@ -2,7 +2,7 @@ package me.night.nullvalkyrie.commands;
import me.night.nullvalkyrie.database.MinerDataManager;
import me.night.nullvalkyrie.entities.miners.CryptoMiner;
import me.night.nullvalkyrie.entities.miners.MinerType;
import me.night.nullvalkyrie.enums.MinerType;
import me.night.nullvalkyrie.ui.inventory.Miner;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
@ -34,8 +34,8 @@ public class MinerCommand extends Command {
double rate = 0.4;
long time = System.currentTimeMillis();
assert type != null;
MinerDataManager.setMiner(name, type, level, rate, true, time, player.getLocation());
CryptoMiner miner = new CryptoMiner(name, type, level, rate, time, player.getLocation());
MinerDataManager.setMiner(name, type, level, rate, true, time);
CryptoMiner miner = new CryptoMiner(name, type, level, rate, time);
miner.spawn(player);
} else if (args[0].equalsIgnoreCase("claim")) {
MinerDataManager.setLastClaim(args[1]);

View file

@ -1,39 +0,0 @@
package me.night.nullvalkyrie.commands;
import me.night.nullvalkyrie.entities.npcs.NPCManager;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import java.util.ArrayList;
import java.util.List;
public class NPCCommand extends Command {
public NPCCommand() {
super("npc", new String[]{}, "NPCs", "");
}
@Override
public void onCommand(CommandSender sender, String[] args) {
if (sender instanceof Player player) {
if (args.length == 0) {
player.sendMessage(ChatColor.RED + "Invalid command");
return;
}
if (args[0].equalsIgnoreCase("new")) {
NPCManager.createNPC(player, args[1]);
}
}
}
@Override
public List<String> onTabComplete(CommandSender sender, String[] args) {
if (args.length == 1) {
List<String> cc = List.of("new", "list");
return StringUtil.copyPartialMatches(args[0], cc, new ArrayList<>());
}
return new ArrayList<>();
}
}

View file

@ -1,7 +1,7 @@
package me.night.nullvalkyrie.commands;
import me.night.nullvalkyrie.database.RankDataManager;
import me.night.nullvalkyrie.util.Rank;
import me.night.nullvalkyrie.enums.Rank;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;

View file

@ -1,6 +1,6 @@
package me.night.nullvalkyrie.commands;
import me.night.nullvalkyrie.NullValkyrie;
import me.night.nullvalkyrie.Main;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
@ -23,13 +23,13 @@ public class VanishCommand extends Command {
if (vanished.contains(player.getUniqueId())) {
vanished.remove(player.getUniqueId());
for (Player target : Bukkit.getOnlinePlayers()) {
target.showPlayer(NullValkyrie.getPlugin(NullValkyrie.class), player);
target.showPlayer(Main.getPlugin(Main.class), player);
}
player.sendMessage(ChatColor.GREEN + "You are now seen by people");
} else {
vanished.add(player.getUniqueId());
for (Player target : Bukkit.getOnlinePlayers()) {
target.hidePlayer(NullValkyrie.getPlugin(NullValkyrie.class), player);
target.hidePlayer(Main.getPlugin(Main.class), player);
}
player.sendMessage(ChatColor.GREEN + "You are now vanished");
}

View file

@ -2,16 +2,14 @@ package me.night.nullvalkyrie.database;
import com.mongodb.client.MongoCursor;
import me.night.nullvalkyrie.entities.miners.CryptoMiner;
import me.night.nullvalkyrie.entities.miners.MinerType;
import me.night.nullvalkyrie.enums.MinerType;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import java.util.HashMap;
public class MinerDataManager {
public static void setMiner(String name, MinerType type, int level, double rate, boolean enabled, long lastclaim, Location location) {
public static void setMiner(String name, MinerType type, int level, double rate, boolean enabled, long lastclaim) {
Document newDocument = new Document();
newDocument.put("ID", new DatabaseManager().getMinersDB().countDocuments() + 1);
newDocument.put("Name", name);
@ -20,9 +18,6 @@ public class MinerDataManager {
newDocument.put("Rate", rate);
newDocument.put("Enabled", enabled);
newDocument.put("LastClaim", lastclaim);
newDocument.put("x", location.getX());
newDocument.put("y", location.getY());
newDocument.put("z", location.getZ());
new DatabaseManager().getMinersDB().insertOne(newDocument);
}
@ -45,12 +40,20 @@ public class MinerDataManager {
return 0;
}
public static CryptoMiner getMiner(long id) {
Document doc = new DatabaseManager().getMinersDB().find(new Document("ID", id)).first();
if (doc != null) {
return new CryptoMiner(doc.getString("Name"), MinerType.getByName(doc.getString("Material")), doc.getInteger("Level"), doc.getDouble("Rate"), doc.getLong("LastClaim"));
}
return null;
}
public static HashMap<Long, CryptoMiner> getMiners() {
HashMap<Long, CryptoMiner> list = new HashMap<>();
try (MongoCursor<Document> cursor = new DatabaseManager().getMinersDB().find().cursor()) {
while (cursor.hasNext()) {
Document doc = cursor.next();
list.put(doc.getLong("ID"), new CryptoMiner(doc.getString("Name"), MinerType.getByName(doc.getString("Material")), doc.getInteger("Level"), doc.getDouble("Rate"), doc.getLong("LastClaim"), new Location(Bukkit.getWorld("world"), doc.getDouble("x"), doc.getDouble("y"), doc.getDouble("z"))));
list.put(doc.getLong("ID"), new CryptoMiner(doc.getString("Name"), MinerType.getByName(doc.getString("Material")), doc.getInteger("Level"), doc.getDouble("Rate"), doc.getLong("LastClaim")));
}
return list;
}

View file

@ -10,7 +10,7 @@ import java.util.List;
public class NPCDataManager {
public static void setNPC(String name, double x, double y, double z, int pitch, int yaw, String world, String texture, String signature) {
public static void setNPC(String name, int x, int y, int z, int pitch, int yaw, String world, String texture, String signature) {
Document document = new DatabaseManager().getNPCsDB().find(new Document("Name", name)).first();
if (document != null) {
System.out.println("A NPC with this name already exist");
@ -36,9 +36,9 @@ public class NPCDataManager {
Document document = cursor.next();
HashMap<String, Object> npc = new HashMap<>();
String name = document.getString("Name");
double x = document.getDouble("x");
double y = document.getDouble("y");
double z = document.getDouble("z");
int x = document.getInteger("x");
int y = document.getInteger("y");
int z = document.getInteger("z");
int pitch = document.getInteger("pitch");
int yaw = document.getInteger("yaw");
String world = document.getString("world");

View file

@ -1,7 +1,7 @@
package me.night.nullvalkyrie.database;
import com.mongodb.client.MongoCursor;
import me.night.nullvalkyrie.util.Rank;
import me.night.nullvalkyrie.enums.Rank;
import me.night.nullvalkyrie.ui.player.ScoreboardListener;
import org.bson.Document;
import org.bson.conversions.Bson;

View file

@ -8,39 +8,27 @@ import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.decoration.ArmorStand;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.Optional;
public class PerPlayerHologram {
public static HashMap<Integer, ArmorStand[]> holograms = new HashMap<>();
public PerPlayerHologram(Player player, String[] lines) {
spawnLine(player, lines);
double c = (lines.length) * 0.3 - 0.15;
for (String line : lines) {
spawnLine(player.getLocation().getY() + c, player, line);
c -= 0.3;
}
private void spawnLine(Player player, String[] lines) {
double c = (lines.length) * 0.3 - 0.8;
ArmorStand[] stands = new ArmorStand[lines.length];
for (int i = 0; i < lines.length; i++) {
}
private void spawnLine(double y, Player player, String line) {
ServerPlayer p = ((CraftPlayer) player).getHandle();
ArmorStand stand = new ArmorStand(p.getLevel(), player.getLocation().getX(), player.getLocation().getY() + c, player.getLocation().getZ());
ArmorStand stand = new ArmorStand(p.level, player.getLocation().getX(), y, player.getLocation().getZ());
stand.setInvisible(true);
new PacketPlayOutSpawnEntity(player, stand);
stands[i] = stand;
SynchedEntityData watcher = stand.getEntityData();
watcher.set(new EntityDataAccessor<>(2, EntityDataSerializers.OPTIONAL_COMPONENT), Optional.of(Component.nullToEmpty(lines[i])));
watcher.set(new EntityDataAccessor<>(2, EntityDataSerializers.OPTIONAL_COMPONENT), Optional.of(Component.nullToEmpty(line)));
watcher.set(new EntityDataAccessor<>(3, EntityDataSerializers.BOOLEAN), true);
new PacketPlayOutEntityMetadata(player, stand, watcher);
c -= 0.3;
if (lines.length == i + 1)
holograms.put(stand.getBukkitEntity().getEntityId(), stands);
}
}
public static HashMap<Integer, ArmorStand[]> getHolograms() {
return holograms;
new PacketPlayOutEntityMetadata(player, stand, watcher.getNonDefaultValues());
}
}

View file

@ -1,8 +1,8 @@
package me.night.nullvalkyrie.entities.items;
import me.night.nullvalkyrie.NullValkyrie;
import me.night.nullvalkyrie.Main;
import me.night.nullvalkyrie.database.CustomWeaponsDataManager;
import me.night.nullvalkyrie.entities.miners.Rarity;
import me.night.nullvalkyrie.enums.Rarity;
import me.night.nullvalkyrie.util.Util;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -84,7 +84,7 @@ public class CustomItemManager {
HashMap<String, Object> pdcdata = (HashMap<String, Object>) weapon.get("PDC");
for (String key : pdcdata.keySet()) {
PersistentDataContainer container = itemMeta.getPersistentDataContainer();
NamespacedKey key1 = new NamespacedKey(NullValkyrie.getPlugin(NullValkyrie.class), key);
NamespacedKey key1 = new NamespacedKey(Main.getPlugin(Main.class), key);
keys.put(Rarity.getRarity((String) weapon.get("Rarity")).getColor() + weapon.get("Name") + "." + key, key1);
container.set(key1, PersistentDataType.INTEGER, (int) pdcdata.get(key));
}
@ -103,7 +103,7 @@ public class CustomItemManager {
}
public static void setItemRecipe(String key, ItemStack i, List<String> shapes, HashMap<Character, Material> ingredients, int amount) {
NamespacedKey nsk = new NamespacedKey(NullValkyrie.getPlugin(NullValkyrie.class), key.replaceAll("\\s", ""));
NamespacedKey nsk = new NamespacedKey(Main.getPlugin(Main.class), key.replaceAll("\\s", ""));
ShapedRecipe recipe = new ShapedRecipe(nsk, i);
recipe.shape(shapes.get(0), shapes.get(1), shapes.get(2));
List<Character> abcs = List.of('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I');

View file

@ -2,62 +2,45 @@ package me.night.nullvalkyrie.entities.miners;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import com.mojang.datafixers.util.Pair;
import me.night.nullvalkyrie.NullValkyrie;
import me.night.nullvalkyrie.database.MinerDataManager;
import me.night.nullvalkyrie.packets.protocol.PacketPlayOutEntityMetadata;
import me.night.nullvalkyrie.enums.MinerType;
import me.night.nullvalkyrie.util.Skin;
import me.night.nullvalkyrie.util.Util;
import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket;
import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.decoration.ArmorStand;
import org.apache.commons.codec.binary.Base64;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_19_R1.CraftServer;
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_19_R2.CraftServer;
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom;
public class CryptoMiner {
protected String name;
protected MinerType type;
protected int level;
protected double rate;
protected final long lastclaim;
protected final double x;
protected final double y;
protected final double z;
protected final Location location;
public CryptoMiner(String name, MinerType type, int level, double rate, long lastclaim, Location location) {
public CryptoMiner(String name, MinerType type, int level, double rate, long lastclaim) {
this.name = name; // Name of the miner
this.type = type; // Type of the miner
this.level = level;
this.rate = rate; // Percentage generate chance in each tick 20tick per sec
this.lastclaim = lastclaim;
this.x = location.getX();
this.y = location.getY();
this.z = location.getZ();
this.location = location;
}
public String getName() {
@ -72,12 +55,16 @@ public class CryptoMiner {
return rate;
}
public void setRate(double rate) {
this.rate = rate;
}
public Material getType() {
return this.type.getMaterial();
}
public MinerType getMinerType() {
return this.type;
public void setType(MinerType type) {
this.type = type;
}
public int getLevel() {
@ -92,10 +79,6 @@ public class CryptoMiner {
return lastclaim;
}
public Location getLocation() {
return location;
}
public static void generate(int pp, int times) {
int generated = 0;
for (int counter = 0; counter < times; counter++) {
@ -104,21 +87,29 @@ public class CryptoMiner {
}
System.out.println(generated);
}
public void spawn(Player player) {
ArmorStand stand = new ArmorStand(((CraftWorld) this.getLocation().getWorld()).getHandle(), this.getLocation().getX() + 0.5, this.getLocation().getY(), this.getLocation().getZ() + 0.5);
stand.setInvulnerable(true);
Location loc = player.getLocation().getWorld().getBlockAt(player.getLocation()).getLocation().add(0.5, 0, 0.5);
if (player.getLocation().getWorld() == null) return;
ArmorStand stand = player.getLocation().getWorld().spawn(loc, ArmorStand.class);
stand.setGravity(false);
stand.setBasePlate(false);
stand.setSmall(true);
stand.setArms(true);
stand.setVisible(true);
ItemStack head = new ItemStack(Material.PLAYER_HEAD, 1);
SkullMeta meta = (SkullMeta) head.getItemMeta();
if (meta == null) return;
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
// url method: new String(Base64.encodeBase64(String.format("{textures:{SKIN:{url:\"%s\"}}}", this.getMinerType().getHeadTexture()).getBytes()));
profile.getProperties().put("textures", new Property("textures", this.getMinerType().getHeadTexture()));
byte[] encodedData = Base64.encodeBase64(String.format("{textures:{SKIN:{url:\"%s\"}}}", this.type.getHeadTexture()).getBytes());
profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
try {
Util.setFieldValue(meta, "profile", profile);
} catch (Exception e) {
throw new RuntimeException(e);
}
head.setItemMeta(meta);
ItemStack chest = new ItemStack(Material.LEATHER_CHESTPLATE);
LeatherArmorMeta chestdata = (LeatherArmorMeta) chest.getItemMeta();
if (chestdata == null) return;
@ -135,73 +126,107 @@ public class CryptoMiner {
bootdata.setColor(org.bukkit.Color.fromRGB(2, 2, 58));
boot.setItemMeta(bootdata);
ItemStack pick = new ItemStack(Material.GOLDEN_PICKAXE);
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> list = new ArrayList<>();
list.add(new Pair<>(EquipmentSlot.HEAD, CraftItemStack.asNMSCopy(head)));
list.add(new Pair<>(EquipmentSlot.CHEST, CraftItemStack.asNMSCopy(chest)));
list.add(new Pair<>(EquipmentSlot.LEGS, CraftItemStack.asNMSCopy(leg)));
list.add(new Pair<>(EquipmentSlot.FEET, CraftItemStack.asNMSCopy(boot)));
list.add(new Pair<>(EquipmentSlot.MAINHAND, CraftItemStack.asNMSCopy(pick)));
stand.getEquipment().setItemInMainHand(pick);
stand.getEquipment().setHelmet(head);
stand.getEquipment().setChestplate(chest);
stand.getEquipment().setLeggings(leg);
stand.getEquipment().setBoots(boot);
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), Util.color(this.name));
gameProfile.getProperties().put("textures", new Property("textures", this.type.getHeadTexture()));
String[] skin = Skin.getSkin("Shiba_");
gameProfile.getProperties().put("textures", new Property("textures", skin[0], skin[1]));
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
ServerLevel w = ((CraftWorld) player.getLocation().getWorld()).getHandle();
ServerPlayer m = new ServerPlayer(server, w, gameProfile, null);
ServerGamePacketListenerImpl pc = ((CraftPlayer) player).getHandle().connection;
pc.send(new ClientboundAddEntityPacket(stand));
pc.send(new ClientboundSetEquipmentPacket(stand.getId(), list));
pc.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, m));
SynchedEntityData watcher = stand.getEntityData();
watcher.set(new EntityDataAccessor<>(0, EntityDataSerializers.BYTE), (byte) 20);
watcher.set(new EntityDataAccessor<>(5, EntityDataSerializers.BOOLEAN), true);
watcher.set(new EntityDataAccessor<>(15, EntityDataSerializers.BYTE), (byte) 13);
new PacketPlayOutEntityMetadata(player, stand, watcher);
new BukkitRunnable() {
@Override
public void run() {
generate();
}
}.runTaskTimer(NullValkyrie.getPlugin(NullValkyrie.class), 0, 40);
}
public void generate() {
ServerPlayer miner = new ServerPlayer(server, w, gameProfile);
World world = miner.getBukkitEntity().getWorld();
List<Location> locs = new ArrayList<>();
for (int x = (int) this.getLocation().getX() - 2; x <= this.getLocation().getX() + 2; x++) {
for (int z = (int) this.getLocation().getZ() - 2; z <= this.getLocation().getZ() + 2; z++) {
for (int y = (int) this.getLocation().getY() - 1; y <= this.getLocation().getY() - 1; y++) {
this.getLocation().setY(17.0F);
if (this.getLocation().getWorld().getBlockAt(x, y, z).getType() == this.getType()) {
locs.add(this.getLocation().getWorld().getBlockAt(x, y, z).getLocation());
}
for (int x = (int) stand.getLocation().getX() - 3; x <= stand.getLocation().getX() + 2; x++) {
for (int z = (int) stand.getLocation().getZ() - 2; z <= stand.getLocation().getZ() + 2; z++) {
for (int y = (int) stand.getLocation().getY() - 1; y <= stand.getLocation().getY() - 1; y++) {
if (world.getBlockAt(x, y, z).getType() == this.getType())
locs.add(world.getBlockAt(x, y, z).getLocation());
}
}
}
locs.remove(world.getBlockAt(stand.getLocation().subtract(0, -1, 0)).getLocation());
if (locs.size() != 0) {
Location closest = locs.get(0);
for (Location location : locs)
if (location.distance(this.getLocation()) < closest.distance(this.getLocation()))
closest = location;
if (location.distance(stand.getLocation()) < closest.distance(stand.getLocation())) closest = location;
ArrayList<ItemStack> items = new ArrayList<>();
ThreadLocalRandom random = ThreadLocalRandom.current();
if (closest.getBlock().getType() == this.getType()) {
closest.getBlock().getDrops().clear();
List<int[]> levels = List.of(new int[]{1, 3}, new int[]{2, 5}, new int[]{3, 7}, new int[]{4, 9}, new int[]{5, 11}, new int[]{6, 13}, new int[]{7, 15}, new int[]{8, 17}, new int[]{9, 19}, new int[]{10, 21}, new int[]{11, 23}, new int[]{12, 25}, new int[]{13, 27}, new int[]{14, 29}, new int[]{15, 31}, new int[]{16, 33}, new int[]{17, 35}, new int[]{18, 37}, new int[]{19, 39}, new int[]{20, 41}, new int[]{21, 43}, new int[]{22, 45}, new int[]{23, 47}, new int[]{24, 49}, new int[]{25, 51}, new int[]{26, 53}, new int[]{27, 55}, new int[]{28, 57}, new int[]{29, 59}, new int[]{30, 61}, new int[]{31, 63}, new int[]{32, 65}, new int[]{33, 67}, new int[]{34, 69}, new int[]{35, 71}, new int[]{36, 73}, new int[]{37, 75}, new int[]{38, 77}, new int[]{39, 79}, new int[]{40, 81}, new int[]{41, 83}, new int[]{42, 85}, new int[]{43, 87}, new int[]{44, 89}, new int[]{45, 91}, new int[]{46, 93}, new int[]{47, 95}, new int[]{48, 97}, new int[]{49, 99}, new int[]{50, 100});
items.add(new ItemStack(this.getType(), random.nextInt(levels.get(this.getLevel())[0], levels.get(this.getLevel())[1])));
int lower = 0;
int upper = 0;
if (this.level == 1) {
lower = 1;
upper = 3;
} else if (this.level == 2) {
lower = 2;
upper = 5;
} else if (this.level == 3) {
lower = 3;
upper = 7;
} else if (this.level == 4) {
lower = 4;
upper = 9;
} else if (this.level == 5) {
lower = 5;
upper = 11;
} else if (this.level == 6) {
lower = 6;
upper = 13;
} else if (this.level == 7) {
lower = 7;
upper = 15;
} else if (this.level == 8) {
lower = 8;
upper = 17;
} else if (this.level == 9) {
lower = 9;
upper = 19;
} else if (this.level == 10) {
lower = 10;
upper = 21;
} else if (this.level == 11) {
lower = 11;
upper = 23;
} else if (this.level == 12) {
lower = 12;
upper = 25;
} else if (this.level == 13) {
lower = 13;
upper = 27;
} else if (this.level == 14) {
lower = 14;
upper = 29;
} else if (this.level == 15) {
lower = 15;
upper = 31;
} else if (this.level == 16) {
lower = 16;
upper = 33;
} else if (this.level == 17) {
lower = 17;
upper = 35;
} else if (this.level == 18) {
lower = 18;
upper = 37;
} else if (this.level == 19) {
lower = 19;
upper = 39;
} else if (this.level == 20) {
lower = 20;
upper = 41;
}
items.add(new ItemStack(this.getType(), random.nextInt(lower, upper)));
closest.getBlock().setType(Material.AIR);
}
// drop the items
for (ItemStack item : items) {
this.getLocation().add(0, 2, 0).getWorld().dropItemNaturally(closest, item);
}
}
}
public static void reloadMiner() {
for (Player player : Bukkit.getOnlinePlayers())
for (CryptoMiner miner : MinerDataManager.getMiners().values()) {
miner.spawn(player);
world.dropItemNaturally(closest, item);
}
}
public static void onJoin(Player player) {
for (CryptoMiner miner : MinerDataManager.getMiners().values()) {
miner.spawn(player);
}
}
}

View file

@ -1,46 +0,0 @@
package me.night.nullvalkyrie.entities.miners;
import org.bukkit.Material;
public enum MinerType {
DIAMOND("Diamond", Material.DIAMOND_ORE, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWM4Y2E2NjRmMDZkNDE0NjUwYWFjNWNkNDgyYzNiMGM3OWE2NjFiNWYxMWRjODUyMTQyNWJhNmU1NjllNSJ9fX0="),
EMERALD("Emerald", Material.EMERALD_ORE, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjRmNzNlMmVjZGMxYTM5MzlmYzEyZWY1N2Q3MTA0YTcwYzAyOGM1Y2ZiNzMyNGQ2OGVkM2IxZTIwYTkxMGEzIn19fQ=="),
GOLD("Gold", Material.GOLD_ORE, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDcxNDlmYjllNjM4NTI2OGY1MTk4N2IyZGU1MjVmNTkwNTFiNjE3Njc2Mjc2ZDI1YzZiMjQ1Y2E4ZDRkNCJ9fX0="),
IRON("Iron", Material.IRON_ORE, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNGMzMTc1M2QzNDQwYjJhN2QxMTVmNmE3NTQyY2Q0YjI0ODdjYjdhZGEwYzk0NWJlNGQ0ZGY2MmJiMzlkNDA2NyJ9fX0="),
REDSTONE("Redstone", Material.REDSTONE_ORE, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNzU1YjcwZWEyM2VmNjFkNjE4N2U1NTgzMTI4MTU2ZTE2MDg2YzIyODM4YjQ4YTc2YTk5NWZiZjk4ZjFlYjhhIn19fQ=="),
COAL("Coal", Material.COAL_ORE, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZmM2ZDBkYWQ4NmRjZDNkN2JjNDIxYTNjMjIyYWJhMzQxNDRjOTc5MWRkMmZjYTZiNzZlMzYwMmE2ZTM2In19fQ=="),
LAPIS("Lapis", Material.LAPIS_ORE, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNGI4M2QyMjkzYTVjYjVlOGE5YTY4M2JiOWYxYzI2NzAzZjdjMDNmMzE0Mzk2MTEzYjA3MzQ5Njk5YTNjOGIifX19"),
QUARTZ("Quartz", Material.NETHER_QUARTZ_ORE, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTQ1MjVhNTE2YTg3YTMxNTdlMTE2MzlhZWJiYzRjMmRmMmRiMTFkNTNjZWQ3NjgxMzQ0MzA0NmVkM2U1YiJ9fX0="),
OBSIDIAN("Obsidian", Material.OBSIDIAN, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNDY1YmIxOTJhNjU2YmQ2ZGVjOGQ4YzhlNGRiM2I1NzNjZjcxNjliYjczOTM5MTZlZjlhYzE5ZGExNjNhZGE1In19fQ=="),
NETHERITE("Netherite", Material.ANCIENT_DEBRIS, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZDM1NzQ0NGFkZTY0ZWM2Y2VhNjQ1ZWM1N2U3NzU4NjRkNjdjNWZhNjIyOTk3ODZlMDM3OTkzMTdlZTRhZCJ9fX0=");
private final String name;
private final Material material;
private final String headTexture;
MinerType(String name, Material material, String headTexture) {
this.name = name;
this.material = material;
this.headTexture = headTexture;
}
public String getName() {
return name;
}
public Material getMaterial() {
return material;
}
public String getHeadTexture() {
return headTexture;
}
public static MinerType getByName(String name) {
for (MinerType type : MinerType.values()) {
if (type.getName().equalsIgnoreCase(name)) {
return type;
}
}
return null;
}
}

View file

@ -3,9 +3,9 @@ package me.night.nullvalkyrie.entities.npcs;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import com.mojang.datafixers.util.Pair;
import me.night.nullvalkyrie.NullValkyrie;
import me.night.nullvalkyrie.database.NPCDataManager;
import me.night.nullvalkyrie.packets.protocol.PacketPlayOutEntityMetadata;
import me.night.nullvalkyrie.packets.protocol.PacketPlayOutSpawnEntity;
import me.night.nullvalkyrie.util.*;
import net.minecraft.network.protocol.game.*;
import net.minecraft.network.syncher.*;
@ -17,10 +17,10 @@ import net.minecraft.world.entity.EquipmentSlot;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_19_R1.CraftServer;
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
import org.bukkit.craftbukkit.v1_19_R2.CraftServer;
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -30,37 +30,34 @@ import java.util.List;
import java.util.UUID;
public class NPCManager {
private static final HashMap<Integer, ServerPlayer> NPCs = new HashMap<>();
private static final List<ServerPlayer> NPCs = new ArrayList<>();
public static HashMap<Integer, ServerPlayer> getNPCs() {
public static List<ServerPlayer> getNPCs() {
return NPCs;
}
@SuppressWarnings("ConstantConditions")
public static void createNPC(Player player, String name) { // name must be less than 16 characters including color codes
// TODO: npc not even spawning rn
ServerPlayer sp = ((CraftPlayer) player).getHandle();
MinecraftServer server = sp.server;
ServerLevel level = ((CraftWorld) player.getLocation().getWorld()).getHandle();
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), Util.color(name));
String[] skin = Skin.getSkin(player);
gameProfile.getProperties().put("textures", new Property("textures", skin[0], skin[1]));
ServerPlayer npc = new ServerPlayer(server, level, gameProfile, null);
ServerPlayer npc = new ServerPlayer(server, level, gameProfile);
Location location = player.getLocation();
npc.setPos(location.getX(), location.getY(), location.getZ());
addNPCPacket(npc);
NPCs.put(npc.getId(), npc);
NPCDataManager.setNPC(name, player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ(), (int) player.getLocation().getPitch(), (int) player.getLocation().getYaw(), player.getLocation().getWorld().getName(), skin[0], skin[1]);
NPCs.add(npc);
NPCDataManager.setNPC(name, (int) player.getLocation().getX(), (int) player.getLocation().getY(), (int) player.getLocation().getZ(), (int) player.getLocation().getPitch(), (int) player.getLocation().getYaw(), player.getLocation().getWorld().getName(), skin[0], skin[1]);
}
public static void addNPCPacket(ServerPlayer npc) {
for (Player player : Bukkit.getOnlinePlayers()) {
ServerGamePacketListenerImpl pc = ((CraftPlayer) player).getHandle().connection;
pc.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, npc));
pc.send(new ClientboundAddPlayerPacket(npc));
new PacketPlayOutSpawnEntity(player, npc);
pc.send(new ClientboundRotateHeadPacket(npc, (byte) (npc.getBukkitYaw() * 256 / 360)));
SynchedEntityData watcher = npc.getEntityData();
watcher.set(new EntityDataAccessor<>(17, EntityDataSerializers.BYTE), (byte) 127);
new PacketPlayOutEntityMetadata(player, npc, watcher);
Bukkit.getScheduler().runTaskLaterAsynchronously(NullValkyrie.getPlugin(NullValkyrie.class), () -> pc.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER, npc)), 50);
new PacketPlayOutEntityMetadata(player, npc, watcher.getNonDefaultValues());
ItemStack netheriteAxe = new ItemStack(Material.NETHERITE_AXE);
ItemStack anotherAxe = new ItemStack(Material.NETHERITE_INGOT);
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> itemList = new ArrayList<>();
@ -71,15 +68,13 @@ public class NPCManager {
}
public static void addJoinPacket(Player player) {
for (ServerPlayer npc : NPCs.values()) {
for (ServerPlayer npc : NPCs) {
ServerGamePacketListenerImpl pc = ((CraftPlayer) player).getHandle().connection;
pc.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, npc));
pc.send(new ClientboundAddPlayerPacket(npc));
new PacketPlayOutSpawnEntity(player, npc);
pc.send(new ClientboundRotateHeadPacket(npc, (byte) (npc.getBukkitYaw() * 256 / 360)));
SynchedEntityData watcher = npc.getEntityData();
watcher.set(new EntityDataAccessor<>(17, EntityDataSerializers.BYTE), (byte) 127);
new PacketPlayOutEntityMetadata(player, npc, watcher);
Bukkit.getScheduler().runTaskLaterAsynchronously(NullValkyrie.getPlugin(NullValkyrie.class), () -> pc.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.REMOVE_PLAYER, npc)), 50);
new PacketPlayOutEntityMetadata(player, npc, watcher.getNonDefaultValues());
ItemStack netheriteAxe = new ItemStack(Material.NETHERITE_AXE);
ItemStack anotherAxe = new ItemStack(Material.NETHERITE_INGOT);
List<Pair<EquipmentSlot, net.minecraft.world.item.ItemStack>> itemList = new ArrayList<>();
@ -88,21 +83,18 @@ public class NPCManager {
pc.send(new ClientboundSetEquipmentPacket(npc.getBukkitEntity().getEntityId(), itemList));
}
}
@SuppressWarnings("ConstantConditions")
public static void reloadNPC(List<HashMap<String, Object>> npcs) {
for (HashMap<String, Object> npc : npcs) {
Location location = new Location(Bukkit.getWorld((String) npc.get("world")), (double) npc.get("x"), (double) npc.get("y"), (double) npc.get("z"), (int) npc.get("yaw"), (int) npc.get("pitch"));
Location location = new Location(Bukkit.getWorld((String) npc.get("world")), (int) npc.get("x"), (int) npc.get("y"), (int) npc.get("z"), (int) npc.get("yaw"), (int) npc.get("pitch"));
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), Util.color((String) npc.get("name")));
gameProfile.getProperties().put("textures", new Property("textures", (String) npc.get("texture"), (String) npc.get("signature")));
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
ServerLevel w = ((CraftWorld) location.getWorld()).getHandle();
ServerPlayer ep = new ServerPlayer(server, w, gameProfile, null);
ServerPlayer ep = new ServerPlayer(server, w, gameProfile);
ep.setPos(location.getX(), location.getY(), location.getZ()); // NMS: 1.19.2 https://nms.screamingsandals.org/1.19.2/net/minecraft/world/entity/Entity.html absMoveTo
addNPCPacket(ep);
NPCs.put(ep.getId(), ep);
NPCs.add(ep);
}
}
public static ServerPlayer getNPC(int id) {
return NPCs.get(id);
}
}

View file

@ -7,8 +7,8 @@ import net.minecraft.world.entity.ai.goal.FloatGoal;
import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal;
import net.minecraft.world.entity.monster.Zombie;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityTargetEvent;

View file

@ -1,5 +1,6 @@
package me.night.nullvalkyrie.util.enchantments;
package me.night.nullvalkyrie.enums;
import me.night.nullvalkyrie.util.enchantments.EnchantmentManager;
import org.bukkit.enchantments.Enchantment;
public enum Enchantments {

View file

@ -1,6 +1,5 @@
package me.night.nullvalkyrie.entities.items;
package me.night.nullvalkyrie.enums;
import me.night.nullvalkyrie.entities.miners.Rarity;
import org.bukkit.Material;
public enum Items {

View file

@ -0,0 +1,37 @@
package me.night.nullvalkyrie.enums;
import org.bukkit.Material;
public enum MinerType {
DIAMOND("Diamond", Material.DIAMOND_ORE, "https://textures.minecraft.net/texture/c09cc3c75bd13c59602040b5970f30dbc76825c0e817da815a65d76ab0e82198"), EMERALD("Emerald", Material.EMERALD_ORE, "https://textures.minecraft.net/texture/c09cc3c75bd13c59602040b5970f30dbc76825c0e817da815a65d76ab0e82198"), GOLD("Gold", Material.GOLD_ORE, "https://textures.minecraft.net/texture/c09cc3c75bd13c59602040b5970f30dbc76825c0e817da815a65d76ab0e82198"), IRON("Iron", Material.IRON_ORE, "https://textures.minecraft.net/texture/c09cc3c75bd13c59602040b5970f30dbc76825c0e817da815a65d76ab0e82198"), REDSTONE("Redstone", Material.REDSTONE_ORE, "https://textures.minecraft.net/texture/c09cc3c75bd13c59602040b5970f30dbc76825c0e817da815a65d76ab0e82198"), COAL("Coal", Material.COAL_ORE, "https://textures.minecraft.net/texture/c09cc3c75bd13c59602040b5970f30dbc76825c0e817da815a65d76ab0e82198"), LAPIS("Lapis", Material.LAPIS_ORE, "https://textures.minecraft.net/texture/c09cc3c75bd13c59602040b5970f30dbc76825c0e817da815a65d76ab0e82198"), QUARTZ("Quartz", Material.NETHER_QUARTZ_ORE, "https://textures.minecraft.net/texture/c09cc3c75bd13c59602040b5970f30dbc76825c0e817da815a65d76ab0e82198"), OBSIDIAN("Obsidian", Material.OBSIDIAN, "https://textures.minecraft.net/texture/c09cc3c75bd13c59602040b5970f30dbc76825c0e817da815a65d76ab0e82198"), NETHERITE("Netherite", Material.ANCIENT_DEBRIS, "https://textures.minecraft.net/texture/c09cc3c75bd13c59602040b5970f30dbc76825c0e817da815a65d76ab0e82198");
private final String name;
private final Material material;
private final String headTexture;
MinerType(String name, Material material, String headTexture) {
this.name = name;
this.material = material;
this.headTexture = headTexture;
}
public String getName() {
return name;
}
public Material getMaterial() {
return material;
}
public String getHeadTexture() {
return headTexture;
}
public static MinerType getByName(String name) {
for (MinerType type : MinerType.values()) {
if (type.getName().equalsIgnoreCase(name)) {
return type;
}
}
return null;
}
}

View file

@ -1,4 +1,4 @@
package me.night.nullvalkyrie.util;
package me.night.nullvalkyrie.enums;
import org.bukkit.ChatColor;

View file

@ -1,4 +1,4 @@
package me.night.nullvalkyrie.entities.miners;
package me.night.nullvalkyrie.enums;
import org.bukkit.ChatColor;

View file

@ -2,8 +2,8 @@ package me.night.nullvalkyrie.events.listeners;
import me.night.nullvalkyrie.entities.items.CustomItemManager;
import me.night.nullvalkyrie.entities.items.Pickaxe;
import me.night.nullvalkyrie.entities.miners.Rarity;
import me.night.nullvalkyrie.NullValkyrie;
import me.night.nullvalkyrie.enums.Rarity;
import me.night.nullvalkyrie.Main;
import me.night.nullvalkyrie.packets.protocol.PacketPlayOutBlockBreakAnimation;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
@ -245,7 +245,7 @@ public class CustomItemEvents implements Listener {
// player.setHealth(20);
// player.teleport(generateRandomCoord(9, Bukkit.getWorld("world")));
// }
// }.runTaskLater(NullValkyrie.getPlugin(NullValkyrie.class), 100L);
// }.runTaskLater(Main.getPlugin(Main.class), 100L);
// countDown(player, new int[]{5});
// }
}
@ -255,7 +255,7 @@ public class CustomItemEvents implements Listener {
private int taskID;
public void countDown(Player player, int[] a) {
taskID = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(NullValkyrie.getPlugin(NullValkyrie.class), () -> {
taskID = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(Main.getPlugin(Main.class), () -> {
player.sendTitle(ChatColor.RED + "YOU DIED!", ChatColor.GREEN + "You will revive in " + a[0] + " seconds", 0, 20, 0);
a[0]--;
if (a[0] == 0) {

View file

@ -1,6 +1,6 @@
package me.night.nullvalkyrie.events.listeners;
import me.night.nullvalkyrie.NullValkyrie;
import me.night.nullvalkyrie.Main;
import me.night.nullvalkyrie.util.Util;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -60,7 +60,7 @@ public class DamageEffectEvents implements Listener {
}
removal.forEach(stands::remove);
}
}.runTaskTimer(NullValkyrie.getPlugin(NullValkyrie.class), 0L, 1L);
}.runTaskTimer(Main.getPlugin(Main.class), 0L, 1L);
}
public boolean isSpawnable(Location loc) {

View file

@ -1,39 +1,30 @@
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.craftbukkit.v1_19_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
public class CustomEvents implements Listener {
public class NPCEvents implements Listener {
@EventHandler
public void onClick(RightClickNPCEvent e) {
Player player = e.getPlayer();
if (e.getNPC().getBukkitEntity().getName().contains("VETTEL")) {
if (e.getNPC().getBukkitEntity().getName().contains("SAI")) {
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 -> {
NPCManager.getNPCs().forEach(npc -> {
Location location = npc.getBukkitEntity().getLocation();
location.setDirection(e.getPlayer().getLocation().subtract(location).toVector());
float yaw = location.getYaw();

View file

@ -1,5 +1,6 @@
package me.night.nullvalkyrie.events.listeners;
import me.night.nullvalkyrie.events.custom.InteractHologramEvent;
import me.night.nullvalkyrie.packets.handle.PacketInjector;
import me.night.nullvalkyrie.util.Util;
import org.bukkit.Bukkit;
@ -28,6 +29,7 @@ public class ServerEvents implements Listener {
public void onJoin(PlayerJoinEvent e) {
bossbar.addPlayer(e.getPlayer());
injector.addPlayer(e.getPlayer());
e.getPlayer().setResourcePack("https://www.dropbox.com/s/7y7p93xzhar6vvw/%C2%A7b%C2%A7lNKRP%201.19.3.zip?dl=1");
}
@EventHandler
@ -48,6 +50,14 @@ public class ServerEvents implements Listener {
}
}
@EventHandler
public void onClickHologram(InteractHologramEvent e) {
if (e.getHologram().getCustomName() == null) return;
if (e.getHologram().getCustomName().equals(ChatColor.GOLD + "Click me to change!!!")) {
// TODO: change hologram things
}
}
@EventHandler
public void onWeatherChange(WeatherChangeEvent e) {
e.setCancelled(true);

View file

@ -3,29 +3,18 @@ package me.night.nullvalkyrie.packets.handle;
import io.netty.channel.ChannelDuplexHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPromise;
import me.night.nullvalkyrie.NullValkyrie;
import me.night.nullvalkyrie.entities.holograms.PerPlayerHologram;
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 me.night.nullvalkyrie.util.Util;
import net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket;
import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket;
import net.minecraft.network.protocol.game.ServerboundInteractPacket;
import net.minecraft.network.syncher.EntityDataAccessor;
import net.minecraft.network.syncher.EntityDataSerializers;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.server.level.ServerPlayer;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
public class PacketHandler extends ChannelDuplexHandler {
private final Player player;
@ -36,28 +25,6 @@ public class PacketHandler extends ChannelDuplexHandler {
@Override
public void write(ChannelHandlerContext ctx, Object packet, ChannelPromise promise) throws Exception {
if (packet.getClass().getSimpleName().equalsIgnoreCase("PacketPlayOutEntityMetadat")) {
ClientboundSetEntityDataPacket pk = (ClientboundSetEntityDataPacket) packet;
int entityID = pk.getId();
final Entity[] entity = {null};
// get entity from id
new BukkitRunnable() {
@Override
public void run() {
for (Entity e : Bukkit.getWorld("world").getEntities()) {
if (e.getEntityId() == entityID && e.getType() == EntityType.PLAYER) {
entity[0] = e;
}
}
}
}.runTaskLater(NullValkyrie.getPlugin(NullValkyrie.class), 0);
if (entity[0] == null) return;
List<SynchedEntityData.DataItem<?>> list = pk.getUnpackedData();
SynchedEntityData.DataItem<Float> value = (SynchedEntityData.DataItem<Float>) list.get(9);
System.out.println(value.getAccessor());
float health = ThreadLocalRandom.current().nextInt(5, 20);
list.set(9, new SynchedEntityData.DataItem<>(new EntityDataAccessor<>(value.getAccessor().getId(), EntityDataSerializers.FLOAT), health));
}
super.write(ctx, packet, promise);
}
@ -67,24 +34,26 @@ public class PacketHandler extends ChannelDuplexHandler {
ServerboundInteractPacket pk = (ServerboundInteractPacket) packet;
int entityID = (int) Util.getFieldValue(packet, "a");
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);
if (stands == null) return;
Bukkit.getPluginManager().callEvent(new InteractHologramEvent(player, (ArmorStand) stands[stands.length - 1].getBukkitEntity()));
for (net.minecraft.world.entity.decoration.ArmorStand i : stands) {
((CraftPlayer) player).getHandle().connection.send(new ClientboundRemoveEntitiesPacket(i.getId()));
Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getPlugin(Main.class), () -> {
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);
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
if (npc.getBukkitEntity().getEntityId() == entityID && sneak)
Bukkit.getScheduler().scheduleSyncDelayedTask(NullValkyrie.getPlugin(NullValkyrie.class), () -> Bukkit.getPluginManager().callEvent(new RightClickNPCEvent(player, npc)), 0);
for (ServerPlayer npcs : NPCManager.getNPCs()) {
if (npcs.getBukkitEntity().getEntityId() == entityID && sneak) {
Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getPlugin(Main.class), () -> Bukkit.getPluginManager().callEvent(new RightClickNPCEvent(player, npcs)), 0);
}
}
} catch (NoSuchFieldException x) {
//Left Click
}

View file

@ -1,6 +1,6 @@
package me.night.nullvalkyrie.packets.protocol;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class Channel {

View file

@ -3,7 +3,7 @@ package me.night.nullvalkyrie.packets.protocol;
import net.minecraft.core.BlockPos;
import net.minecraft.network.protocol.game.ClientboundBlockDestructionPacket;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class PacketPlayOutBlockBreakAnimation implements Packet {

View file

@ -3,11 +3,13 @@ package me.night.nullvalkyrie.packets.protocol;
import net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket;
import net.minecraft.network.syncher.SynchedEntityData;
import net.minecraft.world.entity.Entity;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.util.List;
public class PacketPlayOutEntityMetadata implements Packet {
public PacketPlayOutEntityMetadata(Player player, Entity entity, SynchedEntityData entityData) {
((CraftPlayer) player).getHandle().connection.send(new ClientboundSetEntityDataPacket(entity.getBukkitEntity().getEntityId(), entityData, true));
public PacketPlayOutEntityMetadata(Player player, Entity entity, List<SynchedEntityData.DataValue<?>> list) {
((CraftPlayer) player).getHandle().connection.send(new ClientboundSetEntityDataPacket(entity.getBukkitEntity().getEntityId(), list));
}
}

View file

@ -2,7 +2,7 @@ package me.night.nullvalkyrie.packets.protocol;
import net.minecraft.network.protocol.game.ClientboundAddEntityPacket;
import net.minecraft.world.entity.Entity;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class PacketPlayOutSpawnEntity implements Packet {

View file

@ -1,4 +1,4 @@
package me.night.nullvalkyrie.game.tasks;
package me.night.nullvalkyrie.tasks;
import org.bukkit.Bukkit;
import org.bukkit.World;

View file

@ -1,8 +1,8 @@
package me.night.nullvalkyrie.ui.inventory;
import me.night.nullvalkyrie.NullValkyrie;
import me.night.nullvalkyrie.Main;
import me.night.nullvalkyrie.database.UserDataManager;
import me.night.nullvalkyrie.entities.items.Items;
import me.night.nullvalkyrie.enums.Items;
import me.night.nullvalkyrie.util.RandomCollection;
import me.night.nullvalkyrie.util.Util;
import org.bukkit.ChatColor;
@ -142,7 +142,7 @@ public class InventoryListener implements Listener {
ii++;
time++;
}
}.runTaskTimer(NullValkyrie.getPlugin(NullValkyrie.class), 1L, 5L);
}.runTaskTimer(Main.getPlugin(Main.class), 1L, 5L);
new BukkitRunnable() {
@Override
public void run() {
@ -184,7 +184,7 @@ public class InventoryListener implements Listener {
player.getInventory().addItem(item);
} else player.closeInventory();
}
}.runTaskLater(NullValkyrie.getPlugin(NullValkyrie.class), 5L * 20L);
}.runTaskLater(Main.getPlugin(Main.class), 5L * 20L);
}
}

View file

@ -1,6 +1,6 @@
package me.night.nullvalkyrie.ui.inventory;
import me.night.nullvalkyrie.entities.items.Items;
import me.night.nullvalkyrie.enums.Items;
import me.night.nullvalkyrie.util.Util;
import org.bukkit.ChatColor;
import org.bukkit.Material;

View file

@ -7,7 +7,7 @@ import org.bukkit.scoreboard.*;
public class BelowNameManager {
public void setBelowName(Player player) {
Scoreboard board = player.getScoreboard();
Objective obj = board.registerNewObjective("HealthBar", Criteria.HEALTH, ChatColor.RED + "");
Objective obj = board.registerNewObjective("HealthBar", Criteria.create("CustomHealth"), ChatColor.RED.toString() + player.getHealth() + "");
obj.setDisplaySlot(DisplaySlot.BELOW_NAME);
player.setScoreboard(board);
}

View file

@ -1,7 +1,7 @@
package me.night.nullvalkyrie.ui.player;
import me.night.nullvalkyrie.database.RankDataManager;
import me.night.nullvalkyrie.util.Rank;
import me.night.nullvalkyrie.enums.Rank;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.*;

View file

@ -2,8 +2,7 @@ package me.night.nullvalkyrie.ui.player;
import me.night.nullvalkyrie.database.RankDataManager;
import me.night.nullvalkyrie.database.UserDataManager;
import me.night.nullvalkyrie.entities.miners.CryptoMiner;
import me.night.nullvalkyrie.util.Rank;
import me.night.nullvalkyrie.enums.Rank;
import me.night.nullvalkyrie.entities.npcs.NPCManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -31,7 +30,6 @@ public class ScoreboardListener implements Listener {
public void onJoin(PlayerJoinEvent e) {
Player player = e.getPlayer();
if (!player.hasPlayedBefore()) {
e.getPlayer().setResourcePack("https://www.dropbox.com/s/7y7p93xzhar6vvw/%C2%A7b%C2%A7lNKRP%201.19.3.zip?dl=1");
e.getPlayer().sendTitle(ChatColor.RED + "Welcome to Vanadium!", ChatColor.GREEN + "LOL", 20, 100, 20);
RankDataManager.setRank(player.getUniqueId(), Rank.ROOKIE, this);
new UserDataManager().createUserBank(e.getPlayer().getUniqueId().toString());
@ -46,7 +44,6 @@ public class ScoreboardListener implements Listener {
if (NPCManager.getNPCs() == null) return;
if (NPCManager.getNPCs().isEmpty()) return;
NPCManager.addJoinPacket(e.getPlayer());
CryptoMiner.onJoin(e.getPlayer());
}
@EventHandler

View file

@ -1,6 +1,6 @@
package me.night.nullvalkyrie.ui.player;
import me.night.nullvalkyrie.NullValkyrie;
import me.night.nullvalkyrie.Main;
import me.night.nullvalkyrie.database.UserDataManager;
import me.night.nullvalkyrie.util.Util;
import org.bukkit.Bukkit;
@ -50,7 +50,7 @@ public class SideBarManager {
public void start(Player player) {
board = new AnimatedSideBar(player.getUniqueId());
taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(NullValkyrie.getPlugin(NullValkyrie.class), new Runnable() {
taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.getPlugin(Main.class), new Runnable() {
int count = 0;
public void animate(String str) {

View file

@ -4,7 +4,7 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import java.io.InputStreamReader;

View file

@ -1,5 +1,6 @@
package me.night.nullvalkyrie.util.enchantments;
import me.night.nullvalkyrie.enums.Enchantments;
import org.bukkit.enchantments.Enchantment;
import java.lang.reflect.Field;