mining speed up

This commit is contained in:
NK 2022-11-18 08:59:21 +00:00
parent dfa6cb489e
commit f70a800320
3 changed files with 34 additions and 16 deletions

View file

@ -6,6 +6,7 @@ import me.night.nullvalkyrie.enchantments.EnchantmentManager;
import me.night.nullvalkyrie.events.CustomItemEvents; import me.night.nullvalkyrie.events.CustomItemEvents;
//import me.night.nullvalkyrie.hardpoint.GameEvent; //import me.night.nullvalkyrie.hardpoint.GameEvent;
import me.night.nullvalkyrie.events.DamageEffect; import me.night.nullvalkyrie.events.DamageEffect;
import me.night.nullvalkyrie.hardpoint.ConfigManager;
import me.night.nullvalkyrie.items.CustomItemManager; import me.night.nullvalkyrie.items.CustomItemManager;
import me.night.nullvalkyrie.rank.ScoreboardListener; import me.night.nullvalkyrie.rank.ScoreboardListener;
import me.night.nullvalkyrie.util.Util; 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 { public final class Main extends JavaPlugin implements Listener {
private BossBar bossbar; private BossBar bossbar;
@Override @Override
public void onEnable() { public void onEnable() {
getConfig().options().copyDefaults(); getConfig().options().copyDefaults();
@ -51,11 +53,11 @@ public final class Main extends JavaPlugin implements Listener {
new DiscordClientManager(); new DiscordClientManager();
new CryptoMiner(this, "Baka", Material.ENDER_CHEST, 10, 0.7, new Date().getTime()); new CryptoMiner(this, "Baka", Material.ENDER_CHEST, 10, 0.7, new Date().getTime());
new Client(); new Client();
ConfigManager.setConfig();
} }
@EventHandler @EventHandler
public void onJoin(PlayerJoinEvent e) { public void onJoin(PlayerJoinEvent e) {
e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§1NOT ENOUGH MANNER"));
bossbar.addPlayer(e.getPlayer()); bossbar.addPlayer(e.getPlayer());
} }

View file

@ -31,14 +31,6 @@ public class BetaCommand extends Command {
// EntityPlayer ep = cp.getHandle(); // EntityPlayer ep = cp.getHandle();
// PacketPlayOutUpdateHealth packet = new PacketPlayOutUpdateHealth(20f, 20, 5.0f); // health, food, food saturation // PacketPlayOutUpdateHealth packet = new PacketPlayOutUpdateHealth(20f, 20, 5.0f); // health, food, food saturation
// ep.b.a(packet); // Sends the Packet // 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);
} }
} }

View file

@ -1,5 +1,7 @@
package me.night.nullvalkyrie.events; 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.CustomItemManager;
import me.night.nullvalkyrie.items.Rarity; import me.night.nullvalkyrie.items.Rarity;
import me.night.nullvalkyrie.Main; import me.night.nullvalkyrie.Main;
@ -21,6 +23,7 @@ import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType; import org.bukkit.persistence.PersistentDataType;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit;
public class CustomItemEvents implements Listener { public class CustomItemEvents implements Listener {
private final Main main; private final Main main;
@ -262,15 +265,13 @@ public class CustomItemEvents implements Listener {
private int taskID; private int taskID;
public void countDown(Player player, int[] a) { public void countDown(Player player, int[] a) {
taskID = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(main, () -> { taskID = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(main, () -> {
player.sendTitle(ChatColor.RED + "YOU DIED!", ChatColor.GREEN + "You will revive in " + a[0] + " seconds", player.sendTitle(ChatColor.RED + "YOU DIED!", ChatColor.GREEN + "You will revive in " + a[0] + " seconds", 0, 20, 0);
0, 20, 0);
a[0]--; a[0]--;
if (a[0] == 0) { if (a[0] == 0) {
Bukkit.getScheduler().cancelTask(taskID); Bukkit.getScheduler().cancelTask(taskID);
} }
}, 0L, 20L); }, 0L, 20L);
} }
private final Map<UUID, Merchant> villagerlist = new HashMap<>(); private final Map<UUID, Merchant> villagerlist = new HashMap<>();
@EventHandler @EventHandler
@ -278,8 +279,7 @@ public class CustomItemEvents implements Listener {
Player p = e.getPlayer(); Player p = e.getPlayer();
Entity clickedEntity = e.getRightClicked(); Entity clickedEntity = e.getRightClicked();
if (clickedEntity instanceof Creeper) { if (clickedEntity instanceof Creeper) {
if (p.getInventory().getItemInMainHand().getType() != Material.STICK) if (p.getInventory().getItemInMainHand().getType() != Material.STICK) return;
return;
clickedEntity.remove(); clickedEntity.remove();
Location loc = clickedEntity.getLocation(); Location loc = clickedEntity.getLocation();
Villager villager = (Villager) p.getWorld().spawnEntity(loc, EntityType.VILLAGER); Villager villager = (Villager) p.getWorld().spawnEntity(loc, EntityType.VILLAGER);
@ -300,8 +300,7 @@ public class CustomItemEvents implements Listener {
} }
if (e.getRightClicked() instanceof Villager) { if (e.getRightClicked() instanceof Villager) {
Merchant merchant = villagerlist.get(clickedEntity.getUniqueId()); Merchant merchant = villagerlist.get(clickedEntity.getUniqueId());
if (merchant == null) if (merchant == null) return;
return;
e.setCancelled(true); e.setCancelled(true);
p.openMerchant(merchant, true); p.openMerchant(merchant, true);
} }
@ -313,4 +312,29 @@ public class CustomItemEvents implements Listener {
// System.out.println(e.getEntity().getLocation()); // System.out.println(e.getEntity().getLocation());
// e.getEntity().setCustomName(ChatColor.RED + "Changed name since you ust clicked lol"); // 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);
}
}
}
}
}
} }