feat: BlackKnife DeltaMine v1.0.0 - Paper 1.21.1 SWOON/Stars/Sword/Diamond/Lunge/Snipe/Tri/Overhead + Magic 4commons Parry chat 400words +12h updates
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
package me.sashegdev.blackknife;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
public class AttackTpListener implements Listener {
|
||||
private final TensionManager tension;
|
||||
public AttackTpListener(TensionManager tension) { this.tension = tension; }
|
||||
|
||||
private Player getAttacker(org.bukkit.entity.Entity damager) {
|
||||
if (damager instanceof Player p) return p;
|
||||
if (damager instanceof org.bukkit.entity.Projectile proj && proj.getShooter() instanceof Player p) return p;
|
||||
if (damager instanceof org.bukkit.entity.AbstractArrow arrow && arrow.getShooter() instanceof Player p) return p;
|
||||
return null;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onAttack(EntityDamageByEntityEvent e) {
|
||||
Player p = getAttacker(e.getDamager());
|
||||
if (p == null) return;
|
||||
if (!(e.getEntity() instanceof LivingEntity target)) return;
|
||||
if (e.isCancelled()) return;
|
||||
tension.startBattle(p, target);
|
||||
boolean crit = false;
|
||||
if (e.getDamager() instanceof org.bukkit.entity.AbstractArrow arrow) crit = arrow.isCritical();
|
||||
else crit = p.getFallDistance() > 0 && !p.isOnGround() && !p.isSprinting();
|
||||
float gain = crit ? 25f : 12.5f;
|
||||
tension.addTP(p, gain, crit ? "CRIT +10%" : "+5%");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMiss(org.bukkit.event.player.PlayerAnimationEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
var ray = p.rayTraceEntities(4);
|
||||
if (ray != null && ray.getHitEntity() != null) return;
|
||||
var nearby = p.getWorld().getNearbyEntities(p.getEyeLocation(), 3, 3, 3, en -> en instanceof LivingEntity && en != p);
|
||||
for (var ent : nearby) {
|
||||
if (ent.getLocation().distanceSquared(p.getEyeLocation()) < 0.25) {
|
||||
if (tension.isInBattle(p)) tension.addTP(p, 2.5f, "MISS +1%");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onDodge(Player p) {
|
||||
if (tension.isInBattle(p)) tension.addTP(p, 2.5f, "DODGE +1%");
|
||||
p.getWorld().spawnParticle(org.bukkit.Particle.DUST, p.getLocation().add(0, 0.25, 0), 25, 0.5, 0.05, 0.5, 0, new org.bukkit.Particle.DustOptions(org.bukkit.Color.fromRGB(255, 255, 255), 0.15f));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package me.sashegdev.blackknife;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
public class BlackKnifeCommand implements CommandExecutor {
|
||||
private final BlackKnifePlugin plugin;
|
||||
private final ChatConfig chatConfig;
|
||||
private final ChatHandler chatHandler;
|
||||
public BlackKnifeCommand(BlackKnifePlugin plugin, ChatConfig chatConfig, ChatHandler chatHandler) { this.plugin = plugin; this.chatConfig = chatConfig; this.chatHandler = chatHandler; }
|
||||
public BlackKnifeCommand(BlackKnifePlugin plugin) { this(plugin, null, null); }
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (args.length >= 1 && args[0].equalsIgnoreCase("give")) {
|
||||
Player target = null;
|
||||
if (args.length >= 2) target = plugin.getServer().getPlayer(args[1]);
|
||||
else if (sender instanceof Player p) target = p;
|
||||
if (target == null) { sender.sendMessage(Component.text("Player not found").color(NamedTextColor.RED)); return true; }
|
||||
target.getInventory().addItem(BlackKnifeItem.create());
|
||||
sender.sendMessage(Component.text("Gave Black Knife to " + target.getName()).color(NamedTextColor.GREEN));
|
||||
return true;
|
||||
}
|
||||
if (args.length >= 1 && args[0].equalsIgnoreCase("reload")) {
|
||||
if (chatConfig != null) chatConfig.load();
|
||||
sender.sendMessage(Component.text("Chat config reloaded (400 words)").color(NamedTextColor.GREEN));
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(Component.text("Usage: /blackknife give [player] | /blackknife reload").color(NamedTextColor.YELLOW));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package me.sashegdev.blackknife;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import java.util.List;
|
||||
|
||||
public class BlackKnifeItem {
|
||||
public static final NamespacedKey KEY = new NamespacedKey("blackknife", "blackknife");
|
||||
public static final NamespacedKey MODE = new NamespacedKey("blackknife", "mode");
|
||||
|
||||
public static ItemStack create() {
|
||||
ItemStack item = new ItemStack(Material.NETHERITE_SWORD);
|
||||
ItemMeta m = item.getItemMeta();
|
||||
m.displayName(Component.text("Black Knife").color(NamedTextColor.BLACK).decorate(TextDecoration.BOLD));
|
||||
m.lore(List.of(
|
||||
Component.text("A blade that hums in the dark...").color(NamedTextColor.DARK_GRAY).decorate(TextDecoration.ITALIC),
|
||||
Component.text("It chooses its owner.").color(NamedTextColor.GRAY).decorate(TextDecoration.ITALIC)
|
||||
));
|
||||
m.setUnbreakable(true);
|
||||
m.getPersistentDataContainer().set(KEY, PersistentDataType.BYTE, (byte) 1);
|
||||
m.getPersistentDataContainer().set(MODE, PersistentDataType.STRING, "STARS");
|
||||
item.setItemMeta(m);
|
||||
return item;
|
||||
}
|
||||
|
||||
public static boolean is(ItemStack item) {
|
||||
if (item == null || item.getType() != Material.NETHERITE_SWORD) return false;
|
||||
var meta = item.getItemMeta();
|
||||
return meta != null && meta.getPersistentDataContainer().has(KEY, PersistentDataType.BYTE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,337 @@
|
||||
package me.sashegdev.blackknife;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Display;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class BlackKnifeListener implements Listener {
|
||||
private final BlackKnifePlugin plugin;
|
||||
private final java.util.Map<java.util.UUID, String> mode = new java.util.HashMap<>();
|
||||
private final java.util.Map<java.util.UUID, BukkitRunnable> previewTasks = new java.util.HashMap<>();
|
||||
private final java.util.Map<java.util.UUID, BukkitRunnable> lungeHighlightTasks = new java.util.HashMap<>();
|
||||
private final java.util.Map<java.util.UUID, Integer> swordCombo = new java.util.HashMap<>();
|
||||
private static final String[] MODES = {"STARS", "SWORD", "DIAMOND", "LUNGE", "SNIPE", "TRI", "OVERHEAD"};
|
||||
|
||||
public BlackKnifeListener(BlackKnifePlugin plugin) { this.plugin = plugin; }
|
||||
|
||||
private String getMode(Player p) { return mode.getOrDefault(p.getUniqueId(), "STARS"); }
|
||||
|
||||
public Location getGazePoint(Player p) {
|
||||
var ray = p.getWorld().rayTraceBlocks(p.getEyeLocation(), p.getEyeLocation().getDirection(), 120);
|
||||
if (ray != null && ray.getHitPosition() != null) {
|
||||
Location loc = new Location(p.getWorld(), ray.getHitPosition().getX(), ray.getHitPosition().getY(), ray.getHitPosition().getZ());
|
||||
if (ray.getHitBlockFace() != null) loc.add(0, 0.1, 0);
|
||||
return loc;
|
||||
}
|
||||
return p.getEyeLocation().add(p.getEyeLocation().getDirection().normalize().multiply(20));
|
||||
}
|
||||
|
||||
public LivingEntity getLungeTarget(Player p) {
|
||||
Location eye = p.getEyeLocation();
|
||||
Vector dir = eye.getDirection().normalize();
|
||||
LivingEntity best = null;
|
||||
double bestScore = Double.MAX_VALUE;
|
||||
for (var ent : p.getWorld().getNearbyEntities(eye, 120, 120, 120, e -> e instanceof LivingEntity && e != p)) {
|
||||
LivingEntity le = (LivingEntity) ent;
|
||||
if (!p.hasLineOfSight(le)) continue;
|
||||
var ray = p.getWorld().rayTraceBlocks(eye, dir, 120);
|
||||
if (ray != null && ray.getHitBlock() != null) {
|
||||
double blockDist = ray.getHitBlock().getLocation().distanceSquared(eye);
|
||||
double entDist = le.getLocation().add(0, 1, 0).distanceSquared(eye);
|
||||
if (blockDist + 1 < entDist) continue;
|
||||
}
|
||||
Location eloc = le.getLocation().add(0, 1, 0);
|
||||
Vector toEnt = eloc.clone().subtract(eye).toVector();
|
||||
double dist = toEnt.length();
|
||||
double dot = toEnt.normalize().dot(dir);
|
||||
if (dot < 0.995) continue;
|
||||
if (best == null || dist < bestScore) { best = le; bestScore = dist; }
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
ItemStack item = e.getItem();
|
||||
if (!BlackKnifeItem.is(item)) return;
|
||||
Player p = e.getPlayer();
|
||||
TensionManager tm = plugin.getTension();
|
||||
if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if (p.isSneaking()) {
|
||||
int idx = 0;
|
||||
String cur = getMode(p);
|
||||
for (int i = 0; i < MODES.length; i++) if (MODES[i].equals(cur)) { idx = i; break; }
|
||||
String next = MODES[(idx + 1) % MODES.length];
|
||||
mode.put(p.getUniqueId(), next);
|
||||
updatePreview(p, next);
|
||||
p.sendActionBar(Component.text("Mode: " + next).color(NamedTextColor.LIGHT_PURPLE));
|
||||
return;
|
||||
}
|
||||
if (p.hasCooldown(item.getType())) return;
|
||||
String m = getMode(p);
|
||||
Location center = p.getEyeLocation().add(p.getEyeLocation().getDirection().multiply(8));
|
||||
center.setY(p.getLocation().getY() + 2);
|
||||
if (m.equals("STARS")) {
|
||||
spawnStars(p, center);
|
||||
p.setCooldown(item.getType(), 60);
|
||||
p.getWorld().playSound(p.getLocation(), Sound.BLOCK_AMETHYST_BLOCK_PLACE, 1f, 1.2f);
|
||||
} else if (m.equals("SWORD")) {
|
||||
int combo = swordCombo.getOrDefault(p.getUniqueId(), 0);
|
||||
if (combo < 2) {
|
||||
if (SwordAttack.tryUse(p, tm)) {
|
||||
swordCombo.put(p.getUniqueId(), combo + 1);
|
||||
p.setCooldown(item.getType(), 13);
|
||||
clearPreview(p);
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, () -> { if (getMode(p).equals("SWORD")) updatePreview(p, "SWORD"); }, 14L);
|
||||
}
|
||||
} else {
|
||||
if (tm.getTP(p) < 12.5f) { p.sendActionBar(Component.text("Need 5% TP").color(NamedTextColor.RED)); return; }
|
||||
tm.setTP(p, tm.getTP(p) - 12.5f);
|
||||
Vector dir = p.getEyeLocation().getDirection().normalize();
|
||||
Vector right = dir.clone().crossProduct(new Vector(0, 1, 0)).normalize();
|
||||
if (right.lengthSquared() < 0.01) right = new Vector(1, 0, 0);
|
||||
swordCombo.put(p.getUniqueId(), 0);
|
||||
p.setCooldown(item.getType(), 40);
|
||||
clearPreview(p);
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, () -> { if (getMode(p).equals("SWORD")) updatePreview(p, "SWORD"); }, 41L);
|
||||
SwordAttack.launch(p, tm, dir, 2.0);
|
||||
SwordAttack.launch(p, tm, dir.clone().add(right.clone().multiply(0.22)).normalize(), 2.0);
|
||||
SwordAttack.launch(p, tm, dir.clone().add(right.clone().multiply(-0.22)).normalize(), 2.0);
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_PLAYER_ATTACK_SWEEP, 1f, 0.8f);
|
||||
}
|
||||
} else if (m.equals("DIAMOND")) {
|
||||
if (DiamondAttack.tryUse(p, tm)) {
|
||||
p.setCooldown(item.getType(), 15);
|
||||
p.getWorld().playSound(p.getLocation(), Sound.BLOCK_AMETHYST_BLOCK_PLACE, 1f, 0.9f);
|
||||
}
|
||||
} else if (m.equals("LUNGE")) {
|
||||
LivingEntity target = getLungeTarget(p);
|
||||
if (LungeAttack.tryUse(p, tm, target)) {
|
||||
p.setCooldown(item.getType(), 280);
|
||||
clearHighlight(p);
|
||||
}
|
||||
} else if (m.equals("SNIPE")) {
|
||||
LivingEntity target = getLungeTarget(p);
|
||||
if (LungeAttack.trySnipe(p, tm, target)) {
|
||||
p.setCooldown(item.getType(), 5);
|
||||
}
|
||||
} else if (m.equals("TRI")) {
|
||||
LivingEntity target = getLungeTarget(p);
|
||||
if (LungeAttack.tryTri(p, tm, target)) {
|
||||
p.setCooldown(item.getType(), 40);
|
||||
}
|
||||
} else if (m.equals("OVERHEAD")) {
|
||||
Location gaze = getGazePoint(p);
|
||||
if (LungeAttack.tryOverhead(p, tm, gaze)) {
|
||||
p.setCooldown(item.getType(), 30);
|
||||
}
|
||||
}
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void clearPreview(Player p) {
|
||||
var task = previewTasks.remove(p.getUniqueId());
|
||||
if (task != null) task.cancel();
|
||||
}
|
||||
|
||||
private void clearHighlight(Player p) {
|
||||
var task = lungeHighlightTasks.remove(p.getUniqueId());
|
||||
if (task != null) task.cancel();
|
||||
}
|
||||
|
||||
private void updatePreview(Player p, String m) {
|
||||
clearPreview(p);
|
||||
clearHighlight(p);
|
||||
if (m.equals("SWORD")) {
|
||||
BukkitRunnable r = new BukkitRunnable() {
|
||||
@Override public void run() {
|
||||
if (!p.isOnline() || !getMode(p).equals("SWORD") || p.hasCooldown(Material.NETHERITE_SWORD)) return;
|
||||
if (!BlackKnifeItem.is(p.getInventory().getItemInMainHand()) && !BlackKnifeItem.is(p.getInventory().getItemInOffHand())) return;
|
||||
Vector dir = p.getEyeLocation().getDirection().normalize();
|
||||
Vector right = dir.clone().crossProduct(new Vector(0, 1, 0));
|
||||
if (right.lengthSquared() < 0.01) right = new Vector(1, 0, 0);
|
||||
right.normalize();
|
||||
Location base = p.getLocation().add(0, 2.2, 0).add(dir.clone().multiply(0.7));
|
||||
int combo = swordCombo.getOrDefault(p.getUniqueId(), 0);
|
||||
if (combo < 2) {
|
||||
for (int i = -2; i <= 2; i++) {
|
||||
Location pp = base.clone().add(right.clone().multiply(i * 0.3)).add(dir.clone().multiply(Math.abs(i) * 0.15));
|
||||
p.spawnParticle(Particle.DUST, pp, 1, 0, 0, 0, 0, new Particle.DustOptions(Color.fromRGB(0, 0, 0), 1.3f));
|
||||
}
|
||||
p.spawnParticle(Particle.DUST, base.clone().add(dir.clone().multiply(1.2)), 1, 0, 0, 0, 0, new Particle.DustOptions(Color.fromRGB(0, 0, 0), 0.8f));
|
||||
} else {
|
||||
for (int side = -1; side <= 1; side++) {
|
||||
Location c = base.clone().add(right.clone().multiply(side * 1.3));
|
||||
for (int i = -2; i <= 2; i++) {
|
||||
Location pp = c.clone().add(right.clone().multiply(i * 0.22)).add(dir.clone().multiply(Math.abs(i) * 0.1));
|
||||
p.spawnParticle(Particle.DUST, pp, 1, 0, 0, 0, 0, new Particle.DustOptions(Color.fromRGB(50, 0, 0), 1.3f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
r.runTaskTimer(plugin, 2L, 4L);
|
||||
previewTasks.put(p.getUniqueId(), r);
|
||||
} else if (m.equals("LUNGE") || m.equals("SNIPE") || m.equals("TRI")) {
|
||||
BukkitRunnable r = new BukkitRunnable() {
|
||||
@Override public void run() {
|
||||
if (!p.isOnline() || !(getMode(p).equals("LUNGE") || getMode(p).equals("SNIPE") || getMode(p).equals("TRI"))) { cancel(); return; }
|
||||
if (p.hasCooldown(Material.NETHERITE_SWORD)) return;
|
||||
if (!BlackKnifeItem.is(p.getInventory().getItemInMainHand()) && !BlackKnifeItem.is(p.getInventory().getItemInOffHand())) return;
|
||||
LivingEntity target = getLungeTarget(p);
|
||||
if (target == null) return;
|
||||
Location tl = target.getLocation().add(0, 1, 0);
|
||||
int ringCount = m.equals("TRI") ? 16 : 12;
|
||||
double r1 = m.equals("SNIPE") ? 0.6 : 0.8;
|
||||
for (int i = 0; i < ringCount; i++) {
|
||||
double angle = (double) i / ringCount * Math.PI * 2;
|
||||
double x = Math.cos(angle) * r1;
|
||||
double z = Math.sin(angle) * r1;
|
||||
Location ring = tl.clone().add(x, 0, z);
|
||||
Color col = m.equals("TRI") ? Color.fromRGB(80, 20, 80) : m.equals("SNIPE") ? Color.fromRGB(20, 100, 160) : Color.fromRGB(30, 80, 120);
|
||||
p.spawnParticle(Particle.DUST, ring, 1, 0, 0, 0, 0, new Particle.DustOptions(col, 1.5f));
|
||||
}
|
||||
if (m.equals("TRI")) {
|
||||
for (int k = 0; k < 3; k++) {
|
||||
double a = k * 120 * Math.PI / 180;
|
||||
Location dot = tl.clone().add(Math.cos(a) * r1, 0, Math.sin(a) * r1);
|
||||
p.spawnParticle(Particle.DUST, dot, 1, 0, 0, 0, 0, new Particle.DustOptions(Color.fromRGB(255, 50, 50), 1.3f));
|
||||
}
|
||||
}
|
||||
p.spawnParticle(Particle.SCULK_SOUL, tl, 3, 0.3, 0.5, 0.3, 0.02);
|
||||
p.spawnParticle(Particle.DUST, tl.clone().add(0, 2, 0), 1, 0, 0, 0, 0, new Particle.DustOptions(Color.fromRGB(255, 50, 50), 1.0f));
|
||||
}
|
||||
};
|
||||
r.runTaskTimer(plugin, 1L, 5L);
|
||||
lungeHighlightTasks.put(p.getUniqueId(), r);
|
||||
} else if (m.equals("OVERHEAD")) {
|
||||
BukkitRunnable r = new BukkitRunnable() {
|
||||
@Override public void run() {
|
||||
if (!p.isOnline() || !getMode(p).equals("OVERHEAD")) { cancel(); return; }
|
||||
if (p.hasCooldown(Material.NETHERITE_SWORD)) return;
|
||||
if (!BlackKnifeItem.is(p.getInventory().getItemInMainHand()) && !BlackKnifeItem.is(p.getInventory().getItemInOffHand())) return;
|
||||
Location gp = getGazePoint(p);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
double a = (double) i / 16 * Math.PI * 2;
|
||||
Location ring = gp.clone().add(Math.cos(a) * 2, 0.1, Math.sin(a) * 2);
|
||||
p.spawnParticle(Particle.DUST, ring, 1, 0, 0, 0, 0, new Particle.DustOptions(Color.fromRGB(20, 20, 20), 1.2f));
|
||||
p.spawnParticle(Particle.ASH, ring, 1, 0, 0, 0, 0);
|
||||
}
|
||||
for (int i = 0; i < 8; i++) {
|
||||
double a = (double) i / 8 * Math.PI * 2;
|
||||
Location ring = gp.clone().add(Math.cos(a) * 1, 0.1, Math.sin(a) * 1);
|
||||
p.spawnParticle(Particle.SCULK_SOUL, ring, 1, 0.02, 0.02, 0.02, 0);
|
||||
}
|
||||
p.spawnParticle(Particle.DUST, gp.clone().add(0, 0.1, 0), 1, 0, 0, 0, 0, new Particle.DustOptions(Color.fromRGB(255, 40, 40), 1.5f));
|
||||
}
|
||||
};
|
||||
r.runTaskTimer(plugin, 1L, 4L);
|
||||
lungeHighlightTasks.put(p.getUniqueId(), r);
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnStars(Player p, Location center) {
|
||||
p.getWorld().playSound(center, Sound.BLOCK_AMETHYST_BLOCK_PLACE, 1f, 1.4f);
|
||||
p.getWorld().playSound(center, Sound.BLOCK_BEACON_POWER_SELECT, 0.8f, 1.5f);
|
||||
for (int i = 0; i < 18; i++) {
|
||||
double angle = Math.random() * Math.PI * 2;
|
||||
double r = 6 + Math.random() * 6;
|
||||
Location loc = center.clone().add(Math.cos(angle) * r, 8 + Math.random() * 4, Math.sin(angle) * r);
|
||||
org.bukkit.entity.BlockDisplay disp = p.getWorld().spawn(loc, org.bukkit.entity.BlockDisplay.class, d -> {
|
||||
d.setBlock(Material.AMETHYST_BLOCK.createBlockData());
|
||||
d.setBrightness(new Display.Brightness(15, 15));
|
||||
d.setViewRange(64);
|
||||
});
|
||||
Vector vel = new Vector(0, -0.35 - Math.random() * 0.1, 0);
|
||||
vel.add(new Vector((Math.random() - 0.5) * 0.08, 0, (Math.random() - 0.5) * 0.08));
|
||||
new BukkitRunnable() {
|
||||
@Override public void run() {
|
||||
if (!disp.isValid() || disp.isDead()) { cancel(); return; }
|
||||
Location cur = disp.getLocation();
|
||||
Location nl = cur.clone().add(vel);
|
||||
Location next = nl.clone().add(vel);
|
||||
if (next.getBlock().isSolid() || nl.getY() <= p.getWorld().getHighestBlockYAt(nl) + 0.5) {
|
||||
Location expl = cur.clone().add(vel.clone().normalize().multiply(-0.1));
|
||||
disp.teleport(expl);
|
||||
disp.remove();
|
||||
cancel();
|
||||
p.getWorld().spawnParticle(Particle.EXPLOSION, expl, 1);
|
||||
p.getWorld().playSound(expl, Sound.ENTITY_GENERIC_EXPLODE, 0.8f, 1.2f);
|
||||
for (int s = 0; s < 6; s++) {
|
||||
double a = s * Math.PI * 2 / 6;
|
||||
Vector sv = new Vector(Math.cos(a) * 0.35, 0, Math.sin(a) * 0.35);
|
||||
org.bukkit.entity.BlockDisplay shard = p.getWorld().spawn(expl, org.bukkit.entity.BlockDisplay.class, d -> {
|
||||
d.setBlock(Material.MEDIUM_AMETHYST_BUD.createBlockData());
|
||||
d.setBrightness(new Display.Brightness(15, 15));
|
||||
d.setViewRange(64);
|
||||
});
|
||||
new BukkitRunnable() {
|
||||
@Override public void run() {
|
||||
if (!shard.isValid()) { cancel(); return; }
|
||||
Location cur2 = shard.getLocation();
|
||||
Location n2 = cur2.clone().add(sv);
|
||||
if (n2.getBlock().isSolid()) {
|
||||
Location expl2 = cur2.clone().add(sv.clone().normalize().multiply(-0.1));
|
||||
shard.teleport(expl2);
|
||||
shard.remove();
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
shard.teleport(n2);
|
||||
n2.getWorld().spawnParticle(Particle.CRIT, n2, 1, 0.05, 0.05, 0.05, 0);
|
||||
for (var ent : n2.getWorld().getNearbyEntities(n2, 0.7, 0.7, 0.7)) {
|
||||
if (ent instanceof Player pl && pl != p) continue;
|
||||
if (ent instanceof org.bukkit.entity.LivingEntity le && le != p) {
|
||||
le.getPersistentDataContainer().set(SwoonHandler.MAGIC_DAMAGE, PersistentDataType.BYTE, (byte) 1);
|
||||
le.damage(3.0, p);
|
||||
shard.remove();
|
||||
cancel();
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (Player pl : n2.getWorld().getNearbyPlayers(n2, 0.9)) {
|
||||
if (pl == p) continue;
|
||||
double d2 = pl.getLocation().add(0, 1, 0).distanceSquared(n2);
|
||||
if (d2 > 0.25 && d2 < 0.81) {
|
||||
plugin.getTension().addTP(pl, 2.5f, "DODGE +1%");
|
||||
pl.getWorld().spawnParticle(Particle.DUST, pl.getLocation().add(0, 0.25, 0), 25, 0.5, 0.05, 0.5, 0, new Particle.DustOptions(Color.fromRGB(255, 255, 255), 0.15f));
|
||||
}
|
||||
}
|
||||
if (shard.getTicksLived() > 40) { shard.remove(); cancel(); }
|
||||
}
|
||||
}.runTaskTimer(plugin, 1L, 1L);
|
||||
}
|
||||
return;
|
||||
}
|
||||
disp.teleport(nl);
|
||||
disp.getWorld().spawnParticle(Particle.END_ROD, nl, 1, 0.05, 0.05, 0.05, 0);
|
||||
for (Player pl : nl.getWorld().getNearbyPlayers(nl, 0.9)) {
|
||||
if (pl == p) continue;
|
||||
double d2 = pl.getLocation().add(0, 1, 0).distanceSquared(nl);
|
||||
if (d2 > 0.25 && d2 < 0.81) {
|
||||
plugin.getTension().addTP(pl, 2.5f, "DODGE +1%");
|
||||
pl.getWorld().spawnParticle(Particle.DUST, pl.getLocation().add(0, 0.25, 0), 25, 0.5, 0.05, 0.5, 0, new Particle.DustOptions(Color.fromRGB(255, 255, 255), 0.15f));
|
||||
}
|
||||
}
|
||||
if (disp.getTicksLived() > 120) { disp.remove(); cancel(); }
|
||||
}
|
||||
}.runTaskTimer(plugin, 1L, 1L);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package me.sashegdev.blackknife;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class BlackKnifePlugin extends JavaPlugin {
|
||||
private TensionManager tension;
|
||||
private MagicManager magicManager;
|
||||
private MagicListener magicListener;
|
||||
private ChatConfig chatConfig;
|
||||
private ChatHandler chatHandler;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
tension = new TensionManager();
|
||||
magicManager = new MagicManager(this);
|
||||
magicListener = new MagicListener(this, magicManager);
|
||||
chatConfig = new ChatConfig(this);
|
||||
chatHandler = new ChatHandler(this, chatConfig);
|
||||
getServer().getPluginManager().registerEvents(tension, this);
|
||||
getServer().getPluginManager().registerEvents(new BlackKnifeListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new SwoonHandler(this), this);
|
||||
getServer().getPluginManager().registerEvents(new AttackTpListener(tension), this);
|
||||
getServer().getPluginManager().registerEvents(new KnockedHandler(this), this);
|
||||
getServer().getPluginManager().registerEvents(new ParryHandler(this), this);
|
||||
getServer().getPluginManager().registerEvents(magicListener, this);
|
||||
getServer().getPluginManager().registerEvents(chatHandler, this);
|
||||
getCommand("blackknife").setExecutor(new BlackKnifeCommand(this, chatConfig, chatHandler));
|
||||
getCommand("magic").setExecutor(new MagicCommand(magicManager, this));
|
||||
getServer().getScheduler().runTaskTimer(this, () -> tension.tickShield(), 20L, 1L);
|
||||
getLogger().info("BlackKnife 1.0.0 enabled - Paper 1.21.1");
|
||||
}
|
||||
|
||||
public TensionManager getTension() { return tension; }
|
||||
public MagicManager getMagicManager() { return magicManager; }
|
||||
public MagicListener getMagicListener() { return magicListener; }
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getServer().getScheduler().cancelTasks(this);
|
||||
if (tension != null) {
|
||||
tension.hideAll();
|
||||
for (var p : getServer().getOnlinePlayers()) {
|
||||
var copy = new java.util.ArrayList<net.kyori.adventure.bossbar.BossBar>();
|
||||
for (var b : p.activeBossBars()) copy.add(b);
|
||||
for (var bar : copy) p.hideBossBar(bar);
|
||||
}
|
||||
}
|
||||
if (magicManager != null) magicManager.saveAll();
|
||||
int removed = EntityTracker.cleanup(this);
|
||||
getLogger().info("BlackKnife disabled, cleaned " + removed + " entities");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package me.sashegdev.blackknife;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
public class ChatConfig {
|
||||
public Map<String,String> ru = new LinkedHashMap<>();
|
||||
public Map<String,String> en = new LinkedHashMap<>();
|
||||
public Map<String,String> ionRu = new LinkedHashMap<>();
|
||||
public Map<String,String> ionEn = new LinkedHashMap<>();
|
||||
private final BlackKnifePlugin plugin;
|
||||
private File file;
|
||||
|
||||
public ChatConfig(BlackKnifePlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
file = new File(plugin.getDataFolder(), "chat.yml");
|
||||
load();
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (!file.exists()) createDefault();
|
||||
YamlConfiguration y = YamlConfiguration.loadConfiguration(file);
|
||||
ru.clear(); en.clear(); ionRu.clear(); ionEn.clear();
|
||||
var secRu = y.getConfigurationSection("ru_words");
|
||||
var secEn = y.getConfigurationSection("en_words");
|
||||
if (secRu != null) for (String w : secRu.getKeys(false)) {
|
||||
if (w.matches(".*\\d$")) continue;
|
||||
ru.put(w.toLowerCase(), secRu.getString(w));
|
||||
}
|
||||
if (secEn != null) for (String w : secEn.getKeys(false)) {
|
||||
if (w.matches(".*\\d$")) continue;
|
||||
en.put(w.toLowerCase(), secEn.getString(w));
|
||||
}
|
||||
var secIonRu = y.getConfigurationSection("ion_ru");
|
||||
var secIonEn = y.getConfigurationSection("ion_en");
|
||||
if (secIonRu != null) for (String w : secIonRu.getKeys(false)) ionRu.put(w.toLowerCase(), secIonRu.getString(w));
|
||||
if (secIonEn != null) for (String w : secIonEn.getKeys(false)) ionEn.put(w.toLowerCase(), secIonEn.getString(w));
|
||||
if (ru.isEmpty() && en.isEmpty()) createDefaultAndReload();
|
||||
plugin.getLogger().info("ChatConfig loaded ru:" + ru.size() + " en:" + en.size() + " ionRu:" + ionRu.size() + " ionEn:" + ionEn.size());
|
||||
}
|
||||
|
||||
private void createDefaultAndReload() { createDefault(); YamlConfiguration y = YamlConfiguration.loadConfiguration(file); ru.clear(); en.clear(); ionRu.clear(); ionEn.clear(); var secRu = y.getConfigurationSection("ru_words"); var secEn = y.getConfigurationSection("en_words"); if (secRu!=null) for(String w:secRu.getKeys(false)) if(!w.matches(".*\\d$")) ru.put(w.toLowerCase(), secRu.getString(w)); if (secEn!=null) for(String w:secEn.getKeys(false)) if(!w.matches(".*\\d$")) en.put(w.toLowerCase(), secEn.getString(w)); var sIr=y.getConfigurationSection("ion_ru"); var sIe=y.getConfigurationSection("ion_en"); if(sIr!=null) for(String w:sIr.getKeys(false)) ionRu.put(w.toLowerCase(), sIr.getString(w)); if(sIe!=null) for(String w:sIe.getKeys(false)) ionEn.put(w.toLowerCase(), sIe.getString(w)); }
|
||||
|
||||
private void createDefault() {
|
||||
file.getParentFile().mkdirs();
|
||||
YamlConfiguration y = new YamlConfiguration();
|
||||
String[] ruWords = {"бля","пипец","ахуеть","кринж","хайп","мем","рофл","чиллить","вайб","имба","флекс","краш","ауф","база","сигма","зашквар","челик","щитпост","дефблог","билд","реворк","ахаха","ору","азаза","кек","чел","чсв","жиза","годнота","треш","пушка","вышка","мемас","найс","топ","агр","дед","хай","пока","спс","пж","норм","че","где","кто","почему","когда","бро","сис","легит","фейк","тролль","хейтер","стан","шип","крипота","душный","токсик","гоу","изи","гг","афк","бан","чит","лаг","пинг","фпс","баг","фикс","нерф","бафф","ульта","крит","хил","лут","дроп","крафт","гринд","фарм","квест","ивент","скилл","левел","экспа","мана","хп","урон","щит","меч","магия","босс","рейд","пвп","пве","вижу","время","майнинг","стройка","привет","какдела","нормально","глянь","дела","спасибо","извини","ок","покедова","дело","человек","игра","мир","сервер","клан","чат","голос","мод","ресурс","настройка","команда","помощь","админ","игрок","друг","войс","дискорд","телега","ссылка","йоу","чекак","банан","круто","топовый","годно","прикольно","угар","жесть","капец","офигеть","блин","ёмоё","йомайо","кошмар","ужас","класс","супер","отлично","крутяк","ого","вау","нихуя","хуйня","пиздец","ебать","сука","блять","нахуй","заебись","охуенно","охуеть","ебаный","пиздатый","охуительно","ахуенно","нихуясебе","ебанись","офигенно","кайф","кайфовый","красава","красавчик","топчик","имбовый","чиловый","вайбовый","кринжовый","рофловый","мемный","флексовый","хайповый","сигмовый","базовый","ауфный","душно","токсично","гриндовый","фармовый","дрочево","задрот","нуб","про","скилловый","хайлевел","лоулевел","бомж","богатый","бедный","крутыш","чсвшный","токсичный","душнила","крашовый","мемас2","рофлан","чиллик","вайбовый2","хайпожор","флексер","крашевый","сигмач","базяра","ауфер","зашкварный","чельный","щитпостер","дефблогер","билдодел","реворкер","ахахский","орущий","азазашный","кекающий","человый","чсвешный","жизненый","годнотский","трешовый","пушечный","вышковый","найсовый","топовый2","агрессивный","дедовый","хайповый2","покатый","спсовый","пэжешный","нормовый","чешный","гдешный","ктошный","почемушный","когдашный","бровский","сисовый","легитный","фейковый","троллевый","хейтерский","становый","шиповый","крипотный","душноватый","токсичный2","гоушный","изишный","гэгэшный","афкашный","банный","читерский","лаговый","пинговый","фпсный","багованный","фиксовый","нерфнутый","баффнутый","ультовый","критовый","хиловый","лутовый","дроповый","крафтовый","гриндозный","фармовый2","квестовый","ивентовый","скилловый2","левеловый","эксповый","мановый","хпешный","уроновый","щитовый","мечевой","магический","боссовый","рейдовый"};
|
||||
String[] ruRepl = {"БЛЯ","ПИПЕЦ","АХУЕТЬ","КРИНЖ","ХАЙП","МЕМ","РОФЛ","ЧИЛЛИТЬ","ВАЙБ","ИМБА","ФЛЕКС","КРАШ","АУФ","БАЗА","СИГМА","ЗАШКВАР","ЧЕЛИК","ЩИТПОСТ","ДЕФБЛОГ","БИЛД","РЕВОРК","АХАХА","ОРУ","АЗАЗА","КЕК","ЧЕЛ","ЧСВ","ЖИЗА","ГОДНОТА","ТРЕШ","ПУШКА","ВЫШКА","МЕМАС","НАЙС","ТОП","АГР","ДЕД","ХАЙ","ПОКА","СПС","ПЖ","НОРМ","ЧЕ","ГДЕ","КТО","ПОЧЕМУ","КОГДА","БРО","СИС","ЛЕГИТ","ФЕЙК","ТРОЛЛЬ","ХЕЙТЕР","СТАН","ШИП","КРИПОТА","ДУШНЫЙ","ТОКСИК","ГОУ","ИЗИ","ГГ","АФК","БАН","ЧИТ","ЛАГ","ПИНГ","ФПС","БАГ","ФИКС","НЕРФ","БАФФ","УЛЬТА","КРИТ","ХИЛ","ЛУТ","ДРОП","КРАФТ","ГРИНД","ФАРМ","КВЕСТ","ИВЕНТ","СКИЛЛ","ЛЕВЕЛ","ЭКСПА","МАНА","ХП","УРОН","ЩИТ","МЕЧ","МАГИЯ","БОСС","РЕЙД","ПВП","ПВЕ","ВИЖУ","ВРЕМЯ","МАЙНИНГ","СТРОЙКА","ПРИВЕТ","КАКДЕЛА","НОРМАЛЬНО","ГЛЯНЬ","ДЕЛА","СПАСИБО","ИЗВИНИ","ОК","ПОКЕДОВА","ДЕЛО","ЧЕЛОВЕК","ИГРА","МИР","СЕРВЕР","КЛАН","ЧАТ","ГОЛОС","МОД","РЕСУРС","НАСТРОЙКА","КОМАНДА","ПОМОЩЬ","АДМИН","ИГРОК","ДРУГ","ВОЙС","ДИСКОРД","ТЕЛЕГА","ССЫЛКА","ЙОУ","ЧЕКАК","БАНАН","КРУТО","ТОПОВЫЙ","ГОДНО","ПРИКОЛЬНО","УГАР","ЖЕСТЬ","КАПЕЦ","ОФИГЕТЬ","БЛИН","ЁМОЁ","ЙОМАЙО","КОШМАР","УЖАС","КЛАСС","СУПЕР","ОТЛИЧНО","КРУТЯК","ОГО","ВАУ","НИХУЯ","ХУЙНЯ","ПИЗДЕЦ","ЕБАТЬ","СУКА","БЛЯТЬ","НАХУЙ","ЗАЕБИСЬ","ОХУЕННО","ОХУЕТЬ","ЕБАНЫЙ","ПИЗДАТЫЙ","ОХУИТЕЛЬНО","АХУЕННО","НИХУЯСЕБЕ","ЕБАНИСЬ","ОФИГЕННО","КАЙФ","КАЙФОВЫЙ","КРАСАВА","КРАСАВЧИК","ТОПЧИК","ИМБОВЫЙ","ЧИЛОВЫЙ","ВАЙБОВЫЙ","КРИНЖОВЫЙ","РОФЛОВЫЙ","МЕМНЫЙ","ФЛЕКСОВЫЙ","ХАЙПОВЫЙ","СИГМОВЫЙ","БАЗОВЫЙ","АУФНЫЙ","ДУШНО","ТОКСИЧНО","ГРИНДОВЫЙ","ФАРМОВЫЙ","ДРОЧЕВО","ЗАДРОТ","НУБ","ПРО","СКИЛЛОВЫЙ","ХАЙЛЕВЕЛ","ЛОУЛЕВЕЛ","БОМЖ","БОГАТЫЙ","БЕДНЫЙ","КРУТЫШ","ЧСВШНЫЙ","ТОКСИЧНЫЙ","ДУШНИЛА","КРАШОВЫЙ","МЕМАС","РОФЛАН","ЧИЛЛИК","ВАЙБОВЫЙ","ХАЙПОЖОР","ФЛЕКСЕР","КРАШЕВЫЙ","СИГМАЧ","БАЗЯРА","АУФЕР","ЗАШКВАРНЫЙ","ЧЕЛЬНЫЙ","ЩИТПОСТЕР","ДЕФБЛОГЕР","БИЛДОДЕЛ","РЕВОРКЕР","АХАХСКИЙ","ОРУЩИЙ","АЗАЗАШНЫЙ","КЕКАЮЩИЙ","ЧЕЛОВЫЙ","ЧСВЕШНЫЙ","ЖИЗНЕНЫЙ","ГОДНОТСКИЙ","ТРЕШОВЫЙ","ПУШЕЧНЫЙ","ВЫШКОВЫЙ","НАЙСОВЫЙ","ТОПОВЫЙ","АГРЕССИВНЫЙ","ДЕДОВЫЙ","ХАЙПОВЫЙ","ПОКАТЫЙ","СПСОВЫЙ","ПЭЖЕШНЫЙ","НОРМОВЫЙ","ЧЕШНЫЙ","ГДЕШНЫЙ","КТОШНЫЙ","ПОЧЕМУШНЫЙ","КОГДАШНЫЙ","БРОВСКИЙ","СИСОВЫЙ","ЛЕГИТНЫЙ","ФЕЙКОВЫЙ","ТРОЛЛЕВЫЙ","ХЕЙТЕРСКИЙ","СТАНОВЫЙ","ШИПОВЫЙ","КРИПОТНЫЙ","ДУШНОВАТЫЙ","ТОКСИЧНЫЙ","ГОУШНЫЙ","ИЗИШНЫЙ","ГЭГЭШНЫЙ","АФКАШНЫЙ","БАННЫЙ","ЧИТЕРСКИЙ","ЛАГОВЫЙ","ПИНГОВЫЙ","ФПСНЫЙ","БАГОВАННЫЙ","ФИКСОВЫЙ","НЕРФНУТЫЙ","БАФФНУТЫЙ","УЛЬТОВЫЙ","КРИТОВЫЙ","ХИЛОВЫЙ","ЛУТОВЫЙ","ДРОПОВЫЙ","КРАФТОВЫЙ","ГРИНДОЗНЫЙ","ФАРМОВЫЙ","КВЕСТОВЫЙ","ИВЕНТОВЫЙ","СКИЛЛОВЫЙ","ЛЕВЕЛОВЫЙ","ЭКСПOВЫЙ","МАНОВЫЙ","ХПЕШНЫЙ","УРОНОВЫЙ","ЩИТОВЫЙ","МЕЧЕВОЙ","МАГИЧЕСКИЙ","БОССОВЫЙ","РЕЙДОВЫЙ"};
|
||||
String[] enWords = {"meme","cringe","rofl","chill","vibe","hype","flex","dead","based","devlog","fix","build","rework","heal","dmg","shield","sword","magic","boss","farm","grind","loot","quest","event","afk","gg","ez","go","bro","sis","legit","fake","troll","hater","stan","ship","creepy","toxic","letsgo","lol","kek","omg","wtf","pog","bruh","sus","skibidi","gigachad","sheesh","yeet","slay","amongus","fr","nah","cap","bet","kekw","poggers","sigma","ohio","gyatt","rizz","fanum","kai","mid","w","l","npc","ratio","clutch","cope","bussin","drip","slaps","fire","lit","bet2","no cap","fr fr","sheesh2","yeet2","slay2","sus2","gigachad2","skibidi2","rizz2","ohio2","gyatt2","fanum2","kai2","mid2","w2","l2","npc2","ratio2","clutch2","cope2","bussin2","drip2","slaps2","fire2","lit2","based2","devlog2","heal2","dmg2","shield2","sword2","magic2","boss2","farm2","grind2","loot2","quest2","event2","afk2","gg2","ez2","go2","bro2","sis2","legit2","fake2","troll2","hater2","see","time","forbidden","method","activity","mining","building","farming","pvp","craft","skill","level","exp","mana","hp","damage","shield2b","sword2b","magic2b","boss2b","raid","pvp2","pve","hello","howareyou","normal","look","things","thanks","sorry","ok","bye","deal","thing","person","game","world","server","clan","chat","voice","mod","resource","setting","command","help","admin","player","friend","discord","telegram","link","yo","wazzup","banana","cool","top","nice","funny","hilarious","insane","crazy","wow","damn","shit","fuck","bitch","ass","hell","dammit","awesome","amazing","great","holy","based3","cringe2","meme2","rofl2","kek2","lol2","bruh2","sus3","gigachad3","slay3","yeet3","sheesh3","bet3","cap3","fr3","nah3","pog3","kekw2","poggers2","ratio3","clutch3","cope3","bussin3","drip3","slaps3","fire3","lit3","mid3","w3","l3","npc3","ohio3","gyatt3","rizz3","skibidi3","gigachad4","sigma2","based4","chill2","vibe2","hype2","flex2","dead2"};
|
||||
String[] enRepl = {"MEME","CRINGE","ROFL","CHILL","VIBE","HYPE","FLEX","DEAD","BASED","DEVLOG","FIX","BUILD","REWORK","HEAL","DMG","SHIELD","SWORD","MAGIC","BOSS","FARM","GRIND","LOOT","QUEST","EVENT","AFK","GG","EZ","GO","BRO","SIS","LEGIT","FAKE","TROLL","HATER","STAN","SHIP","CREEPY","TOXIC","LETSGO","LOL","KEK","OMG","WTF","POG","BRUH","SUS","SKIBIDI","GIGACHAD","SHEESH","YEET","SLAY","AMONGUS","FR","NAH","CAP","BET","KEKW","POGGERS","SIGMA","OHIO","GYATT","RIZZ","FANUM","KAI","MID","W","L","NPC","RATIO","CLUTCH","COPE","BUSSIN","DRIP","SLAPS","FIRE","LIT","BET","NO CAP","FR FR","SHEESH","YEET","SLAY","SUS","GIGACHAD","SKIBIDI","RIZZ","OHIO","GYATT","FANUM","KAI","MID","W","L","NPC","RATIO","CLUTCH","COPE","BUSSIN","DRIP","SLAPS","FIRE","LIT","BASED","DEVLOG","HEAL","DMG","SHIELD","SWORD","MAGIC","BOSS","FARM","GRIND","LOOT","QUEST","EVENT","AFK","GG","EZ","GO","BRO","SIS","LEGIT","FAKE","TROLL","HATER","SEE","TIME","FORBIDDEN","METHOD","ACTIVITY","MINING","BUILDING","FARMING","PVP","CRAFT","SKILL","LEVEL","EXP","MANA","HP","DAMAGE","SHIELD","SWORD","MAGIC","BOSS","RAID","PVP","PVE","HELLO","HOWAREYOU","NORMAL","LOOK","THINGS","THANKS","SORRY","OK","BYE","DEAL","THING","PERSON","GAME","WORLD","SERVER","CLAN","CHAT","VOICE","MOD","RESOURCE","SETTING","COMMAND","HELP","ADMIN","PLAYER","FRIEND","DISCORD","TELEGRAM","LINK","YO","WAZZUP","BANANA","COOL","TOP","NICE","FUNNY","HILARIOUS","INSANE","CRAZY","WOW","DAMN","SHIT","FUCK","BITCH","ASS","HELL","DAMMIT","AWESOME","AMAZING","GREAT","HOLY","BASED","CRINGE","MEME","ROFL","KEK","LOL","BRUH","SUS","GIGACHAD","SLAY","YEET","SHEESH","BET","CAP","FR","NAH","POG","KEKW","POGGERS","RATIO","CLUTCH","COPE","BUSSIN","DRIP","SLAPS","FIRE","LIT","MID","W","L","NPC","OHIO","GYATT","RIZZ","SKIBIDI","GIGACHAD","SIGMA","BASED","CHILL","VIBE","HYPE","FLEX","DEAD"};
|
||||
y.set("ru_words.note", "200 ru words CAPS in [] 25% activity block else 10% double");
|
||||
for (int i=0;i<Math.min(ruWords.length, ruRepl.length) && i<200;i++) y.set("ru_words." + ruWords[i], ruRepl[i]);
|
||||
y.set("en_words.note", "200 en words CAPS in [] 25% activity block else 10% double");
|
||||
for (int i=0;i<Math.min(enWords.length, enRepl.length) && i<200;i++) y.set("en_words." + enWords[i], enRepl[i]);
|
||||
y.set("ion_ru.note", "money to [ЙОНЫ]");
|
||||
y.set("ion_ru.деньги","[ЙОНЫ]"); y.set("ion_ru.денег","[ЙОНЫ]"); y.set("ion_ru.алмазы","[ЙОНЫ]"); y.set("ion_ru.алмаз","[ЙОНЫ]"); y.set("ion_ru.незерит","[ЙОНЫ]"); y.set("ion_ru.незерита","[ЙОНЫ]"); y.set("ion_ru.золото","[ЙОНЫ]"); y.set("ion_ru.золота","[ЙОНЫ]"); y.set("ion_ru.изумруды","[ЙОНЫ]"); y.set("ion_ru.изумруд","[ЙОНЫ]");
|
||||
y.set("ion_en.note", "money to [ION]");
|
||||
y.set("ion_en.money","[ION]"); y.set("ion_en.diamonds","[ION]"); y.set("ion_en.diamond","[ION]"); y.set("ion_en.netherite","[ION]"); y.set("ion_en.gold","[ION]"); y.set("ion_en.emeralds","[ION]"); y.set("ion_en.emerald","[ION]");
|
||||
try { y.save(file); } catch (Exception e) { plugin.getLogger().warning("Failed create chat.yml: " + e.getMessage()); }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
package me.sashegdev.blackknife;
|
||||
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import java.util.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class ChatHandler implements Listener {
|
||||
private final BlackKnifePlugin plugin;
|
||||
private final ChatConfig cfg;
|
||||
private static final Pattern LINK = Pattern.compile("(?i)(https?://\\S+|www\\.\\S+|discord\\.gg/\\S+|discord\\.com/invite/\\S+|t\\.me/\\S+)");
|
||||
private static final Pattern LAUGH_RU = Pattern.compile("^(ха|аха|хи|хе|хо|хы|ах|хаха|ахаха|хихи|хехе|хохо|хахаха|ахахаха)+$", Pattern.CASE_INSENSITIVE);
|
||||
private static final Pattern LAUGH_RU2 = Pattern.compile("^[хахиоеёу]+$", Pattern.CASE_INSENSITIVE);
|
||||
private static final Pattern LAUGH_EN = Pattern.compile("^(ha|haha|hehe|hihi|hoho|ah|ahah|lol|lmao|rofl|kek|lul)+$", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
public ChatHandler(BlackKnifePlugin plugin, ChatConfig cfg) { this.plugin = plugin; this.cfg = cfg; }
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onChat(AsyncChatEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if (!BlackKnifeItem.is(p.getInventory().getItemInMainHand()) && !BlackKnifeItem.is(p.getInventory().getItemInOffHand())) return;
|
||||
String plain = net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer.plainText().serialize(e.message());
|
||||
if (plain.isBlank()) return;
|
||||
e.message(build(p, plain));
|
||||
}
|
||||
|
||||
private Component build(Player sender, String msg) {
|
||||
String[] rawTokens = msg.split(" ");
|
||||
Map<String,String> nickMap = new HashMap<>();
|
||||
for (Player pl : plugin.getServer().getOnlinePlayers()) nickMap.put(pl.getName().toLowerCase(), pl.getName());
|
||||
List<Component> parts = new ArrayList<>();
|
||||
for (int i = 0; i < rawTokens.length; i++) {
|
||||
String tok = rawTokens[i];
|
||||
String low = tok.toLowerCase().replaceAll("[^\\p{L}0-9]", "");
|
||||
String trail = "";
|
||||
if (!tok.isEmpty() && !Character.isLetterOrDigit(tok.charAt(tok.length()-1))) {
|
||||
trail = tok.substring(tok.length()-1);
|
||||
if (",.!?;:".indexOf(trail) == -1) trail = "";
|
||||
}
|
||||
Component c;
|
||||
if (!low.isEmpty() && nickMap.containsKey(low)) {
|
||||
String nick = nickMap.get(low);
|
||||
String bracket = "[" + nick.toUpperCase() + "]";
|
||||
c = Component.text(bracket).color(NamedTextColor.YELLOW).decorate(TextDecoration.BOLD).hoverEvent(HoverEvent.showText(Component.text("Player: " + nick)));
|
||||
if (Math.random() < 0.10) c = c.append(Component.text(" ")).append(Component.text(bracket).color(NamedTextColor.YELLOW).decorate(TextDecoration.BOLD).hoverEvent(HoverEvent.showText(Component.text("Player: " + nick))));
|
||||
} else if (LINK.matcher(tok).find()) {
|
||||
String url = tok;
|
||||
if (!url.toLowerCase().startsWith("http")) url = "https://" + url;
|
||||
boolean isRu = sender.locale().getLanguage().equalsIgnoreCase("ru");
|
||||
String blocked = isRu ? "[ГИПЕРССЫЛКА ЗАБЛОКИРОВАНА]" : "[HYPERLINK BLOCKED]";
|
||||
c = Component.text(blocked).color(NamedTextColor.AQUA).decorate(TextDecoration.UNDERLINED).clickEvent(ClickEvent.openUrl(url)).hoverEvent(HoverEvent.showText(Component.text(tok)));
|
||||
} else if (!low.isEmpty() && isIon(low, sender)) {
|
||||
boolean isRu = low.matches(".*[а-яё].*");
|
||||
String ion = isRu ? "[ЙОНЫ]" : "[ION]";
|
||||
c = Component.text(ion).color(NamedTextColor.GOLD).decorate(TextDecoration.BOLD);
|
||||
if (Math.random() < 0.10) c = c.append(Component.text(" ")).append(Component.text(ion).color(NamedTextColor.GOLD).decorate(TextDecoration.BOLD));
|
||||
if (!trail.isEmpty()) c = c.append(Component.text(trail).color(NamedTextColor.GOLD));
|
||||
} else if (!low.isEmpty()) {
|
||||
String laugh = getLaughReplacement(low);
|
||||
if (laugh != null) {
|
||||
String bracket = "[" + laugh + "]";
|
||||
c = Component.text(bracket).color(NamedTextColor.LIGHT_PURPLE).decorate(TextDecoration.BOLD);
|
||||
if (Math.random() < 0.10) c = c.append(Component.text(" ")).append(Component.text(bracket).color(NamedTextColor.LIGHT_PURPLE).decorate(TextDecoration.BOLD));
|
||||
} else if (isActivity(low) && Math.random() < 0.25) {
|
||||
boolean isRu = low.matches(".*[а-яё].*");
|
||||
String block = isRu ? "[ЗАПРЕЩЁННЫЙ МЕТОД ДЕЯТЕЛЬНОСТИ]" : "[FORBIDDEN METHOD OF ACTIVITY]";
|
||||
c = Component.text(block).color(NamedTextColor.DARK_PURPLE).decorate(TextDecoration.BOLD);
|
||||
if (Math.random() < 0.10) c = c.append(Component.text(" ")).append(Component.text(block).color(NamedTextColor.DARK_PURPLE).decorate(TextDecoration.BOLD));
|
||||
} else {
|
||||
boolean isRu = low.matches(".*[а-яё].*");
|
||||
Map<String,String> dict = isRu ? cfg.ru : cfg.en;
|
||||
String repl = findClosest(low, dict);
|
||||
if (repl != null && Math.random() < 0.20) {
|
||||
String bracket = "[" + repl.toUpperCase() + "]";
|
||||
c = Component.text(bracket).color(NamedTextColor.LIGHT_PURPLE).decorate(TextDecoration.BOLD);
|
||||
if (Math.random() < 0.10) c = c.append(Component.text(" ")).append(Component.text(bracket).color(NamedTextColor.LIGHT_PURPLE).decorate(TextDecoration.BOLD));
|
||||
} else {
|
||||
c = Component.text(tok);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
c = Component.text(tok);
|
||||
}
|
||||
parts.add(c);
|
||||
}
|
||||
Component out = Component.empty();
|
||||
for (int i = 0; i < parts.size(); i++) {
|
||||
if (i > 0) out = out.append(Component.text(" "));
|
||||
out = out.append(parts.get(i));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
private String findClosest(String low, Map<String,String> dict) {
|
||||
String exact = dict.get(low);
|
||||
if (exact != null) return exact;
|
||||
String best = null;
|
||||
double bestScore = 0.90;
|
||||
for (var e : dict.entrySet()) {
|
||||
double sim = similarity(low, e.getKey());
|
||||
if (sim >= bestScore) { bestScore = sim; best = e.getValue(); }
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
private double similarity(String a, String b) {
|
||||
int maxLen = Math.max(a.length(), b.length());
|
||||
if (maxLen == 0) return 1.0;
|
||||
int dist = levenshtein(a, b);
|
||||
return (maxLen - dist) / (double) maxLen;
|
||||
}
|
||||
|
||||
private int levenshtein(String a, String b) {
|
||||
int n = a.length(), m = b.length();
|
||||
if (n == 0) return m;
|
||||
if (m == 0) return n;
|
||||
int[] prev = new int[m+1];
|
||||
int[] cur = new int[m+1];
|
||||
for (int j=0;j<=m;j++) prev[j]=j;
|
||||
for (int i=1;i<=n;i++) {
|
||||
cur[0]=i;
|
||||
for (int j=1;j<=m;j++) {
|
||||
int cost = a.charAt(i-1)==b.charAt(j-1) ? 0 : 1;
|
||||
cur[j]=Math.min(Math.min(cur[j-1]+1, prev[j]+1), prev[j-1]+cost);
|
||||
}
|
||||
int[] tmp=prev; prev=cur; cur=tmp;
|
||||
}
|
||||
return prev[m];
|
||||
}
|
||||
|
||||
private String getLaughReplacement(String low) {
|
||||
if (low.length() < 2) return null;
|
||||
if (low.matches(".*[а-яё].*")) {
|
||||
if (low.equals("лол")) return "ЛОЛ";
|
||||
if (low.equals("кек")) return "КЕК";
|
||||
if (low.equals("азаза")) return "АЗАЗА";
|
||||
if (low.equals("лмао") || low.equals("lmao")) return "LMAO";
|
||||
if (LAUGH_RU.matcher(low).matches() || (LAUGH_RU2.matcher(low).matches() && low.contains("х"))) return "АХАХА";
|
||||
if (low.matches("^(лол|кек|азаза)+$")) return low.toUpperCase();
|
||||
} else {
|
||||
String l = low.toLowerCase();
|
||||
if (l.equals("lol")) return "LOL";
|
||||
if (l.equals("lmao")) return "LMAO";
|
||||
if (l.equals("rofl")) return "ROFL";
|
||||
if (l.equals("kek")) return "KEK";
|
||||
if (l.equals("lul")) return "LUL";
|
||||
if (l.equals("omg")) return "OMG";
|
||||
if (l.equals("wtf")) return "WTF";
|
||||
if (LAUGH_EN.matcher(low).matches()) return "HAHA";
|
||||
if (low.matches("^(lol|kek|lmao|rofl|haha|hehe|hihi|hoho|ahah|hah|lul|omg|wtf)+$")) return l.toUpperCase();
|
||||
if (low.matches("^(ha|he|hi|ho|ah)+$")) return "HAHA";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final Set<String> ACTIVITY_RU = Set.of("крафт","крафтить","крафчу","фарм","фармить","фармлю","поиск","искать","ищу","торговля","торговать","торгую","общение","общаться","общаюсь","майнинг","копать","копаю","стройка","строить","строю","гринд","гриндить","гриндю","добыча","добывать","добываю","рыбалка","рыбачить","охота","охотиться","готовка","готовить","готовлю","шить","пошив","обмен","обменивать","продажа","продавать","покупка","покупать","торг","аукцион");
|
||||
private static final Set<String> ACTIVITY_EN = Set.of("craft","crafting","farm","farming","search","searching","trade","trading","communicate","communicating","mining","mine","building","build","grind","grinding","hunt","hunting","fish","fishing","cook","cooking","sew","exchange","sell","buy","auction");
|
||||
|
||||
private boolean isActivity(String low) {
|
||||
for (String k : ACTIVITY_RU) if (low.equals(k) || similarity(low,k) >= 0.90) return true;
|
||||
for (String k : ACTIVITY_EN) if (low.equals(k) || similarity(low,k) >= 0.90) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isIon(String low, Player sender) {
|
||||
for (String k : cfg.ionRu.keySet()) if (low.startsWith(k) || k.startsWith(low) || similarity(low,k) >= 0.90) return true;
|
||||
for (String k : cfg.ionEn.keySet()) if (low.startsWith(k) || k.startsWith(low) || similarity(low,k) >= 0.90) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void reload() { cfg.load(); }
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
package me.sashegdev.blackknife;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.BlockDisplay;
|
||||
import org.bukkit.entity.Display;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class DiamondAttack {
|
||||
public static boolean tryUse(Player p, TensionManager tension) {
|
||||
if (tension.getTP(p) < 25f) { p.sendActionBar(net.kyori.adventure.text.Component.text("Need 10% TP").color(net.kyori.adventure.text.format.NamedTextColor.RED)); return false; }
|
||||
tension.setTP(p, tension.getTP(p) - 25f);
|
||||
Location eye = p.getEyeLocation();
|
||||
Vector dir = eye.getDirection().normalize();
|
||||
Location spawn = eye.clone().add(dir.clone().multiply(1.5));
|
||||
BlockDisplay crystal = p.getWorld().spawn(spawn, BlockDisplay.class, d -> {
|
||||
d.setBlock(Material.AMETHYST_BLOCK.createBlockData());
|
||||
d.setBrightness(new Display.Brightness(15, 15));
|
||||
d.setViewRange(64);
|
||||
});
|
||||
p.getWorld().playSound(spawn, Sound.BLOCK_AMETHYST_BLOCK_PLACE, 1f, 0.9f);
|
||||
p.getWorld().playSound(spawn, Sound.BLOCK_AMETHYST_BLOCK_CHIME, 1f, 1.5f);
|
||||
Vector vel = dir.clone().multiply(1.5);
|
||||
BlackKnifePlugin plugin = BlackKnifePlugin.getPlugin(BlackKnifePlugin.class);
|
||||
new BukkitRunnable() {
|
||||
@Override public void run() {
|
||||
if (!crystal.isValid() || crystal.isDead()) { cancel(); return; }
|
||||
Location cur = crystal.getLocation();
|
||||
Location nl = cur.clone().add(vel);
|
||||
Location next = nl.clone().add(vel);
|
||||
boolean hitBlock = next.getBlock().isSolid();
|
||||
if (hitBlock) {
|
||||
Location expl = cur.clone().add(vel.clone().normalize().multiply(-0.1));
|
||||
crystal.teleport(expl);
|
||||
crystal.remove();
|
||||
cancel();
|
||||
expl.getWorld().spawnParticle(Particle.EXPLOSION, expl, 1);
|
||||
expl.getWorld().playSound(expl, Sound.ENTITY_GENERIC_EXPLODE, 1f, 1.2f);
|
||||
Vector[] dirs = { new Vector(1,0,0), new Vector(-1,0,0), new Vector(0,0,1), new Vector(0,0,-1), new Vector(1,0,1).normalize(), new Vector(-1,0,1).normalize(), new Vector(1,0,-1).normalize(), new Vector(-1,0,-1).normalize() };
|
||||
for (Vector d : dirs) {
|
||||
BlockDisplay shard = p.getWorld().spawn(expl, BlockDisplay.class, s -> {
|
||||
s.setBlock(Material.MEDIUM_AMETHYST_BUD.createBlockData());
|
||||
s.setBrightness(new Display.Brightness(15, 15));
|
||||
s.setViewRange(64);
|
||||
});
|
||||
Vector sv = d.clone().multiply(0.4);
|
||||
new BukkitRunnable() {
|
||||
@Override public void run() {
|
||||
if (!shard.isValid()) { cancel(); return; }
|
||||
Location cur2 = shard.getLocation();
|
||||
Location n2 = cur2.clone().add(sv);
|
||||
if (n2.getBlock().isSolid()) {
|
||||
Location expl2 = cur2.clone().add(sv.clone().normalize().multiply(-0.1));
|
||||
shard.teleport(expl2);
|
||||
shard.remove();
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
shard.teleport(n2);
|
||||
n2.getWorld().spawnParticle(Particle.CRIT, n2, 1, 0.05, 0.05, 0.05, 0);
|
||||
for (var ent : n2.getWorld().getNearbyEntities(n2, 0.7, 0.7, 0.7, e -> e instanceof LivingEntity && e != p)) {
|
||||
LivingEntity le = (LivingEntity) ent;
|
||||
le.getPersistentDataContainer().set(SwoonHandler.MAGIC_DAMAGE, PersistentDataType.BYTE, (byte) 1);
|
||||
le.damage(2.0, p);
|
||||
shard.remove();
|
||||
cancel();
|
||||
break;
|
||||
}
|
||||
for (Player pl : n2.getWorld().getNearbyPlayers(n2, 0.9)) {
|
||||
if (pl == p) continue;
|
||||
double d2 = pl.getLocation().add(0, 1, 0).distanceSquared(n2);
|
||||
if (d2 > 0.25 && d2 < 0.81) {
|
||||
BlackKnifePlugin.getPlugin(BlackKnifePlugin.class).getTension().addTP(pl, 2.5f, "DODGE +1%");
|
||||
pl.getWorld().spawnParticle(Particle.DUST, pl.getLocation().add(0, 0.25, 0), 25, 0.5, 0.05, 0.5, 0, new Particle.DustOptions(Color.fromRGB(255, 255, 255), 0.15f));
|
||||
}
|
||||
}
|
||||
if (shard.getTicksLived() > 40) { shard.remove(); cancel(); }
|
||||
}
|
||||
}.runTaskTimer(plugin, 1L, 1L);
|
||||
}
|
||||
return;
|
||||
}
|
||||
crystal.teleport(nl);
|
||||
crystal.getWorld().spawnParticle(Particle.END_ROD, nl, 1, 0.05, 0.05, 0.05, 0);
|
||||
crystal.getWorld().spawnParticle(Particle.DUST, nl, 1, 0, 0, 0, 0, new Particle.DustOptions(Color.fromRGB(180, 0, 255), 1f));
|
||||
boolean hit = false;
|
||||
for (var ent : nl.getWorld().getNearbyEntities(nl, 0.7, 0.7, 0.7, e -> e instanceof LivingEntity && e != p)) {
|
||||
LivingEntity le = (LivingEntity) ent;
|
||||
le.getPersistentDataContainer().set(SwoonHandler.MAGIC_DAMAGE, PersistentDataType.BYTE, (byte) 1);
|
||||
le.damage(5.0, p);
|
||||
hit = true;
|
||||
break;
|
||||
}
|
||||
for (Player pl : nl.getWorld().getNearbyPlayers(nl, 0.9)) {
|
||||
if (pl == p) continue;
|
||||
double d = pl.getLocation().add(0, 1, 0).distanceSquared(nl);
|
||||
if (d > 0.25 && d < 0.81) {
|
||||
BlackKnifePlugin.getPlugin(BlackKnifePlugin.class).getTension().addTP(pl, 2.5f, "DODGE +1%");
|
||||
pl.getWorld().spawnParticle(Particle.DUST, pl.getLocation().add(0, 0.25, 0), 25, 0.5, 0.05, 0.5, 0, new Particle.DustOptions(Color.fromRGB(255, 255, 255), 0.15f));
|
||||
}
|
||||
}
|
||||
if (hit) {
|
||||
Location expl = nl.clone();
|
||||
crystal.remove();
|
||||
cancel();
|
||||
expl.getWorld().spawnParticle(Particle.EXPLOSION, expl, 1);
|
||||
expl.getWorld().playSound(expl, Sound.ENTITY_GENERIC_EXPLODE, 1f, 1.2f);
|
||||
Vector[] dirs = { new Vector(1,0,0), new Vector(-1,0,0), new Vector(0,0,1), new Vector(0,0,-1), new Vector(1,0,1).normalize(), new Vector(-1,0,1).normalize(), new Vector(1,0,-1).normalize(), new Vector(-1,0,-1).normalize() };
|
||||
for (Vector d : dirs) {
|
||||
BlockDisplay shard = p.getWorld().spawn(expl, BlockDisplay.class, s -> {
|
||||
s.setBlock(Material.MEDIUM_AMETHYST_BUD.createBlockData());
|
||||
s.setBrightness(new Display.Brightness(15, 15));
|
||||
s.setViewRange(64);
|
||||
});
|
||||
Vector sv = d.clone().multiply(0.4);
|
||||
new BukkitRunnable() {
|
||||
@Override public void run() {
|
||||
if (!shard.isValid()) { cancel(); return; }
|
||||
Location cur2 = shard.getLocation();
|
||||
Location n2 = cur2.clone().add(sv);
|
||||
if (n2.getBlock().isSolid()) {
|
||||
Location expl2 = cur2.clone().add(sv.clone().normalize().multiply(-0.1));
|
||||
shard.teleport(expl2);
|
||||
shard.remove();
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
shard.teleport(n2);
|
||||
shard.getWorld().spawnParticle(Particle.CRIT, n2, 1, 0.05, 0.05, 0.05, 0);
|
||||
for (var ent : n2.getWorld().getNearbyEntities(n2, 0.7, 0.7, 0.7, e -> e instanceof LivingEntity && e != p)) {
|
||||
LivingEntity le = (LivingEntity) ent;
|
||||
le.getPersistentDataContainer().set(SwoonHandler.MAGIC_DAMAGE, PersistentDataType.BYTE, (byte) 1);
|
||||
le.damage(2.0, p); shard.remove(); cancel(); break;
|
||||
}
|
||||
for (Player pl : n2.getWorld().getNearbyPlayers(n2, 0.9)) {
|
||||
if (pl == p) continue;
|
||||
double d2 = pl.getLocation().add(0, 1, 0).distanceSquared(n2);
|
||||
if (d2 > 0.25 && d2 < 0.81) {
|
||||
BlackKnifePlugin.getPlugin(BlackKnifePlugin.class).getTension().addTP(pl, 2.5f, "DODGE +1%");
|
||||
pl.getWorld().spawnParticle(Particle.DUST, pl.getLocation().add(0, 0.25, 0), 25, 0.5, 0.05, 0.5, 0, new Particle.DustOptions(Color.fromRGB(255, 255, 255), 0.15f));
|
||||
}
|
||||
}
|
||||
if (shard.getTicksLived() > 40) { shard.remove(); cancel(); }
|
||||
}
|
||||
}.runTaskTimer(plugin, 1L, 1L);
|
||||
}
|
||||
} else if (crystal.getTicksLived() > 60) { crystal.remove(); cancel(); }
|
||||
}
|
||||
}.runTaskTimer(plugin, 1L, 1L);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package me.sashegdev.blackknife;
|
||||
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Display;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
public class EntityTracker {
|
||||
public static final NamespacedKey BK_MARK = new NamespacedKey("blackknife", "bk_entity");
|
||||
private static final java.util.Set<java.util.UUID> tracked = java.util.Collections.synchronizedSet(new java.util.HashSet<>());
|
||||
|
||||
public static void mark(Entity e) {
|
||||
e.getPersistentDataContainer().set(BK_MARK, PersistentDataType.BYTE, (byte) 1);
|
||||
tracked.add(e.getUniqueId());
|
||||
}
|
||||
|
||||
public static void untrack(Entity e) {
|
||||
tracked.remove(e.getUniqueId());
|
||||
}
|
||||
|
||||
public static int cleanup(BlackKnifePlugin plugin) {
|
||||
int count = 0;
|
||||
for (var world : plugin.getServer().getWorlds()) {
|
||||
for (var e : world.getEntitiesByClasses(Display.class, org.bukkit.entity.Marker.class, org.bukkit.entity.TextDisplay.class)) {
|
||||
boolean isBk = e.getPersistentDataContainer().has(BK_MARK, PersistentDataType.BYTE) || tracked.contains(e.getUniqueId());
|
||||
if (!isBk && e instanceof org.bukkit.entity.BlockDisplay bd) {
|
||||
var mat = bd.getBlock().getMaterial();
|
||||
if (mat == org.bukkit.Material.DEEPSLATE_TILES || mat == org.bukkit.Material.SCULK_CATALYST || mat == org.bukkit.Material.AMETHYST_BLOCK || mat == org.bukkit.Material.MEDIUM_AMETHYST_BUD) isBk = true;
|
||||
}
|
||||
if (e instanceof org.bukkit.entity.TextDisplay td) {
|
||||
if (td.getPersistentDataContainer().has(new NamespacedKey("blackknife", "knocked"), PersistentDataType.BYTE)) isBk = true;
|
||||
}
|
||||
if (isBk) { e.remove(); count++; }
|
||||
}
|
||||
}
|
||||
for (var uuid : new java.util.HashSet<>(tracked)) {
|
||||
var e = plugin.getServer().getEntity(uuid);
|
||||
if (e != null && e.isValid()) { e.remove(); count++; }
|
||||
}
|
||||
tracked.clear();
|
||||
if (plugin.getTension() != null) plugin.getTension().hideAll();
|
||||
for (var p : plugin.getServer().getOnlinePlayers()) {
|
||||
var copy = new java.util.ArrayList<net.kyori.adventure.bossbar.BossBar>();
|
||||
for (var b : p.activeBossBars()) copy.add(b);
|
||||
for (var bar : copy) p.hideBossBar(bar);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
package me.sashegdev.blackknife;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Display;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TextDisplay;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class KnockedHandler implements Listener {
|
||||
private final BlackKnifePlugin plugin;
|
||||
private final NamespacedKey KNOCKED = new NamespacedKey("blackknife", "knocked");
|
||||
private final NamespacedKey VHP = new NamespacedKey("blackknife", "vhp");
|
||||
private final Map<UUID, TextDisplay> displays = new HashMap<>();
|
||||
|
||||
public KnockedHandler(BlackKnifePlugin plugin) { this.plugin = plugin; }
|
||||
|
||||
@EventHandler
|
||||
public void onDamage(EntityDamageEvent e) {
|
||||
if (!(e.getEntity() instanceof Player p)) return;
|
||||
if (p.getPersistentDataContainer().has(KNOCKED, PersistentDataType.BYTE)) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
double dmg = e.getFinalDamage();
|
||||
double health = p.getHealth();
|
||||
if (dmg < health) return;
|
||||
var nearby = p.getWorld().getNearbyEntities(p.getLocation(), 8, 8, 8, en -> en instanceof Player && en != p && !((Player)en).getPersistentDataContainer().has(KNOCKED, PersistentDataType.BYTE));
|
||||
long attackers = 0;
|
||||
if (e instanceof org.bukkit.event.entity.EntityDamageByEntityEvent ev && ev.getDamager() instanceof Player) attackers = 1;
|
||||
boolean hasAlly = !nearby.isEmpty();
|
||||
if (!hasAlly) {
|
||||
return;
|
||||
}
|
||||
e.setCancelled(true);
|
||||
double vhp = health - dmg;
|
||||
p.getPersistentDataContainer().set(KNOCKED, PersistentDataType.BYTE, (byte) 1);
|
||||
p.getPersistentDataContainer().set(VHP, PersistentDataType.DOUBLE, vhp);
|
||||
p.setHealth(1.0);
|
||||
p.setWalkSpeed(0f);
|
||||
p.addPotionEffect(new org.bukkit.potion.PotionEffect(PotionEffectType.WEAKNESS, 100000, 10, false, false));
|
||||
TextDisplay td = p.getWorld().spawn(p.getLocation().add(0, 2.4, 0), TextDisplay.class, d -> {
|
||||
d.text(Component.text(String.format("%.0f HP", vhp)).color(vhp < 0 ? NamedTextColor.RED : NamedTextColor.YELLOW));
|
||||
d.setBillboard(Display.Billboard.CENTER);
|
||||
d.setSeeThrough(true);
|
||||
d.setShadowed(true);
|
||||
d.setBackgroundColor(org.bukkit.Color.fromARGB(64, 0, 0, 0));
|
||||
d.setAlignment(TextDisplay.TextAlignment.CENTER);
|
||||
});
|
||||
displays.put(p.getUniqueId(), td);
|
||||
p.sendActionBar(Component.text(String.format("KNOCKED %.0f HP - regen potion to revive", vhp)).color(NamedTextColor.RED));
|
||||
plugin.getServer().getScheduler().runTaskTimer(plugin, task -> {
|
||||
TextDisplay d = displays.get(p.getUniqueId());
|
||||
if (d == null || !p.isOnline() || !p.getPersistentDataContainer().has(KNOCKED, PersistentDataType.BYTE)) { task.cancel(); return; }
|
||||
d.teleport(p.getLocation().add(0, 2.4, 0));
|
||||
if (p.isDead()) { d.remove(); task.cancel(); }
|
||||
}, 2L, 2L);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if (!p.getPersistentDataContainer().has(KNOCKED, PersistentDataType.BYTE)) return;
|
||||
if (e.getFrom().distanceSquared(e.getTo()) < 0.01) return;
|
||||
double dx = e.getTo().getX() - e.getFrom().getX();
|
||||
double dz = e.getTo().getZ() - e.getFrom().getZ();
|
||||
if (Math.abs(dx) > 0.1 || Math.abs(dz) > 0.1) {
|
||||
e.setCancelled(true);
|
||||
p.sendActionBar(Component.text("Knocked - can't move, regen potion to revive").color(NamedTextColor.RED));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPotionSplash(org.bukkit.event.entity.PotionSplashEvent e) {
|
||||
if (e.getPotion().getEffects().stream().noneMatch(ef -> ef.getType().equals(PotionEffectType.REGENERATION))) return;
|
||||
for (LivingEntity ent : e.getAffectedEntities()) {
|
||||
if (!(ent instanceof Player p)) continue;
|
||||
if (!p.getPersistentDataContainer().has(KNOCKED, PersistentDataType.BYTE)) continue;
|
||||
double intensity = e.getIntensity(p);
|
||||
double heal = 4 * intensity;
|
||||
Double vhp = p.getPersistentDataContainer().get(VHP, PersistentDataType.DOUBLE);
|
||||
if (vhp == null) vhp = -10.0;
|
||||
double newVhp = vhp + heal;
|
||||
p.getPersistentDataContainer().set(VHP, PersistentDataType.DOUBLE, newVhp);
|
||||
TextDisplay td = displays.get(p.getUniqueId());
|
||||
if (td != null) td.text(Component.text(String.format("%.0f HP", newVhp)).color(newVhp < 0 ? NamedTextColor.RED : NamedTextColor.GREEN));
|
||||
if (newVhp >= 1) {
|
||||
p.getPersistentDataContainer().remove(KNOCKED);
|
||||
p.getPersistentDataContainer().remove(VHP);
|
||||
p.setHealth(1.0);
|
||||
p.setWalkSpeed(0.2f);
|
||||
p.removePotionEffect(PotionEffectType.WEAKNESS);
|
||||
p.removePotionEffect(PotionEffectType.SLOWNESS);
|
||||
if (td != null) { td.remove(); displays.remove(p.getUniqueId()); }
|
||||
p.sendActionBar(Component.text("Revived!").color(NamedTextColor.GREEN));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDeath(PlayerDeathEvent e) {
|
||||
displays.remove(e.getEntity().getUniqueId());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,488 @@
|
||||
package me.sashegdev.blackknife;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.BlockDisplay;
|
||||
import org.bukkit.entity.Display;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class LungeAttack {
|
||||
public static boolean tryUse(Player p, TensionManager tension, LivingEntity target) {
|
||||
if (target == null || !target.isValid() || target.isDead()) {
|
||||
p.sendActionBar(Component.text("No target! Look at entity within 120 blocks").color(NamedTextColor.RED));
|
||||
return false;
|
||||
}
|
||||
if (!canSeeTarget(p, target)) {
|
||||
p.sendActionBar(Component.text("Target blocked by wall!").color(NamedTextColor.RED));
|
||||
return false;
|
||||
}
|
||||
if (tension.getTP(p) < 225f) {
|
||||
p.sendActionBar(Component.text("Need 90% TP").color(NamedTextColor.RED));
|
||||
return false;
|
||||
}
|
||||
tension.setTP(p, tension.getTP(p) - 225f);
|
||||
tension.startBattle(p, target);
|
||||
Location start = p.getEyeLocation().clone();
|
||||
BlackKnifePlugin plugin = BlackKnifePlugin.getPlugin(BlackKnifePlugin.class);
|
||||
|
||||
BlockDisplay catalyst = p.getWorld().spawn(start, BlockDisplay.class, d -> {
|
||||
d.setBlock(Material.SCULK_CATALYST.createBlockData());
|
||||
d.setBrightness(new Display.Brightness(15, 15));
|
||||
d.setViewRange(64);
|
||||
});
|
||||
p.getWorld().playSound(start, Sound.BLOCK_SCULK_CATALYST_BLOOM, 1f, 0.7f);
|
||||
double catSpeed = 3.0;
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override public void run() {
|
||||
if (!target.isValid() || target.isDead()) { if (catalyst.isValid()) catalyst.remove(); cancel(); return; }
|
||||
if (!catalyst.isValid()) { cancel(); return; }
|
||||
Location cur = catalyst.getLocation();
|
||||
Location tpos = target.getLocation().clone().add(0, 1, 0);
|
||||
Vector catDir = tpos.clone().subtract(cur).toVector().normalize();
|
||||
Location nl = cur.clone().add(catDir.clone().multiply(catSpeed));
|
||||
catalyst.teleport(nl);
|
||||
nl.getWorld().spawnParticle(Particle.SCULK_SOUL, nl, 2, 0.15, 0.15, 0.15, 0.02);
|
||||
nl.getWorld().spawnParticle(Particle.DUST, nl, 1, 0, 0, 0, 0, new Particle.DustOptions(Color.fromRGB(20, 60, 80), 1f));
|
||||
if (nl.distanceSquared(tpos) < 4) {
|
||||
catalyst.teleport(tpos);
|
||||
catalyst.remove();
|
||||
cancel();
|
||||
tpos.getWorld().spawnParticle(Particle.EXPLOSION, tpos, 1);
|
||||
tpos.getWorld().playSound(tpos, Sound.BLOCK_SCULK_CATALYST_BLOOM, 1f, 0.5f);
|
||||
tpos.getWorld().playSound(tpos, Sound.ENTITY_WARDEN_SONIC_BOOM, 1f, 0.6f);
|
||||
startPhase1(p, tpos, target, plugin);
|
||||
}
|
||||
if (catalyst.getTicksLived() > 80) { catalyst.remove(); cancel(); }
|
||||
}
|
||||
}.runTaskTimer(plugin, 1L, 1L);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean canSeeTarget(Player p, LivingEntity target) {
|
||||
if (!p.hasLineOfSight(target)) return false;
|
||||
var ray = p.getWorld().rayTraceBlocks(p.getEyeLocation(), p.getEyeLocation().getDirection().normalize(), 120);
|
||||
if (ray != null && ray.getHitBlock() != null) {
|
||||
double blockDist = ray.getHitBlock().getLocation().distanceSquared(p.getEyeLocation());
|
||||
double entDist = target.getLocation().add(0, 1, 0).distanceSquared(p.getEyeLocation());
|
||||
if (blockDist + 1 < entDist) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean trySnipe(Player p, TensionManager tension, LivingEntity target) {
|
||||
if (target == null || !target.isValid() || target.isDead()) {
|
||||
p.sendActionBar(Component.text("No target! Look at entity within 120 blocks").color(NamedTextColor.RED));
|
||||
return false;
|
||||
}
|
||||
if (!canSeeTarget(p, target)) {
|
||||
p.sendActionBar(Component.text("Target blocked by wall!").color(NamedTextColor.RED));
|
||||
return false;
|
||||
}
|
||||
if (tension.getTP(p) < 62.5f) {
|
||||
p.sendActionBar(Component.text("Need 25% TP").color(NamedTextColor.RED));
|
||||
return false;
|
||||
}
|
||||
tension.setTP(p, tension.getTP(p) - 62.5f);
|
||||
tension.startBattle(p, target);
|
||||
spawnLungeSword(p, target, 20);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean tryTri(Player p, TensionManager tension, LivingEntity target) {
|
||||
if (target == null || !target.isValid() || target.isDead()) {
|
||||
p.sendActionBar(Component.text("No target! Look at entity within 120 blocks").color(NamedTextColor.RED));
|
||||
return false;
|
||||
}
|
||||
if (!canSeeTarget(p, target)) {
|
||||
p.sendActionBar(Component.text("Target blocked by wall!").color(NamedTextColor.RED));
|
||||
return false;
|
||||
}
|
||||
if (tension.getTP(p) < 87.5f) {
|
||||
p.sendActionBar(Component.text("Need 35% TP").color(NamedTextColor.RED));
|
||||
return false;
|
||||
}
|
||||
tension.setTP(p, tension.getTP(p) - 87.5f);
|
||||
tension.startBattle(p, target);
|
||||
BlackKnifePlugin plugin = BlackKnifePlugin.getPlugin(BlackKnifePlugin.class);
|
||||
double baseAngle = Math.random() * 360;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
int idx = i;
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, () -> {
|
||||
if (!target.isValid() || target.isDead()) return;
|
||||
double angle = (baseAngle + idx * 120) % 360 * Math.PI / 180;
|
||||
spawnLungeSwordAt(p, target, angle, 7 + Math.random() * 2, 20);
|
||||
if (idx == 0) p.getWorld().playSound(p.getLocation(), Sound.ENTITY_PLAYER_ATTACK_SWEEP, 1f, 0.6f);
|
||||
}, idx * 12L);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void spawnLungeSword(Player p, LivingEntity target, double damage) {
|
||||
double angle = Math.random() * Math.PI * 2;
|
||||
spawnLungeSwordAt(p, target, angle, 7 + Math.random() * 2, damage);
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_PLAYER_ATTACK_SWEEP, 1f, 0.7f);
|
||||
}
|
||||
|
||||
private static void spawnLungeSwordAt(Player p, LivingEntity target, double angleRad, double r, double damage) {
|
||||
BlackKnifePlugin plugin = BlackKnifePlugin.getPlugin(BlackKnifePlugin.class);
|
||||
Location curTargetPos = target.getLocation().clone().add(0, 1, 0);
|
||||
Vector offset = new Vector(Math.cos(angleRad), 0, Math.sin(angleRad));
|
||||
Location spawn = curTargetPos.clone().add(offset.clone().multiply(r)).add(0, (Math.random() - 0.5) * 2, 0);
|
||||
Vector aim = curTargetPos.clone().subtract(spawn).toVector().normalize().multiply(3.0);
|
||||
BlockDisplay sword = spawn.getWorld().spawn(spawn, BlockDisplay.class, d -> {
|
||||
d.setBlock(Material.DEEPSLATE_TILES.createBlockData());
|
||||
d.setBrightness(new Display.Brightness(15, 15));
|
||||
d.setViewRange(64);
|
||||
d.setTransformation(new org.bukkit.util.Transformation(
|
||||
new org.joml.Vector3f(-0.75f, -0.4f, -0.75f),
|
||||
new org.joml.AxisAngle4f(),
|
||||
new org.joml.Vector3f(1.5f, 1.5f, 1.5f),
|
||||
new org.joml.AxisAngle4f()));
|
||||
});
|
||||
new BukkitRunnable() {
|
||||
long hold = 5;
|
||||
boolean launched = false;
|
||||
@Override public void run() {
|
||||
if (!sword.isValid()) { cancel(); return; }
|
||||
Location cur = sword.getLocation();
|
||||
if (!launched) {
|
||||
cur.getWorld().spawnParticle(Particle.DUST, cur.clone().add(0, 0.5, 0), 3, 0.15, 0.15, 0.15, 0, new Particle.DustOptions(Color.fromRGB(10, 30, 50), 1.5f));
|
||||
cur.getWorld().spawnParticle(Particle.SCULK_SOUL, cur, 1, 0.1, 0.1, 0.1, 0);
|
||||
hold--;
|
||||
if (hold <= 0) launched = true;
|
||||
return;
|
||||
}
|
||||
Location nl = cur.clone().add(aim);
|
||||
int points = Math.max(1, (int) (aim.length() * 3));
|
||||
for (int j = 0; j <= points; j++) {
|
||||
Location pp = cur.clone().add(aim.clone().multiply((double) j / points));
|
||||
pp.getWorld().spawnParticle(Particle.DUST, pp, 1, 0, 0, 0, 0, new Particle.DustOptions(Color.fromRGB(0, 0, 0), 2.0f));
|
||||
pp.getWorld().spawnParticle(Particle.SCULK_SOUL, pp, 1, 0.05, 0.05, 0.05, 0);
|
||||
}
|
||||
int steps = Math.max(1, (int) Math.ceil(aim.length() / 0.5));
|
||||
for (int s = 0; s <= steps; s++) {
|
||||
Location check = cur.clone().add(aim.clone().multiply((double) s / steps));
|
||||
if (check.getBlock().isSolid()) { sword.remove(); cancel(); return; }
|
||||
}
|
||||
sword.teleport(nl);
|
||||
for (LivingEntity le : nl.getWorld().getNearbyLivingEntities(nl, 1.0)) {
|
||||
if (le == p) continue;
|
||||
applyLungeDamage(le, p, damage);
|
||||
le.getWorld().spawnParticle(Particle.CRIT, le.getLocation().add(0, 1, 0), 10, 0.4, 0.4, 0.4, 0.1);
|
||||
sword.remove(); cancel(); return;
|
||||
}
|
||||
for (Player pl : nl.getWorld().getNearbyPlayers(nl, 0.9)) {
|
||||
if (pl == p) continue;
|
||||
double d2 = pl.getLocation().add(0, 1, 0).distanceSquared(nl);
|
||||
if (d2 > 0.25 && d2 < 0.81) plugin.getTension().addTP(pl, 2.5f, "DODGE +1%");
|
||||
}
|
||||
if (sword.getTicksLived() > 80) { sword.remove(); cancel(); }
|
||||
}
|
||||
}.runTaskTimer(plugin, 1L, 1L);
|
||||
}
|
||||
|
||||
public static boolean tryOverhead(Player p, TensionManager tension, Location gazePoint) {
|
||||
if (gazePoint == null) {
|
||||
p.sendActionBar(Component.text("Look at ground within 120 blocks!").color(NamedTextColor.RED));
|
||||
return false;
|
||||
}
|
||||
if (tension.getTP(p) < 50f) {
|
||||
p.sendActionBar(Component.text("Need 20% TP").color(NamedTextColor.RED));
|
||||
return false;
|
||||
}
|
||||
tension.setTP(p, tension.getTP(p) - 50f);
|
||||
BlackKnifePlugin plugin = BlackKnifePlugin.getPlugin(BlackKnifePlugin.class);
|
||||
Location above = gazePoint.clone().add(0, 10, 0);
|
||||
BlockDisplay sword = p.getWorld().spawn(above, BlockDisplay.class, d -> {
|
||||
d.setBlock(Material.DEEPSLATE_TILES.createBlockData());
|
||||
d.setBrightness(new Display.Brightness(15, 15));
|
||||
d.setViewRange(64);
|
||||
d.setTransformation(new org.bukkit.util.Transformation(
|
||||
new org.joml.Vector3f(-0.75f, -0.4f, -0.75f),
|
||||
new org.joml.AxisAngle4f(),
|
||||
new org.joml.Vector3f(1.5f, 1.5f, 1.5f),
|
||||
new org.joml.AxisAngle4f()));
|
||||
});
|
||||
p.getWorld().playSound(gazePoint, Sound.ENTITY_PLAYER_ATTACK_SWEEP, 1f, 0.5f);
|
||||
p.getWorld().playSound(gazePoint, Sound.BLOCK_ANVIL_LAND, 0.6f, 1.4f);
|
||||
Vector vel = new Vector(0, -1.8, 0);
|
||||
new BukkitRunnable() {
|
||||
@Override public void run() {
|
||||
if (!sword.isValid()) { cancel(); return; }
|
||||
Location cur = sword.getLocation();
|
||||
Location nl = cur.clone().add(vel);
|
||||
sword.teleport(nl);
|
||||
nl.getWorld().spawnParticle(Particle.DUST, nl, 2, 0.15, 0.15, 0.15, 0, new Particle.DustOptions(Color.fromRGB(0, 0, 0), 1.5f));
|
||||
nl.getWorld().spawnParticle(Particle.SCULK_SOUL, nl, 1, 0.05, 0.05, 0.05, 0);
|
||||
if (nl.getY() <= gazePoint.getY() + 0.5 || nl.getBlock().isSolid()) {
|
||||
Location expl = gazePoint.clone();
|
||||
sword.remove(); cancel();
|
||||
expl.getWorld().spawnParticle(Particle.EXPLOSION, expl, 1);
|
||||
expl.getWorld().spawnParticle(Particle.SMOKE, expl, 10, 0.3, 0.1, 0.3, 0.02);
|
||||
for (int k = 0; k < 16; k++) {
|
||||
double a = (double) k / 16 * Math.PI * 2;
|
||||
Location r = expl.clone().add(Math.cos(a) * 2, 0.1, Math.sin(a) * 2);
|
||||
r.getWorld().spawnParticle(Particle.ASH, r, 1, 0, 0, 0, 0);
|
||||
r.getWorld().spawnParticle(Particle.SOUL, r, 1, 0.02, 0.02, 0.02, 0);
|
||||
}
|
||||
for (LivingEntity le : expl.getWorld().getNearbyLivingEntities(expl, 2.2)) {
|
||||
if (le == p) continue;
|
||||
double d = le.getLocation().distanceSquared(expl);
|
||||
if (d > 4.84) continue;
|
||||
applyLungeDamage(le, p, 20);
|
||||
le.getWorld().spawnParticle(Particle.CRIT, le.getLocation().add(0, 1, 0), 10, 0.4, 0.4, 0.4, 0.1);
|
||||
}
|
||||
for (Player pl : expl.getWorld().getNearbyPlayers(expl, 2.5)) {
|
||||
if (pl == p) continue;
|
||||
double d2 = pl.getLocation().add(0, 1, 0).distanceSquared(expl);
|
||||
if (d2 > 0.25 && d2 < 6.5) plugin.getTension().addTP(pl, 2.5f, "DODGE +1%");
|
||||
}
|
||||
expl.getWorld().playSound(expl, Sound.ENTITY_GENERIC_EXPLODE, 0.8f, 1.2f);
|
||||
return;
|
||||
}
|
||||
for (LivingEntity le : nl.getWorld().getNearbyLivingEntities(nl, 1.0)) {
|
||||
if (le == p) continue;
|
||||
applyLungeDamage(le, p, 20);
|
||||
sword.remove(); cancel(); return;
|
||||
}
|
||||
if (sword.getTicksLived() > 60) { sword.remove(); cancel(); }
|
||||
}
|
||||
}.runTaskTimer(plugin, 1L, 1L);
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void applyLungeDamage(LivingEntity ent, Player attacker, double amount) {
|
||||
if (ent instanceof Player pl && pl.isBlocking()) amount /= 2.5;
|
||||
ent.getPersistentDataContainer().set(SwoonHandler.MAGIC_DAMAGE, PersistentDataType.BYTE, (byte) 1);
|
||||
ent.damage(amount, attacker);
|
||||
}
|
||||
|
||||
private static void startPhase1(Player p, Location epicenter, LivingEntity target, BlackKnifePlugin plugin) {
|
||||
epicenter = epicenter.clone();
|
||||
Location ground = epicenter.clone();
|
||||
ground.setY(epicenter.getWorld().getHighestBlockYAt(epicenter) + 1);
|
||||
if (ground.getY() > epicenter.getY() + 0.5) ground = epicenter.clone();
|
||||
Location finalEpicenter = ground.clone();
|
||||
new BukkitRunnable() {
|
||||
int wave = 0;
|
||||
@Override public void run() {
|
||||
if (wave >= 5) { cancel(); startPhase2(p, finalEpicenter, target, plugin); return; }
|
||||
spawnShockwave(p, finalEpicenter.clone(), 20, plugin);
|
||||
wave++;
|
||||
}
|
||||
}.runTaskTimer(plugin, 0L, 10L);
|
||||
}
|
||||
|
||||
private static void spawnShockwave(Player p, Location center, double damage, BlackKnifePlugin plugin) {
|
||||
center.getWorld().playSound(center, Sound.BLOCK_SCULK_SHRIEKER_SHRIEK, 1f, 0.6f);
|
||||
double maxRadius = 40;
|
||||
double expandSpeed = 2.0;
|
||||
new BukkitRunnable() {
|
||||
double radius = 1;
|
||||
@Override public void run() {
|
||||
if (radius > maxRadius) { cancel(); return; }
|
||||
int points = (int) (radius * 6);
|
||||
for (int i = 0; i < points; i++) {
|
||||
double angle = (double) i / points * Math.PI * 2;
|
||||
double x = Math.cos(angle) * radius;
|
||||
double z = Math.sin(angle) * radius;
|
||||
Location ring = center.clone().add(x, 0.3, z);
|
||||
ring.getWorld().spawnParticle(Particle.ASH, ring, 1, 0, 0, 0, 0);
|
||||
ring.getWorld().spawnParticle(Particle.SOUL, ring, 1, 0.05, 0.05, 0.05, 0);
|
||||
ring.getWorld().spawnParticle(Particle.SCULK_SOUL, ring, 1, 0.05, 0.05, 0.05, 0);
|
||||
}
|
||||
if (radius > 3 && radius < maxRadius - 1) {
|
||||
double thinRadius = radius;
|
||||
for (LivingEntity le : center.getWorld().getNearbyLivingEntities(center, maxRadius + 2)) {
|
||||
if (le == p) continue;
|
||||
if (le.getLocation().getY() > center.getY() + 2.5) continue;
|
||||
double dist = Math.sqrt(Math.pow(le.getLocation().getX() - center.getX(), 2) + Math.pow(le.getLocation().getZ() - center.getZ(), 2));
|
||||
if (Math.abs(dist - thinRadius) < 1.2) {
|
||||
applyLungeDamage(le, p, damage);
|
||||
le.getWorld().spawnParticle(Particle.CRIT, le.getLocation().add(0, 1, 0), 8, 0.3, 0.3, 0.3, 0.1);
|
||||
}
|
||||
}
|
||||
}
|
||||
radius += expandSpeed;
|
||||
}
|
||||
}.runTaskTimer(plugin, 1L, 1L);
|
||||
}
|
||||
|
||||
private static void startPhase2(Player p, Location epicenter, LivingEntity target, BlackKnifePlugin plugin) {
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, () -> {
|
||||
new BukkitRunnable() {
|
||||
int idx = 0;
|
||||
@Override public void run() {
|
||||
if (idx >= 8) { cancel(); return; }
|
||||
Location above = epicenter.clone().add((Math.random() - 0.5) * 10, 10 + Math.random() * 3, (Math.random() - 0.5) * 10);
|
||||
spawnFallingSword(p, above, epicenter, 10, 0.7, plugin);
|
||||
idx++;
|
||||
}
|
||||
}.runTaskTimer(plugin, 1L, 3L);
|
||||
spawnShockwave(p, epicenter.clone(), 20, plugin);
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, () -> spawnShockwave(p, epicenter.clone(), 20, plugin), 12L);
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, () -> spawnShockwave(p, epicenter.clone(), 20, plugin), 24L);
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, () -> startPhase3(p, epicenter, target, plugin), 36L);
|
||||
}, 10L);
|
||||
}
|
||||
|
||||
private static void spawnFallingSword(Player p, Location spawn, Location target, double damage, double fallSpeed, BlackKnifePlugin plugin) {
|
||||
BlockDisplay sword = p.getWorld().spawn(spawn, BlockDisplay.class, d -> {
|
||||
d.setBlock(Material.DEEPSLATE_TILES.createBlockData());
|
||||
d.setBrightness(new Display.Brightness(15, 15));
|
||||
d.setViewRange(64);
|
||||
d.setTransformation(new org.bukkit.util.Transformation(
|
||||
new org.joml.Vector3f(-0.35f, -0.18f, -0.35f),
|
||||
new org.joml.AxisAngle4f(),
|
||||
new org.joml.Vector3f(0.7f, 0.7f, 0.7f),
|
||||
new org.joml.AxisAngle4f()));
|
||||
});
|
||||
Vector vel = new Vector(0, -fallSpeed, 0);
|
||||
p.getWorld().playSound(spawn, Sound.ENTITY_PLAYER_ATTACK_SWEEP, 0.6f, 0.7f);
|
||||
new BukkitRunnable() {
|
||||
@Override public void run() {
|
||||
if (!sword.isValid()) { cancel(); return; }
|
||||
Location cur = sword.getLocation();
|
||||
Location nl = cur.clone().add(vel);
|
||||
sword.teleport(nl);
|
||||
nl.getWorld().spawnParticle(Particle.DUST, nl, 1, 0, 0, 0, 0, new Particle.DustOptions(Color.fromRGB(0, 0, 0), 1.0f));
|
||||
nl.getWorld().spawnParticle(Particle.SCULK_SOUL, nl, 1, 0.05, 0.05, 0.05, 0);
|
||||
if (nl.getY() <= target.getY() + 0.5 || nl.getBlock().isSolid()) {
|
||||
Location expl = nl.clone();
|
||||
sword.remove();
|
||||
cancel();
|
||||
expl.getWorld().spawnParticle(Particle.SMOKE, expl, 6, 0.2, 0.1, 0.2, 0.02);
|
||||
expl.getWorld().spawnParticle(Particle.SCULK_SOUL, expl, 4, 0.2, 0.1, 0.2, 0.02);
|
||||
for (int k = 0; k < 12; k++) {
|
||||
double a = (double) k / 12 * Math.PI * 2;
|
||||
Location r = expl.clone().add(Math.cos(a) * 1.5, 0.1, Math.sin(a) * 1.5);
|
||||
r.getWorld().spawnParticle(Particle.ASH, r, 1, 0, 0, 0, 0);
|
||||
r.getWorld().spawnParticle(Particle.SOUL, r, 1, 0.02, 0.02, 0.02, 0);
|
||||
}
|
||||
for (LivingEntity le : expl.getWorld().getNearbyLivingEntities(expl, 1.5)) {
|
||||
if (le == p) continue;
|
||||
applyLungeDamage(le, p, damage);
|
||||
le.getWorld().spawnParticle(Particle.CRIT, le.getLocation().add(0, 1, 0), 6, 0.3, 0.3, 0.3, 0.1);
|
||||
}
|
||||
for (Player pl : expl.getWorld().getNearbyPlayers(expl, 0.9)) {
|
||||
if (pl == p) continue;
|
||||
double d2 = pl.getLocation().add(0, 1, 0).distanceSquared(expl);
|
||||
if (d2 > 0.25 && d2 < 0.81) plugin.getTension().addTP(pl, 2.5f, "DODGE +1%");
|
||||
}
|
||||
return;
|
||||
}
|
||||
for (LivingEntity le : nl.getWorld().getNearbyLivingEntities(nl, 0.7)) {
|
||||
if (le == p) continue;
|
||||
applyLungeDamage(le, p, damage);
|
||||
le.getWorld().spawnParticle(Particle.CRIT, le.getLocation().add(0, 1, 0), 8, 0.3, 0.3, 0.3, 0.1);
|
||||
sword.remove(); cancel(); return;
|
||||
}
|
||||
if (sword.getTicksLived() > 80) { sword.remove(); cancel(); }
|
||||
}
|
||||
}.runTaskTimer(plugin, 1L, 1L);
|
||||
}
|
||||
|
||||
private static void startPhase3(Player p, Location epicenter, LivingEntity target, BlackKnifePlugin plugin) {
|
||||
new BukkitRunnable() {
|
||||
int idx = 0;
|
||||
@Override public void run() {
|
||||
if (idx >= 20) { cancel(); startPhase4(p, target, plugin); return; }
|
||||
Location above = epicenter.clone().add((Math.random() - 0.5) * 12, 10 + Math.random() * 4, (Math.random() - 0.5) * 12);
|
||||
spawnFallingSword(p, above, epicenter, 10, 0.7, plugin);
|
||||
idx++;
|
||||
}
|
||||
}.runTaskTimer(plugin, 2L, 4L);
|
||||
}
|
||||
|
||||
private static void startPhase4(Player p, LivingEntity target, BlackKnifePlugin plugin) {
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, () -> {
|
||||
new BukkitRunnable() {
|
||||
int swordIdx = 0;
|
||||
long nextDelay = 30;
|
||||
long delayCounter = 0;
|
||||
@Override public void run() {
|
||||
if (swordIdx >= 30 || !target.isValid() || target.isDead()) { cancel(); return; }
|
||||
if (delayCounter < nextDelay) { delayCounter++; return; }
|
||||
delayCounter = 0;
|
||||
double frac = (double) swordIdx / 29;
|
||||
long holdTicks = Math.round(15 - frac * 10);
|
||||
long gapTicks = Math.round(20 - frac * 5);
|
||||
nextDelay = gapTicks;
|
||||
|
||||
double angle = (swordIdx * 137.5) % 360 * Math.PI / 180;
|
||||
double r = 7 + Math.random() * 3;
|
||||
Vector offset = new Vector(Math.cos(angle), 0, Math.sin(angle));
|
||||
Location curTargetPos = target.getLocation().clone().add(0, 1, 0);
|
||||
Location spawn = curTargetPos.clone().add(offset.clone().multiply(r)).add(0, (Math.random() - 0.5) * 2, 0);
|
||||
Vector aim = curTargetPos.clone().subtract(spawn).toVector().normalize().multiply(3.0);
|
||||
|
||||
BlockDisplay sword = spawn.getWorld().spawn(spawn, BlockDisplay.class, d -> {
|
||||
d.setBlock(Material.DEEPSLATE_TILES.createBlockData());
|
||||
d.setBrightness(new Display.Brightness(15, 15));
|
||||
d.setViewRange(64);
|
||||
d.setTransformation(new org.bukkit.util.Transformation(
|
||||
new org.joml.Vector3f(-0.75f, -0.4f, -0.75f),
|
||||
new org.joml.AxisAngle4f(),
|
||||
new org.joml.Vector3f(1.5f, 1.5f, 1.5f),
|
||||
new org.joml.AxisAngle4f()));
|
||||
});
|
||||
spawn.getWorld().playSound(spawn, Sound.ENTITY_PLAYER_ATTACK_SWEEP, 0.8f, 0.5f);
|
||||
|
||||
new BukkitRunnable() {
|
||||
long hold = holdTicks;
|
||||
boolean launched = false;
|
||||
@Override public void run() {
|
||||
if (!sword.isValid()) { cancel(); return; }
|
||||
Location cur = sword.getLocation();
|
||||
if (!launched) {
|
||||
cur.getWorld().spawnParticle(Particle.DUST, cur.clone().add(0, 0.5, 0), 3, 0.15, 0.15, 0.15, 0, new Particle.DustOptions(Color.fromRGB(10, 30, 50), 1.5f));
|
||||
cur.getWorld().spawnParticle(Particle.SCULK_SOUL, cur, 1, 0.1, 0.1, 0.1, 0);
|
||||
hold--;
|
||||
if (hold <= 0) launched = true;
|
||||
return;
|
||||
}
|
||||
Location nl = cur.clone().add(aim);
|
||||
int points = Math.max(1, (int) (aim.length() * 3));
|
||||
Vector step = aim.clone();
|
||||
for (int j = 0; j <= points; j++) {
|
||||
Location pp = cur.clone().add(step.clone().multiply((double) j / points));
|
||||
pp.getWorld().spawnParticle(Particle.DUST, pp, 1, 0, 0, 0, 0, new Particle.DustOptions(Color.fromRGB(0, 0, 0), 2.0f));
|
||||
pp.getWorld().spawnParticle(Particle.SCULK_SOUL, pp, 1, 0.05, 0.05, 0.05, 0);
|
||||
}
|
||||
int steps = Math.max(1, (int) Math.ceil(aim.length() / 0.5));
|
||||
for (int s = 0; s <= steps; s++) {
|
||||
Location check = cur.clone().add(aim.clone().multiply((double) s / steps));
|
||||
if (check.getBlock().isSolid()) { sword.remove(); cancel(); return; }
|
||||
}
|
||||
sword.teleport(nl);
|
||||
for (LivingEntity le : nl.getWorld().getNearbyLivingEntities(nl, 1.0)) {
|
||||
if (le == p) continue;
|
||||
applyLungeDamage(le, p, 20);
|
||||
le.getWorld().spawnParticle(Particle.CRIT, le.getLocation().add(0, 1, 0), 10, 0.4, 0.4, 0.4, 0.1);
|
||||
sword.remove(); cancel(); return;
|
||||
}
|
||||
for (Player pl : nl.getWorld().getNearbyPlayers(nl, 0.9)) {
|
||||
if (pl == p) continue;
|
||||
double d2 = pl.getLocation().add(0, 1, 0).distanceSquared(nl);
|
||||
if (d2 > 0.25 && d2 < 0.81) plugin.getTension().addTP(pl, 2.5f, "DODGE +1%");
|
||||
}
|
||||
if (sword.getTicksLived() > 80) { sword.remove(); cancel(); }
|
||||
}
|
||||
}.runTaskTimer(plugin, 1L, 1L);
|
||||
|
||||
swordIdx++;
|
||||
}
|
||||
}.runTaskTimer(plugin, 1L, 1L);
|
||||
}, 10L);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package me.sashegdev.blackknife;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class MagicCommand implements CommandExecutor {
|
||||
private final MagicManager mgr;
|
||||
private final BlackKnifePlugin plugin;
|
||||
public MagicCommand(MagicManager mgr, BlackKnifePlugin plugin) { this.mgr = mgr; this.plugin = plugin; }
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender s, Command cmd, String label, String[] args) {
|
||||
if (args.length == 0) { s.sendMessage("§d/magic give <player> [type] §7| §dreroll <player> §7| §dstats <player>"); return true; }
|
||||
if (args[0].equalsIgnoreCase("give")) {
|
||||
Player t = args.length > 1 ? plugin.getServer().getPlayer(args[1]) : (s instanceof Player p ? p : null);
|
||||
if (t == null) { s.sendMessage("§cPlayer not found"); return true; }
|
||||
MagicProfile prof = mgr.getOrCreate(t);
|
||||
if (args.length > 2) {
|
||||
try { MagicType mt = MagicType.valueOf(args[2].toUpperCase()); if (!prof.story.contains(mt.name())) prof.story.add(mt.name()); } catch (Exception e) { s.sendMessage("§cUnknown type: " + args[2]); return true; }
|
||||
}
|
||||
t.getInventory().addItem(MagicItem.create(prof));
|
||||
s.sendMessage("§aGave Magic Orb to " + t.getName());
|
||||
return true;
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("reroll") && args.length > 1) {
|
||||
Player t = plugin.getServer().getPlayer(args[1]);
|
||||
if (t == null) { s.sendMessage("§cPlayer not found"); return true; }
|
||||
MagicProfile prof = mgr.getOrCreate(t);
|
||||
prof.rareRolled = false; prof.rare.clear();
|
||||
if (Math.random() < 0.05) { String[] pool = {"DETERMORE","FROSHE","PRAYER","SHIELDO"}; String pick = pool[(int)(Math.random()*pool.length)]; prof.rare.add(pick); s.sendMessage("§aReroll: got rare " + pick); } else s.sendMessage("§7Reroll: no rare (5%)");
|
||||
mgr.save(prof); return true;
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("stats") && args.length > 1) {
|
||||
Player t = plugin.getServer().getPlayer(args[1]);
|
||||
if (t == null) { s.sendMessage("§cPlayer not found"); return true; }
|
||||
MagicProfile prof = mgr.getOrCreate(t);
|
||||
s.sendMessage("§d" + prof.nick + " casts:" + prof.casts + " tpSpent:" + (int)prof.tpSpent + " heals:" + prof.heals + " pack:" + prof.all());
|
||||
return true;
|
||||
}
|
||||
s.sendMessage("§cUnknown subcommand");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package me.sashegdev.blackknife;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import java.util.List;
|
||||
|
||||
public class MagicItem {
|
||||
public static final NamespacedKey KEY = new NamespacedKey("blackknife", "magic");
|
||||
public static final NamespacedKey OWNER = new NamespacedKey("blackknife", "magic_owner");
|
||||
public static final NamespacedKey SEL = new NamespacedKey("blackknife", "magic_sel");
|
||||
|
||||
public static ItemStack create(MagicProfile prof) {
|
||||
ItemStack item = new ItemStack(Material.AMETHYST_SHARD);
|
||||
ItemMeta m = item.getItemMeta();
|
||||
String cur = prof.getSelected().display;
|
||||
m.displayName(Component.text("Magic Orb [" + cur + "]").color(NamedTextColor.LIGHT_PURPLE).decorate(TextDecoration.BOLD));
|
||||
m.lore(List.of(
|
||||
Component.text("A faint power stirs within...").color(NamedTextColor.GRAY).decorate(TextDecoration.ITALIC),
|
||||
Component.text("It resonates with its owner.").color(NamedTextColor.DARK_GRAY).decorate(TextDecoration.ITALIC)
|
||||
));
|
||||
m.setUnbreakable(true);
|
||||
m.getPersistentDataContainer().set(KEY, PersistentDataType.BYTE, (byte) 1);
|
||||
m.getPersistentDataContainer().set(OWNER, PersistentDataType.STRING, prof.uuid.toString());
|
||||
m.getPersistentDataContainer().set(SEL, PersistentDataType.INTEGER, prof.selectedIdx);
|
||||
item.setItemMeta(m);
|
||||
return item;
|
||||
}
|
||||
|
||||
public static boolean is(ItemStack item) {
|
||||
if (item == null || item.getType() != Material.AMETHYST_SHARD) return false;
|
||||
var meta = item.getItemMeta();
|
||||
return meta != null && meta.getPersistentDataContainer().has(KEY, PersistentDataType.BYTE);
|
||||
}
|
||||
|
||||
public static void updateLore(ItemStack item, MagicProfile prof) {
|
||||
if (!is(item)) return;
|
||||
ItemMeta m = item.getItemMeta();
|
||||
String cur = prof.getSelected().display;
|
||||
m.displayName(Component.text("Magic Orb [" + cur + "]").color(NamedTextColor.LIGHT_PURPLE).decorate(TextDecoration.BOLD));
|
||||
m.lore(List.of(
|
||||
Component.text("A faint power stirs within...").color(NamedTextColor.GRAY).decorate(TextDecoration.ITALIC),
|
||||
Component.text("It resonates with its owner.").color(NamedTextColor.DARK_GRAY).decorate(TextDecoration.ITALIC)
|
||||
));
|
||||
m.getPersistentDataContainer().set(SEL, PersistentDataType.INTEGER, prof.selectedIdx);
|
||||
item.setItemMeta(m);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
package me.sashegdev.blackknife;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Marker;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class MagicListener implements Listener {
|
||||
private final BlackKnifePlugin plugin;
|
||||
private final MagicManager mgr;
|
||||
private final Map<UUID, Long> shieldEnd = new HashMap<>();
|
||||
private final Map<UUID, BukkitRunnable> shieldTasks = new HashMap<>();
|
||||
|
||||
public MagicListener(BlackKnifePlugin plugin, MagicManager mgr) { this.plugin = plugin; this.mgr = mgr; }
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if (BlackKnifeItem.is(p.getInventory().getItemInMainHand()) || BlackKnifeItem.is(p.getInventory().getItemInOffHand())) return;
|
||||
MagicProfile prof = mgr.getOrCreate(p);
|
||||
boolean hasMagic = false;
|
||||
for (ItemStack it : p.getInventory().getContents()) if (MagicItem.is(it)) { hasMagic = true; break; }
|
||||
if (!hasMagic) p.getInventory().addItem(MagicItem.create(prof));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent e) {
|
||||
ItemStack item = e.getItem();
|
||||
if (!MagicItem.is(item)) return;
|
||||
Player p = e.getPlayer();
|
||||
if (BlackKnifeItem.is(p.getInventory().getItemInMainHand()) || BlackKnifeItem.is(p.getInventory().getItemInOffHand())) { p.sendActionBar(Component.text("Can't use Magic with BlackKnife!").color(NamedTextColor.RED)); return; }
|
||||
String ownerStr = item.getItemMeta().getPersistentDataContainer().get(MagicItem.OWNER, PersistentDataType.STRING);
|
||||
if (ownerStr != null && !ownerStr.equals(p.getUniqueId().toString())) { p.sendActionBar(Component.text("Not your Magic Orb!").color(NamedTextColor.RED)); return; }
|
||||
MagicProfile prof = mgr.getOrCreate(p);
|
||||
if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if (p.isSneaking()) {
|
||||
prof.cycle();
|
||||
MagicItem.updateLore(item, prof);
|
||||
mgr.save(prof);
|
||||
p.sendActionBar(Component.text("Magic: " + prof.getSelected().display).color(NamedTextColor.LIGHT_PURPLE));
|
||||
return;
|
||||
}
|
||||
if (p.hasCooldown(Material.AMETHYST_SHARD)) return;
|
||||
MagicType mt = prof.getSelected();
|
||||
TensionManager tm = plugin.getTension();
|
||||
if (tm.getTP(p) < mt.cost) { p.sendActionBar(Component.text("Need " + (int)(mt.cost/2.5) + "% TP").color(NamedTextColor.RED)); return; }
|
||||
boolean ok = false;
|
||||
if (mt == MagicType.DETERMORE) ok = castDetermore(p, tm);
|
||||
else if (mt == MagicType.FROSHE) ok = castFroshe(p, tm);
|
||||
else if (mt == MagicType.PRAYER) ok = castPrayer(p, tm);
|
||||
else if (mt == MagicType.SHIELDO) ok = castShieldo(p, tm);
|
||||
if (ok) {
|
||||
tm.setTP(p, tm.getTP(p) - mt.cost);
|
||||
prof.casts++; prof.tpSpent += mt.cost; mgr.save(prof);
|
||||
p.setCooldown(Material.AMETHYST_SHARD, mt.cd);
|
||||
MagicItem.updateLore(item, prof);
|
||||
}
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean castDetermore(Player p, TensionManager tm) {
|
||||
Location spawn = p.getLocation().add(0, 2.2, 0).add(p.getEyeLocation().getDirection().normalize().multiply(1));
|
||||
Marker marker = p.getWorld().spawn(spawn, Marker.class, m -> m.setPersistent(false));
|
||||
EntityTracker.mark(marker);
|
||||
Vector vel = p.getEyeLocation().getDirection().normalize().multiply(2.0);
|
||||
p.getWorld().playSound(spawn, Sound.ENTITY_FIREWORK_ROCKET_BLAST, 1f, 1.3f);
|
||||
new BukkitRunnable() {
|
||||
@Override public void run() {
|
||||
if (!marker.isValid() || marker.isDead()) { cancel(); return; }
|
||||
Location cur = marker.getLocation();
|
||||
Location nl = cur.clone().add(vel);
|
||||
double len = cur.distance(nl);
|
||||
int steps = Math.max(1, (int)Math.ceil(len/0.5));
|
||||
for (int s=0;s<=steps;s++) {
|
||||
Location check = cur.clone().add(vel.clone().multiply((double)s/steps));
|
||||
if (check.getBlock().isSolid()) {
|
||||
Location expl = cur.clone().add(vel.clone().normalize().multiply(Math.max(0, (double)(s-1)/steps)));
|
||||
for (int k=0;k<12;k++){ double a=(double)k/12*Math.PI*2; for(int h=-1;h<=1;h++){ Location sphere=expl.clone().add(Math.cos(a)*0.5, h*0.25, Math.sin(a)*0.5); sphere.getWorld().spawnParticle(Particle.DUST, sphere,1,0,0,0,0,new Particle.DustOptions(Color.fromRGB(180,40,40),1f)); sphere.getWorld().spawnParticle(Particle.SMOKE,sphere,1,0.02,0.02,0.02,0);} } expl.getWorld().spawnParticle(Particle.CRIT,expl,6,0.2,0.2,0.2,0.05); expl.getWorld().playSound(expl,Sound.BLOCK_STONE_BREAK,1f,0.8f);
|
||||
marker.remove(); cancel(); return;
|
||||
}
|
||||
}
|
||||
for(int i=0;i<=4;i++){ Location pp=cur.clone().add(vel.clone().multiply((double)i/4)); pp.getWorld().spawnParticle(Particle.DUST,pp,1,0,0,0,0,new Particle.DustOptions(Color.fromRGB(200,40,40),1.4f)); pp.getWorld().spawnParticle(Particle.CRIT,pp,1,0.02,0.02,0.02,0); }
|
||||
marker.teleport(nl);
|
||||
for(var ent: nl.getWorld().getNearbyEntities(nl,0.7,0.7,0.7, en->en instanceof LivingEntity && en!=p)) {
|
||||
LivingEntity le=(LivingEntity)ent;
|
||||
le.getPersistentDataContainer().set(SwoonHandler.MAGIC_DAMAGE,PersistentDataType.BYTE,(byte)1);
|
||||
le.damage(15.0,p);
|
||||
Location hit=le.getLocation().add(0,1,0);
|
||||
for(int k=0;k<12;k++){ double a=(double)k/12*Math.PI*2; for(int h=-1;h<=1;h++){ Location s=hit.clone().add(Math.cos(a)*0.5,h*0.25,Math.sin(a)*0.5); s.getWorld().spawnParticle(Particle.DUST,s,1,0,0,0,0,new Particle.DustOptions(Color.fromRGB(200,40,40),0.9f)); } } hit.getWorld().spawnParticle(Particle.CRIT,hit,10,0.3,0.3,0.3,0.1); hit.getWorld().playSound(hit,Sound.ENTITY_PLAYER_ATTACK_CRIT,1f,0.9f);
|
||||
le.addPotionEffect(new org.bukkit.potion.PotionEffect(org.bukkit.potion.PotionEffectType.SLOWNESS,40,1,false,false,true));
|
||||
marker.remove(); cancel(); return;
|
||||
}
|
||||
if (marker.getTicksLived()>80){ marker.remove(); cancel(); }
|
||||
}
|
||||
}.runTaskTimer(plugin,1L,1L);
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean castFroshe(Player p, TensionManager tm) {
|
||||
Location spawn = p.getLocation().add(0, 2.2, 0).add(p.getEyeLocation().getDirection().normalize().multiply(1));
|
||||
Marker marker = p.getWorld().spawn(spawn, Marker.class, m -> m.setPersistent(false));
|
||||
EntityTracker.mark(marker);
|
||||
Vector vel = p.getEyeLocation().getDirection().normalize().multiply(2.0);
|
||||
p.getWorld().playSound(spawn, Sound.BLOCK_GLASS_BREAK, 1f, 1.5f);
|
||||
p.getWorld().playSound(spawn, Sound.ENTITY_SNOWBALL_THROW, 1f, 0.8f);
|
||||
new BukkitRunnable() {
|
||||
@Override public void run() {
|
||||
if (!marker.isValid() || marker.isDead()) { cancel(); return; }
|
||||
Location cur = marker.getLocation();
|
||||
Location nl = cur.clone().add(vel);
|
||||
double len = cur.distance(nl);
|
||||
int steps = Math.max(1, (int)Math.ceil(len/0.5));
|
||||
for (int s=0;s<=steps;s++) {
|
||||
Location check = cur.clone().add(vel.clone().multiply((double)s/steps));
|
||||
if (check.getBlock().isSolid()) {
|
||||
Location expl = cur.clone().add(vel.clone().normalize().multiply(Math.max(0, (double)(s-1)/steps)));
|
||||
for(int k=0;k<12;k++){ double a=(double)k/12*Math.PI*2; for(int h=-1;h<=1;h++){ Location sphere=expl.clone().add(Math.cos(a)*0.5,h*0.25,Math.sin(a)*0.5); sphere.getWorld().spawnParticle(Particle.SNOWFLAKE,sphere,1,0.02,0.02,0.02,0); sphere.getWorld().spawnParticle(Particle.DUST,sphere,1,0,0,0,0,new Particle.DustOptions(Color.fromRGB(136,204,255),0.9f)); } } expl.getWorld().spawnParticle(Particle.SNOWFLAKE,expl,10,0.3,0.3,0.3,0.1); expl.getWorld().playSound(expl,Sound.BLOCK_GLASS_BREAK,1f,1.2f);
|
||||
marker.remove(); cancel(); return;
|
||||
}
|
||||
}
|
||||
for(int i=0;i<=4;i++){ Location pp=cur.clone().add(vel.clone().multiply((double)i/4)); pp.getWorld().spawnParticle(Particle.DUST,pp,1,0,0,0,0,new Particle.DustOptions(Color.fromRGB(136,204,255),1.3f)); pp.getWorld().spawnParticle(Particle.SNOWFLAKE,pp,1,0.02,0.02,0.02,0); }
|
||||
marker.teleport(nl);
|
||||
for(var ent: nl.getWorld().getNearbyEntities(nl,0.7,0.7,0.7, en->en instanceof LivingEntity && en!=p)) {
|
||||
LivingEntity le=(LivingEntity)ent;
|
||||
le.getPersistentDataContainer().set(SwoonHandler.MAGIC_DAMAGE,PersistentDataType.BYTE,(byte)1);
|
||||
le.damage(8.0,p);
|
||||
Location hit=le.getLocation().add(0,1,0);
|
||||
for(int k=0;k<12;k++){ double a=(double)k/12*Math.PI*2; for(int h=-1;h<=1;h++){ Location s=hit.clone().add(Math.cos(a)*0.5,h*0.25,Math.sin(a)*0.5); s.getWorld().spawnParticle(Particle.SNOWFLAKE,s,1,0.02,0.02,0.02,0); } } hit.getWorld().spawnParticle(Particle.SNOWFLAKE,hit,8,0.3,0.3,0.3,0.1); hit.getWorld().playSound(hit,Sound.BLOCK_GLASS_BREAK,1f,0.7f);
|
||||
le.addPotionEffect(new org.bukkit.potion.PotionEffect(org.bukkit.potion.PotionEffectType.SLOWNESS,40,1,false,false,true));
|
||||
marker.remove(); cancel(); return;
|
||||
}
|
||||
if (marker.getTicksLived()>80){ marker.remove(); cancel(); }
|
||||
}
|
||||
}.runTaskTimer(plugin,1L,1L);
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean castPrayer(Player p, TensionManager tm) {
|
||||
double cur = p.getHealth();
|
||||
double heal = cur * 0.25;
|
||||
double max = p.getAttribute(org.bukkit.attribute.Attribute.GENERIC_MAX_HEALTH).getValue();
|
||||
p.setHealth(Math.min(max, cur + heal));
|
||||
p.getWorld().spawnParticle(Particle.HEART, p.getLocation().add(0,1,0), 6, 0.4,0.5,0.4,0.1);
|
||||
p.getWorld().spawnParticle(Particle.SCULK_SOUL, p.getLocation().add(0,1,0), 10, 0.4,0.4,0.4,0.05);
|
||||
p.getWorld().spawnParticle(Particle.HAPPY_VILLAGER, p.getLocation().add(0,1,0), 8, 0.4,0.4,0.4,0.1);
|
||||
p.getWorld().playSound(p.getLocation(), Sound.BLOCK_BEACON_POWER_SELECT, 1f, 1.4f);
|
||||
p.sendActionBar(Component.text(String.format("Prayer +%.1f HP", heal)).color(NamedTextColor.GREEN));
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean castShieldo(Player p, TensionManager tm) {
|
||||
if (shieldEnd.containsKey(p.getUniqueId()) && System.currentTimeMillis() < shieldEnd.get(p.getUniqueId())) { p.sendActionBar(Component.text("Shield already active!").color(NamedTextColor.YELLOW)); return false; }
|
||||
long end = System.currentTimeMillis() + 8000;
|
||||
shieldEnd.put(p.getUniqueId(), end);
|
||||
p.sendActionBar(Component.text("Shieldo 30% 8s!").color(NamedTextColor.AQUA));
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ITEM_SHIELD_BLOCK, 1f, 1.2f);
|
||||
BukkitRunnable task = new BukkitRunnable() {
|
||||
@Override public void run() {
|
||||
if (!p.isOnline() || System.currentTimeMillis() >= shieldEnd.getOrDefault(p.getUniqueId(), 0L)) {
|
||||
shieldEnd.remove(p.getUniqueId());
|
||||
shieldTasks.remove(p.getUniqueId());
|
||||
if (p.isOnline()) { p.getWorld().spawnParticle(Particle.SMOKE, p.getLocation().add(0,1,0), 10,0.3,0.3,0.3,0.02); p.getWorld().playSound(p.getLocation(), Sound.ITEM_SHIELD_BREAK, 0.8f, 1f); }
|
||||
cancel(); return;
|
||||
}
|
||||
Location loc = p.getLocation().add(0,1,0);
|
||||
for(int i=0;i<8;i++){ double a=(double)i/8*Math.PI*2 + System.currentTimeMillis()*0.005; Location ring=loc.clone().add(Math.cos(a)*1.1, Math.sin(a*2)*0.2, Math.sin(a)*1.1); p.getWorld().spawnParticle(Particle.DUST, ring,1,0,0,0,0,new Particle.DustOptions(Color.fromRGB(200,200,255),1f)); }
|
||||
p.getWorld().spawnParticle(Particle.END_ROD, loc,1,0.1,0.1,0.1,0);
|
||||
}
|
||||
};
|
||||
task.runTaskTimer(plugin,1L,4L);
|
||||
shieldTasks.put(p.getUniqueId(), task);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isShielded(Player p) { return shieldEnd.containsKey(p.getUniqueId()) && System.currentTimeMillis() < shieldEnd.get(p.getUniqueId()); }
|
||||
|
||||
public double reduceShieldDamage(Player p, double dmg) {
|
||||
if (!isShielded(p)) return dmg;
|
||||
TensionManager tm = plugin.getTension();
|
||||
if (tm.getTP(p) < 12.5f) {
|
||||
shieldEnd.remove(p.getUniqueId());
|
||||
var task = shieldTasks.remove(p.getUniqueId());
|
||||
if (task!=null) task.cancel();
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ITEM_SHIELD_BREAK, 1f, 0.8f);
|
||||
p.sendActionBar(Component.text("Shield broken! No TP!").color(NamedTextColor.RED));
|
||||
return dmg;
|
||||
}
|
||||
tm.setTP(p, tm.getTP(p) - 12.5f);
|
||||
p.getWorld().spawnParticle(Particle.CRIT, p.getLocation().add(0,1,0), 5,0.2,0.2,0.2,0.05);
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ITEM_SHIELD_BLOCK, 0.8f, 1.3f);
|
||||
return dmg * 0.7;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package me.sashegdev.blackknife;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class MagicManager {
|
||||
private final BlackKnifePlugin plugin;
|
||||
private final Map<UUID, MagicProfile> map = new HashMap<>();
|
||||
private File folder;
|
||||
|
||||
public MagicManager(BlackKnifePlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
folder = new File(plugin.getDataFolder(), "magic");
|
||||
folder.mkdirs();
|
||||
loadAll();
|
||||
plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, this::saveAll, 1200L, 1200L);
|
||||
}
|
||||
|
||||
private void loadAll() {
|
||||
File[] files = folder.listFiles((d,n) -> n.endsWith(".yml"));
|
||||
if (files == null) return;
|
||||
for (File f : files) {
|
||||
try {
|
||||
YamlConfiguration y = YamlConfiguration.loadConfiguration(f);
|
||||
UUID uuid = UUID.fromString(f.getName().replace(".yml",""));
|
||||
MagicProfile p = new MagicProfile(y.getString("nick","?"), uuid);
|
||||
p.firstSeen = y.getLong("firstSeen", System.currentTimeMillis());
|
||||
p.casts = y.getInt("stats.casts",0);
|
||||
p.tpSpent = y.getDouble("stats.tpSpent",0);
|
||||
p.heals = y.getInt("stats.heals",0);
|
||||
p.selectedIdx = y.getInt("pack.selected",0);
|
||||
p.common = y.getStringList("pack.common");
|
||||
if (p.common.isEmpty()) p.common = new java.util.ArrayList<>(java.util.List.of("DETERMORE","FROSHE","PRAYER","SHIELDO"));
|
||||
p.rare = y.getStringList("pack.rare");
|
||||
p.story = y.getStringList("pack.story");
|
||||
p.rareRolled = y.getBoolean("flags.rareRolled", false);
|
||||
map.put(uuid, p);
|
||||
} catch (Exception e) { plugin.getLogger().warning("Failed load magic " + f.getName() + ": " + e.getMessage()); }
|
||||
}
|
||||
}
|
||||
|
||||
public MagicProfile getOrCreate(Player p) {
|
||||
MagicProfile prof = map.get(p.getUniqueId());
|
||||
if (prof == null) {
|
||||
prof = new MagicProfile(p.getName(), p.getUniqueId());
|
||||
if (!prof.rareRolled) {
|
||||
prof.rareRolled = true;
|
||||
if (Math.random() < 0.05) {
|
||||
String[] pool = {"DETERMORE","FROSHE","PRAYER","SHIELDO"};
|
||||
String pick = pool[(int)(Math.random()*pool.length)];
|
||||
if (!prof.common.contains(pick)) prof.rare.add(pick);
|
||||
}
|
||||
}
|
||||
map.put(p.getUniqueId(), prof);
|
||||
save(prof);
|
||||
} else if (!prof.nick.equals(p.getName())) {
|
||||
prof.nick = p.getName();
|
||||
save(prof);
|
||||
}
|
||||
return prof;
|
||||
}
|
||||
|
||||
public MagicProfile get(UUID uuid) { return map.get(uuid); }
|
||||
|
||||
public void save(MagicProfile prof) {
|
||||
try {
|
||||
File f = new File(folder, prof.uuid.toString() + ".yml");
|
||||
YamlConfiguration y = new YamlConfiguration();
|
||||
y.set("nick", prof.nick);
|
||||
y.set("uuid", prof.uuid.toString());
|
||||
y.set("firstSeen", prof.firstSeen);
|
||||
y.set("stats.casts", prof.casts);
|
||||
y.set("stats.tpSpent", prof.tpSpent);
|
||||
y.set("stats.heals", prof.heals);
|
||||
y.set("pack.common", prof.common);
|
||||
y.set("pack.rare", prof.rare);
|
||||
y.set("pack.story", prof.story);
|
||||
y.set("pack.selected", prof.selectedIdx);
|
||||
y.set("flags.rareRolled", prof.rareRolled);
|
||||
y.save(f);
|
||||
} catch (Exception e) { plugin.getLogger().warning("Failed save magic " + prof.uuid + ": " + e.getMessage()); }
|
||||
}
|
||||
|
||||
public void saveAll() { for (MagicProfile p : map.values()) save(p); }
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package me.sashegdev.blackknife;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class MagicProfile {
|
||||
public String nick;
|
||||
public UUID uuid;
|
||||
public long firstSeen;
|
||||
public int casts;
|
||||
public double tpSpent;
|
||||
public int heals;
|
||||
public int selectedIdx;
|
||||
public List<String> common = new ArrayList<>(List.of("DETERMORE","FROSHE","PRAYER","SHIELDO"));
|
||||
public List<String> rare = new ArrayList<>();
|
||||
public List<String> story = new ArrayList<>();
|
||||
public boolean rareRolled;
|
||||
|
||||
public MagicProfile(String nick, UUID uuid) {
|
||||
this.nick = nick; this.uuid = uuid; this.firstSeen = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public List<MagicType> all() {
|
||||
List<MagicType> out = new ArrayList<>();
|
||||
for (String s : common) try { out.add(MagicType.valueOf(s)); } catch (Exception ignored) {}
|
||||
for (String s : rare) try { out.add(MagicType.valueOf(s)); } catch (Exception ignored) {}
|
||||
for (String s : story) try { out.add(MagicType.valueOf(s)); } catch (Exception ignored) {}
|
||||
if (out.isEmpty()) out.add(MagicType.DETERMORE);
|
||||
return out;
|
||||
}
|
||||
|
||||
public MagicType getSelected() {
|
||||
List<MagicType> a = all();
|
||||
if (selectedIdx < 0 || selectedIdx >= a.size()) selectedIdx = 0;
|
||||
return a.get(selectedIdx);
|
||||
}
|
||||
|
||||
public void cycle() {
|
||||
List<MagicType> a = all();
|
||||
selectedIdx = (selectedIdx + 1) % a.size();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package me.sashegdev.blackknife;
|
||||
|
||||
public enum MagicType {
|
||||
DETERMORE("Determore", 162.5f, 300, "§cDetermination power §7- 15dmg +SLOW 2s"),
|
||||
FROSHE("Froshe", 75f, 160, "§bFrost shot §7- sword style ice 8dmg"),
|
||||
PRAYER("Prayer", 95f, 120, "§aPrayer §7- heal 25% of current HP"),
|
||||
SHIELDO("Shieldo", 112.5f, 180, "§eShieldo §7- 30% 8s -5% per hit");
|
||||
public final String display;
|
||||
public final float cost;
|
||||
public final int cd;
|
||||
public final String lore;
|
||||
MagicType(String display, float cost, int cd, String lore) { this.display = display; this.cost = cost; this.cd = cd; this.lore = lore; }
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package me.sashegdev.blackknife;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
public class ParryHandler implements Listener {
|
||||
private final BlackKnifePlugin plugin;
|
||||
public ParryHandler(BlackKnifePlugin plugin) { this.plugin = plugin; }
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onDamage(EntityDamageByEntityEvent e) {
|
||||
if (!(e.getEntity() instanceof Player victim)) return;
|
||||
if (e.isCancelled()) return;
|
||||
if (BlackKnifeItem.is(victim.getInventory().getItemInMainHand()) || BlackKnifeItem.is(victim.getInventory().getItemInOffHand())) {
|
||||
TensionManager tm = plugin.getTension();
|
||||
if (tm.getTP(victim) < 37.5f) return;
|
||||
double original = e.getDamage();
|
||||
double reduced = original * 0.4;
|
||||
e.setDamage(reduced);
|
||||
tm.setTP(victim, tm.getTP(victim) - 37.5f);
|
||||
victim.getWorld().spawnParticle(Particle.CRIT, victim.getLocation().add(0, 1, 0), 12, 0.3, 0.4, 0.3, 0.1);
|
||||
victim.getWorld().spawnParticle(Particle.SMOKE, victim.getLocation().add(0, 1, 0), 8, 0.2, 0.3, 0.2, 0.02);
|
||||
victim.getWorld().playSound(victim.getLocation(), Sound.ITEM_SHIELD_BLOCK, 1f, 1.1f);
|
||||
victim.sendActionBar(Component.text(String.format("PARRY -60%% (%.0f→%.0f) -15%% TP", original, reduced)).color(NamedTextColor.AQUA));
|
||||
if (e.getDamager() instanceof Player attacker) attacker.sendActionBar(Component.text("PARRIED!").color(NamedTextColor.GRAY));
|
||||
return;
|
||||
}
|
||||
var magicListener = plugin.getMagicListener();
|
||||
if (magicListener != null && magicListener.isShielded(victim)) {
|
||||
double reduced = magicListener.reduceShieldDamage(victim, e.getDamage());
|
||||
e.setDamage(reduced);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package me.sashegdev.blackknife;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class SwoonHandler implements Listener {
|
||||
private final BlackKnifePlugin plugin;
|
||||
public static final NamespacedKey SWOONED = new NamespacedKey("blackknife", "swooned");
|
||||
public static final NamespacedKey MAGIC_DAMAGE = new NamespacedKey("blackknife", "magic_damage");
|
||||
|
||||
public SwoonHandler(BlackKnifePlugin plugin) { this.plugin = plugin; }
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onHit(EntityDamageByEntityEvent e) {
|
||||
if (!(e.getDamager() instanceof Player p)) return;
|
||||
if (!BlackKnifeItem.is(p.getInventory().getItemInMainHand()) && !BlackKnifeItem.is(p.getInventory().getItemInOffHand())) return;
|
||||
if (!(e.getEntity() instanceof LivingEntity target)) return;
|
||||
if (target.getPersistentDataContainer().has(MAGIC_DAMAGE, PersistentDataType.BYTE)) {
|
||||
target.getPersistentDataContainer().remove(MAGIC_DAMAGE);
|
||||
return;
|
||||
}
|
||||
if (p.hasCooldown(Material.NETHERITE_SWORD)) return;
|
||||
e.setCancelled(true);
|
||||
plugin.getTension().setTP(p, Math.max(0, plugin.getTension().getTP(p) - 125f));
|
||||
if (target instanceof Player tp) {
|
||||
tp.setHealth(1.0);
|
||||
tp.getPersistentDataContainer().set(SWOONED, PersistentDataType.BYTE, (byte) 1);
|
||||
tp.addPotionEffect(new PotionEffect(PotionEffectType.SLOWNESS, 100, 2));
|
||||
tp.addPotionEffect(new PotionEffect(PotionEffectType.WEAKNESS, 100, 1));
|
||||
tp.addPotionEffect(new PotionEffect(PotionEffectType.DARKNESS, 60, 0));
|
||||
tp.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20, 0));
|
||||
p.sendActionBar(Component.text("SWOON! " + tp.getName() + " -999 HP").color(NamedTextColor.DARK_RED));
|
||||
tp.sendActionBar(Component.text("SWOONED! -999 HP").color(NamedTextColor.DARK_RED));
|
||||
tp.getWorld().playSound(tp.getLocation(), Sound.ENTITY_WARDEN_SONIC_BOOM, 1f, 0.5f);
|
||||
if (Math.random() < 0.1) tp.getWorld().dropItemNaturally(tp.getLocation(), BlackKnifeItem.create());
|
||||
} else {
|
||||
target.getPersistentDataContainer().set(MAGIC_DAMAGE, PersistentDataType.BYTE, (byte) 1);
|
||||
target.damage(999.0, p);
|
||||
target.getPersistentDataContainer().remove(MAGIC_DAMAGE);
|
||||
target.getWorld().spawnParticle(org.bukkit.Particle.EXPLOSION, target.getLocation().add(0, 1, 0), 1);
|
||||
target.getWorld().playSound(target.getLocation(), Sound.ENTITY_WARDEN_SONIC_BOOM, 1f, 0.5f);
|
||||
p.sendActionBar(Component.text("SWOON! " + target.getName() + " -999").color(NamedTextColor.DARK_RED));
|
||||
}
|
||||
target.getWorld().spawnParticle(org.bukkit.Particle.SWEEP_ATTACK, target.getLocation().add(0, 1, 0), 1);
|
||||
target.getWorld().spawnParticle(org.bukkit.Particle.SOUL, target.getLocation().add(0, 1, 0), 20, 0.5, 0.5, 0.5, 0.02);
|
||||
p.setCooldown(Material.NETHERITE_SWORD, 160);
|
||||
p.playSound(p.getLocation(), Sound.ITEM_TRIDENT_THUNDER, 1f, 0.7f);
|
||||
}
|
||||
|
||||
public static boolean isSwooned(LivingEntity e) {
|
||||
return e.getPersistentDataContainer().has(SWOONED, PersistentDataType.BYTE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package me.sashegdev.blackknife;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Marker;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class SwordAttack {
|
||||
public static boolean tryUse(Player p, TensionManager tension) {
|
||||
if (tension.getTP(p) < 12.5f) { p.sendActionBar(net.kyori.adventure.text.Component.text("Need 5% TP").color(net.kyori.adventure.text.format.NamedTextColor.RED)); return false; }
|
||||
tension.setTP(p, tension.getTP(p) - 12.5f);
|
||||
launch(p, tension, p.getEyeLocation().getDirection().normalize(), 2.0);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void launch(Player p, TensionManager tension, Vector dir, double speed) {
|
||||
dir = dir.clone().normalize();
|
||||
Location spawn = p.getLocation().add(0, 2.2, 0).add(dir.clone().multiply(1));
|
||||
Marker marker = p.getWorld().spawn(spawn, Marker.class, m -> m.setPersistent(false));
|
||||
EntityTracker.mark(marker);
|
||||
p.getWorld().playSound(spawn, Sound.ENTITY_PLAYER_ATTACK_SWEEP, 1f, 1.2f);
|
||||
BlackKnifePlugin plugin = BlackKnifePlugin.getPlugin(BlackKnifePlugin.class);
|
||||
Vector initVel = dir.clone().multiply(speed);
|
||||
new BukkitRunnable() {
|
||||
Vector vel = initVel.clone();
|
||||
int homingTicks = 30;
|
||||
@Override public void run() {
|
||||
if (!marker.isValid() || marker.isDead()) { cancel(); return; }
|
||||
if (homingTicks > 0) {
|
||||
Vector gaze = p.getEyeLocation().getDirection().normalize().multiply(speed);
|
||||
vel = vel.multiply(0.82).add(gaze.multiply(0.18)).normalize().multiply(speed);
|
||||
homingTicks--;
|
||||
}
|
||||
Location cur = marker.getLocation();
|
||||
Location nl = cur.clone().add(vel);
|
||||
Vector step = nl.clone().subtract(cur).toVector();
|
||||
double len = step.length();
|
||||
int steps = Math.max(1, (int) Math.ceil(len / 0.5));
|
||||
for (int s = 0; s <= steps; s++) {
|
||||
Location check = cur.clone().add(step.clone().multiply((double) s / steps));
|
||||
if (check.getBlock().isSolid()) {
|
||||
Location expl = cur.clone().add(step.clone().multiply(Math.max(0, (double) (s - 1) / steps)));
|
||||
marker.teleport(expl);
|
||||
for (int k = 0; k < 12; k++) {
|
||||
double a = (double) k / 12 * Math.PI * 2;
|
||||
for (int h = -1; h <= 1; h++) {
|
||||
Location sphere = expl.clone().add(Math.cos(a) * 0.5, h * 0.25, Math.sin(a) * 0.5);
|
||||
sphere.getWorld().spawnParticle(Particle.SMOKE, sphere, 1, 0.02, 0.02, 0.02, 0);
|
||||
sphere.getWorld().spawnParticle(Particle.DUST, sphere, 1, 0, 0, 0, 0, new Particle.DustOptions(Color.fromRGB(30, 30, 30), 0.9f));
|
||||
}
|
||||
}
|
||||
expl.getWorld().spawnParticle(Particle.CRIT, expl, 6, 0.2, 0.2, 0.2, 0.05);
|
||||
expl.getWorld().playSound(expl, Sound.BLOCK_STONE_BREAK, 1f, 0.8f);
|
||||
marker.remove();
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
}
|
||||
int points = Math.max(1, (int) (len * 4));
|
||||
for (int i = 0; i <= points; i++) {
|
||||
Location pp = cur.clone().add(step.clone().multiply((double) i / points));
|
||||
pp.getWorld().spawnParticle(Particle.DUST, pp, 1, 0, 0, 0, 0, new Particle.DustOptions(Color.fromRGB(0, 0, 0), 1.5f));
|
||||
}
|
||||
marker.teleport(nl);
|
||||
for (var ent : nl.getWorld().getNearbyEntities(nl, 0.7, 0.7, 0.7, e -> e instanceof LivingEntity && e != p)) {
|
||||
LivingEntity le = (LivingEntity) ent;
|
||||
le.getPersistentDataContainer().set(SwoonHandler.MAGIC_DAMAGE, PersistentDataType.BYTE, (byte) 1);
|
||||
le.damage(15.0, p);
|
||||
Location hit = le.getLocation().add(0, 1, 0);
|
||||
for (int k = 0; k < 12; k++) {
|
||||
double a = (double) k / 12 * Math.PI * 2;
|
||||
for (int h = -1; h <= 1; h++) {
|
||||
Location sphere = hit.clone().add(Math.cos(a) * 0.5, h * 0.25, Math.sin(a) * 0.5);
|
||||
sphere.getWorld().spawnParticle(Particle.SMOKE, sphere, 1, 0.02, 0.02, 0.02, 0);
|
||||
sphere.getWorld().spawnParticle(Particle.DUST, sphere, 1, 0, 0, 0, 0, new Particle.DustOptions(Color.fromRGB(40, 40, 40), 0.9f));
|
||||
}
|
||||
}
|
||||
hit.getWorld().spawnParticle(Particle.CRIT, hit, 10, 0.3, 0.3, 0.3, 0.1);
|
||||
hit.getWorld().playSound(hit, Sound.ENTITY_PLAYER_ATTACK_CRIT, 1f, 0.9f);
|
||||
le.addPotionEffect(new org.bukkit.potion.PotionEffect(org.bukkit.potion.PotionEffectType.SLOWNESS, 40, 1, false, false, true));
|
||||
le.addPotionEffect(new org.bukkit.potion.PotionEffect(org.bukkit.potion.PotionEffectType.WEAKNESS, 30, 0, false, false, true));
|
||||
marker.remove();
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
for (Player pl : nl.getWorld().getNearbyPlayers(nl, 0.9)) {
|
||||
if (pl == p) continue;
|
||||
double d = pl.getLocation().add(0, 1, 0).distanceSquared(nl);
|
||||
if (d > 0.25 && d < 0.81) {
|
||||
BlackKnifePlugin.getPlugin(BlackKnifePlugin.class).getTension().addTP(pl, 2.5f, "DODGE +1%");
|
||||
pl.getWorld().spawnParticle(Particle.DUST, pl.getLocation().add(0, 0.25, 0), 25, 0.5, 0.05, 0.5, 0, new Particle.DustOptions(Color.fromRGB(255, 255, 255), 0.15f));
|
||||
}
|
||||
}
|
||||
if (nl.distanceSquared(p.getEyeLocation()) > 14400) { marker.remove(); cancel(); return; }
|
||||
if (marker.getTicksLived() > 80) { marker.remove(); cancel(); }
|
||||
}
|
||||
}.runTaskTimer(plugin, 1L, 1L);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
package me.sashegdev.blackknife;
|
||||
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TensionManager implements Listener {
|
||||
private final Map<UUID, Float> tp = new HashMap<>();
|
||||
final Map<UUID, BossBar> bars = new HashMap<>();
|
||||
private final Map<UUID, Long> blockStart = new HashMap<>();
|
||||
private final Map<UUID, Long> lastCombat = new HashMap<>();
|
||||
private final Map<UUID, java.util.Set<UUID>> battleEnemies = new HashMap<>();
|
||||
|
||||
public float getTP(Player p) { return tp.getOrDefault(p.getUniqueId(), 0f); }
|
||||
|
||||
public void setTP(Player p, float v) {
|
||||
float clamped = Math.max(0, Math.min(250, v));
|
||||
tp.put(p.getUniqueId(), clamped);
|
||||
updateBar(p, clamped);
|
||||
}
|
||||
|
||||
public void addTP(Player p, float amount, String reason) {
|
||||
float cur = Math.min(250, getTP(p) + amount);
|
||||
tp.put(p.getUniqueId(), cur);
|
||||
lastCombat.put(p.getUniqueId(), System.currentTimeMillis());
|
||||
updateBar(p, cur);
|
||||
if (amount > 0) p.sendActionBar(Component.text(String.format("+%.0f%% TP %s", amount / 2.5f, reason)).color(NamedTextColor.YELLOW));
|
||||
}
|
||||
|
||||
public boolean isOwner(Player p) {
|
||||
return BlackKnifeItem.is(p.getInventory().getItemInMainHand()) || BlackKnifeItem.is(p.getInventory().getItemInOffHand());
|
||||
}
|
||||
|
||||
private void updateBar(Player p, float tpVal) {
|
||||
BossBar bar = bars.get(p.getUniqueId());
|
||||
if (bar == null) {
|
||||
bar = BossBar.bossBar(Component.text("TP 0%"), 0f, BossBar.Color.WHITE, BossBar.Overlay.NOTCHED_10);
|
||||
bars.put(p.getUniqueId(), bar);
|
||||
}
|
||||
float pct = tpVal / 250f;
|
||||
bar.progress(Math.max(0, Math.min(1, pct)));
|
||||
bar.name(Component.text(String.format("TP %.0f%%", pct * 100)).color(NamedTextColor.WHITE));
|
||||
bar.color(BossBar.Color.WHITE);
|
||||
if (tpVal > 0) bar.addViewer(p); else bar.removeViewer(p);
|
||||
}
|
||||
|
||||
public void showFor(Player p) {
|
||||
BossBar bar = bars.get(p.getUniqueId());
|
||||
if (bar == null) {
|
||||
updateBar(p, getTP(p));
|
||||
bar = bars.get(p.getUniqueId());
|
||||
}
|
||||
if (getTP(p) > 0) bar.addViewer(p);
|
||||
}
|
||||
|
||||
public boolean isInBattle(Player p) {
|
||||
java.util.Set<UUID> set = battleEnemies.get(p.getUniqueId());
|
||||
return set != null && !set.isEmpty();
|
||||
}
|
||||
|
||||
public void startBattle(Player attacker, org.bukkit.entity.LivingEntity defender) {
|
||||
battleEnemies.computeIfAbsent(attacker.getUniqueId(), k -> new java.util.HashSet<>()).add(defender.getUniqueId());
|
||||
lastCombat.put(attacker.getUniqueId(), System.currentTimeMillis());
|
||||
if (getTP(attacker) > 0) showFor(attacker);
|
||||
if (defender instanceof Player dp) {
|
||||
battleEnemies.computeIfAbsent(dp.getUniqueId(), k -> new java.util.HashSet<>()).add(attacker.getUniqueId());
|
||||
lastCombat.put(dp.getUniqueId(), System.currentTimeMillis());
|
||||
if (getTP(dp) > 0) showFor(dp);
|
||||
}
|
||||
}
|
||||
|
||||
public void tickBattle() {
|
||||
long now = System.currentTimeMillis();
|
||||
for (var e : new java.util.HashMap<>(battleEnemies).entrySet()) {
|
||||
UUID pid = e.getKey();
|
||||
java.util.Set<UUID> set = e.getValue();
|
||||
set.removeIf(uuid -> {
|
||||
var ent = org.bukkit.Bukkit.getEntity(uuid);
|
||||
return ent == null || !ent.isValid() || (ent instanceof org.bukkit.entity.LivingEntity le && le.isDead());
|
||||
});
|
||||
Long last = lastCombat.get(pid);
|
||||
if (set.isEmpty() || (last != null && now - last > 180000)) {
|
||||
battleEnemies.remove(pid);
|
||||
lastCombat.remove(pid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasHeldShield(Player p) {
|
||||
return p.isBlocking() && (p.getInventory().getItemInMainHand().getType() == org.bukkit.Material.SHIELD || p.getInventory().getItemInOffHand().getType() == org.bukkit.Material.SHIELD);
|
||||
}
|
||||
|
||||
public void tickShield() {
|
||||
long now = System.currentTimeMillis();
|
||||
for (Player p : org.bukkit.Bukkit.getOnlinePlayers()) {
|
||||
if (hasHeldShield(p)) {
|
||||
long start = blockStart.getOrDefault(p.getUniqueId(), now);
|
||||
if (!blockStart.containsKey(p.getUniqueId())) blockStart.put(p.getUniqueId(), now);
|
||||
if (now - start >= 5000) {
|
||||
addTP(p, 25f, "SHIELD");
|
||||
blockStart.put(p.getUniqueId(), now);
|
||||
lastCombat.put(p.getUniqueId(), now);
|
||||
}
|
||||
} else if (!hasHeldShield(p)) {
|
||||
blockStart.remove(p.getUniqueId());
|
||||
}
|
||||
if (isOwner(p)) {
|
||||
float cur = getTP(p);
|
||||
if (cur < 250) {
|
||||
float next = Math.min(250, cur + 2f);
|
||||
tp.put(p.getUniqueId(), next);
|
||||
updateBar(p, next);
|
||||
}
|
||||
}
|
||||
}
|
||||
tickBattle();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent e) { updateBar(e.getPlayer(), getTP(e.getPlayer())); }
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent e) { bars.remove(e.getPlayer().getUniqueId()); }
|
||||
|
||||
public void hideAll() {
|
||||
for (var e : new HashMap<>(bars).entrySet()) {
|
||||
var bar = e.getValue();
|
||||
var p = org.bukkit.Bukkit.getPlayer(e.getKey());
|
||||
if (p != null) bar.removeViewer(p);
|
||||
else {
|
||||
for (var pl : org.bukkit.Bukkit.getOnlinePlayers()) bar.removeViewer(pl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDeath(PlayerDeathEvent e) {
|
||||
Player p = e.getEntity();
|
||||
tp.put(p.getUniqueId(), 0f);
|
||||
BossBar bar = bars.get(p.getUniqueId());
|
||||
if (bar != null) { bar.progress(0); bar.name(Component.text("TP 0%")); bar.removeViewer(p); }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
name: BlackKnife
|
||||
version: '1.0.0'
|
||||
main: me.sashegdev.blackknife.BlackKnifePlugin
|
||||
api-version: '1.21'
|
||||
prefix: BlackKnife
|
||||
author: SashegDev
|
||||
description: Black Knife with Roaring Knight attacks (SWOON, Stars, etc.) for Paper 1.21.1 - open world, TimelineFX
|
||||
|
||||
commands:
|
||||
blackknife:
|
||||
description: BlackKnife admin
|
||||
usage: /blackknife give [player]
|
||||
permission: blackknife.admin
|
||||
magic:
|
||||
description: Magic orb
|
||||
usage: /magic give|reroll|stats
|
||||
permission: blackknife.admin
|
||||
permissions:
|
||||
blackknife.use:
|
||||
default: true
|
||||
blackknife.admin:
|
||||
default: op
|
||||
Reference in New Issue
Block a user