NullValkyrie

Minecraft 1.19 multipurpose plugin for spigot servers with a lot of features where most modern servers have.
git clone https://codeberg.org/night0721/NullValkyrie
Log | Files | Refs | README | LICENSE

commit f70a800320f732ffac88414620e47ed357786eb0
parent dfa6cb489e7dda62c8605f310573d89c9ee455ef
Author: NK <[email protected]>
Date:   Fri, 18 Nov 2022 08:59:21 +0000

mining speed up

Diffstat:
Msrc/main/java/me/night/nullvalkyrie/Main.java | 4+++-
Msrc/main/java/me/night/nullvalkyrie/commands/BetaCommand.java | 8--------
Msrc/main/java/me/night/nullvalkyrie/events/CustomItemEvents.java | 38+++++++++++++++++++++++++++++++-------
3 files changed, 34 insertions(+), 16 deletions(-)

diff --git a/src/main/java/me/night/nullvalkyrie/Main.java b/src/main/java/me/night/nullvalkyrie/Main.java @@ -6,6 +6,7 @@ import me.night.nullvalkyrie.enchantments.EnchantmentManager; import me.night.nullvalkyrie.events.CustomItemEvents; //import me.night.nullvalkyrie.hardpoint.GameEvent; import me.night.nullvalkyrie.events.DamageEffect; +import me.night.nullvalkyrie.hardpoint.ConfigManager; import me.night.nullvalkyrie.items.CustomItemManager; import me.night.nullvalkyrie.rank.ScoreboardListener; import me.night.nullvalkyrie.util.Util; @@ -31,6 +32,7 @@ import static me.night.nullvalkyrie.items.CustomItemManager.updateYamlFilesToPlu public final class Main extends JavaPlugin implements Listener { private BossBar bossbar; + @Override public void onEnable() { getConfig().options().copyDefaults(); @@ -51,11 +53,11 @@ public final class Main extends JavaPlugin implements Listener { new DiscordClientManager(); new CryptoMiner(this, "Baka", Material.ENDER_CHEST, 10, 0.7, new Date().getTime()); new Client(); + ConfigManager.setConfig(); } @EventHandler public void onJoin(PlayerJoinEvent e) { - e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§1NOT ENOUGH MANNER")); bossbar.addPlayer(e.getPlayer()); } diff --git a/src/main/java/me/night/nullvalkyrie/commands/BetaCommand.java b/src/main/java/me/night/nullvalkyrie/commands/BetaCommand.java @@ -31,14 +31,6 @@ public class BetaCommand extends Command { // EntityPlayer ep = cp.getHandle(); // PacketPlayOutUpdateHealth packet = new PacketPlayOutUpdateHealth(20f, 20, 5.0f); // health, food, food saturation // ep.b.a(packet); // Sends the Packet - -// new BukkitRunnable() { -// @Override -// public void run() { -// pa.spigot().sendMessage(ChatMessageType.ACTION_BAR, -// TextComponent.fromLegacyText("§1NOT ENOUGH MANNER")); -// } -// }.runTaskTimer(main, 0L, 10); } } diff --git a/src/main/java/me/night/nullvalkyrie/events/CustomItemEvents.java b/src/main/java/me/night/nullvalkyrie/events/CustomItemEvents.java @@ -1,5 +1,7 @@ package me.night.nullvalkyrie.events; +import com.google.common.cache.Cache; +import com.google.common.cache.CacheBuilder; import me.night.nullvalkyrie.items.CustomItemManager; import me.night.nullvalkyrie.items.Rarity; import me.night.nullvalkyrie.Main; @@ -21,6 +23,7 @@ import org.bukkit.persistence.PersistentDataContainer; import org.bukkit.persistence.PersistentDataType; import java.util.*; +import java.util.concurrent.TimeUnit; public class CustomItemEvents implements Listener { private final Main main; @@ -262,15 +265,13 @@ public class CustomItemEvents implements Listener { private int taskID; public void countDown(Player player, int[] a) { taskID = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(main, () -> { - player.sendTitle(ChatColor.RED + "YOU DIED!", ChatColor.GREEN + "You will revive in " + a[0] + " seconds", - 0, 20, 0); + player.sendTitle(ChatColor.RED + "YOU DIED!", ChatColor.GREEN + "You will revive in " + a[0] + " seconds", 0, 20, 0); a[0]--; if (a[0] == 0) { Bukkit.getScheduler().cancelTask(taskID); } }, 0L, 20L); } - private final Map<UUID, Merchant> villagerlist = new HashMap<>(); @EventHandler @@ -278,8 +279,7 @@ public class CustomItemEvents implements Listener { Player p = e.getPlayer(); Entity clickedEntity = e.getRightClicked(); if (clickedEntity instanceof Creeper) { - if (p.getInventory().getItemInMainHand().getType() != Material.STICK) - return; + if (p.getInventory().getItemInMainHand().getType() != Material.STICK) return; clickedEntity.remove(); Location loc = clickedEntity.getLocation(); Villager villager = (Villager) p.getWorld().spawnEntity(loc, EntityType.VILLAGER); @@ -300,8 +300,7 @@ public class CustomItemEvents implements Listener { } if (e.getRightClicked() instanceof Villager) { Merchant merchant = villagerlist.get(clickedEntity.getUniqueId()); - if (merchant == null) - return; + if (merchant == null) return; e.setCancelled(true); p.openMerchant(merchant, true); } @@ -313,4 +312,29 @@ public class CustomItemEvents implements Listener { // System.out.println(e.getEntity().getLocation()); // e.getEntity().setCustomName(ChatColor.RED + "Changed name since you ust clicked lol"); // } + + private Cache<UUID, Long> BreakAbility = CacheBuilder.newBuilder().expireAfterWrite(60, TimeUnit.MILLISECONDS).build(); + private HashMap<Block, Integer> blockStages = new HashMap<>(); + @EventHandler + public void onPlayAnimation(PlayerAnimationEvent e) { + Player player = e.getPlayer(); + if (player.getGameMode().equals(GameMode.SURVIVAL)) { + if (!BreakAbility.asMap().containsKey(player.getUniqueId())) { + if (e.getAnimationType().equals(PlayerAnimationType.ARM_SWING)) { + Block block = player.getTargetBlock(null, 3); + if (!blockStages.containsKey(block)) blockStages.put(block, 0); + else { + BreakAbility.put(player.getUniqueId(), System.currentTimeMillis() + 60); + int blockStage = blockStages.get(block) + 1; + blockStages.replace(block, blockStage); + if (blockStages.get(block) == 10) { + player.sendBlockDamage(block.getLocation(), 1); + block.breakNaturally(); + blockStages.remove(block); + } else player.sendBlockDamage(block.getLocation(), (float) blockStage / 10); + } + } + } + } + } } \ No newline at end of file