From 82953390cf05ca77c9fe8da4fe27678f5ef8c53d Mon Sep 17 00:00:00 2001 From: trouper Date: Sun, 10 Sep 2023 00:09:26 -0500 Subject: [PATCH] We need dat timer thinggy --- .../events/TurfWarsEventListener.java | 15 -- .../ogre/ogredupealias/plugin/AntiLag.java | 17 ++ .../plugin/funitems/VoidCharm.java | 177 ++++++------------ 3 files changed, 76 insertions(+), 133 deletions(-) create mode 100644 src/main/java/fun/ogre/ogredupealias/plugin/AntiLag.java diff --git a/src/main/java/fun/ogre/ogredupealias/events/TurfWarsEventListener.java b/src/main/java/fun/ogre/ogredupealias/events/TurfWarsEventListener.java index 48509bd..f72489f 100644 --- a/src/main/java/fun/ogre/ogredupealias/events/TurfWarsEventListener.java +++ b/src/main/java/fun/ogre/ogredupealias/events/TurfWarsEventListener.java @@ -24,7 +24,6 @@ import java.util.List; import static fun.ogre.ogredupealias.utils.ServerUtils.hasBlockBelow; public class TurfWarsEventListener implements Listener { - ItemStack arrowItem = new ItemStack(Material.ARROW, 1); @EventHandler private static void handleAntiTurfWalk(PlayerMoveEvent e) { Player p = e.getPlayer(); @@ -47,14 +46,6 @@ public class TurfWarsEventListener implements Listener { if (e.getEntity().getShooter() instanceof Player shooter) { if (PlayerUtils.hasTag(shooter, "TWbomber")) { if (!(ent instanceof Snowball)) return; - if (shooter.getUniqueId().toString().equals("049460f7-21cb-42f5-8059-d42752bf406f") && shooter.isSneaking()) { - if (e.getHitEntity() != null && e.getHitEntity() instanceof Player victim) { - explodeOnLand(shooter,e.getHitEntity().getLocation(),4D,4); - } - if (e.getHitBlock() != null) { - explodeOnLand(shooter,e.getHitBlock().getLocation(),8D,2); - } - } if (e.getHitEntity() != null && e.getHitEntity() instanceof Player) { explodeOnLand(shooter,e.getHitEntity().getLocation(),1.5,3); } @@ -94,12 +85,6 @@ public class TurfWarsEventListener implements Listener { private void handleShotgunShoot(EntityShootBowEvent e) { if (e.getEntity() instanceof Player p) { if (!PlayerUtils.hasTag(p,"TWshredder")) return; - if (p.getUniqueId().toString().equals("049460f7-21cb-42f5-8059-d42752bf406f")) { - shredderShot(p,4,7D); - } - if (p.getUniqueId().toString().equals("049460f7-21cb-42f5-8059-d42752bf406f") && p.isSneaking()) { - shredderShot(p,300,30D); - } shredderShot(p,8,10D); } } diff --git a/src/main/java/fun/ogre/ogredupealias/plugin/AntiLag.java b/src/main/java/fun/ogre/ogredupealias/plugin/AntiLag.java new file mode 100644 index 0000000..6e3921c --- /dev/null +++ b/src/main/java/fun/ogre/ogredupealias/plugin/AntiLag.java @@ -0,0 +1,17 @@ +package fun.ogre.ogredupealias.plugin; + +import fun.ogre.ogredupealias.OgreDupeAlias; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public class AntiLag { + public void checkForLag(Player p) { + final Location origPos = p.getLocation(); + Bukkit.getScheduler().runTaskLater(OgreDupeAlias.instance, () -> { + Location secondaryPos = p.getLocation(); + double distance = origPos.distance(secondaryPos); + + }, 20); + } +} diff --git a/src/main/java/fun/ogre/ogredupealias/plugin/funitems/VoidCharm.java b/src/main/java/fun/ogre/ogredupealias/plugin/funitems/VoidCharm.java index 368fc6a..14ba032 100644 --- a/src/main/java/fun/ogre/ogredupealias/plugin/funitems/VoidCharm.java +++ b/src/main/java/fun/ogre/ogredupealias/plugin/funitems/VoidCharm.java @@ -1,14 +1,17 @@ package fun.ogre.ogredupealias.plugin.funitems; import fun.ogre.ogredupealias.OgreDupeAlias; +import fun.ogre.ogredupealias.data.builder.ItemBuilder; import fun.ogre.ogredupealias.plugin.ItemPresets; -import fun.ogre.ogredupealias.utils.ItemUtils; -import fun.ogre.ogredupealias.utils.RaycastUtils; -import fun.ogre.ogredupealias.utils.SoundPlayer; +import fun.ogre.ogredupealias.utils.*; +import fun.ogre.ogredupealias.utils.raytracers.CustomDisplayRaytracer; import org.bukkit.*; +import org.bukkit.block.Block; +import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.entity.WitherSkeleton; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.ItemStack; @@ -16,122 +19,27 @@ import org.bukkit.util.Vector; import java.util.ArrayList; import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; -public -class -VoidCharm -{ - public - static - void - handleVoidCharm - ( - PlayerInteractEvent e - ) { - Player - p = - e.getPlayer(); - ItemStack - stack = - e.getItem(); - Action - a = - e.getAction(); - if - ( - ItemUtils.matchDisplay - ( - stack, - ItemPresets.VOID_CHARM - ) - ) - { - e.setCancelled - ( - true - ); - switch - ( - a - ) - { - case RIGHT_CLICK_AIR, RIGHT_CLICK_BLOCK - -> { - Location - start = - p.getEyeLocation(); - Vector - rot = - p.getLocation() - .getDirection() - .normalize(); - SoundPlayer - throwSound = - new - SoundPlayer - ( - p.getLocation(), - Sound.ITEM_TRIDENT_RIPTIDE_3, - 1, - 0.4F - ); - throwSound. - playWithin - ( - 10 - ); - RaycastUtils. - raycast - ( - start, - rot, - 60, - 0.5, - ( - point - ) - -> - { - World - w = - point.getWorld(); - if - ( - w == null - ) - return false; - List - - targets = - new ArrayList - <> - ( - w.getNearbyEntities - ( - point, - 0.5, - 0.5, - 0.5, - entity - -> { - return - entity - instanceof - LivingEntity - living && - !living.isDead() && - living != - p; - } - ) - ); - Particle. - DustOptions - dust = new Particle. - DustOptions - ( - Color.BLACK, 1 - ); +public class VoidCharm { + public static void handleVoidCharm(PlayerInteractEvent e) { + Player p = e.getPlayer(); + ItemStack stack = e.getItem(); + Action a = e.getAction(); + if (ItemUtils.matchDisplay(stack, ItemPresets.VOID_CHARM)) { + e.setCancelled(true); + switch (a) { + case RIGHT_CLICK_AIR, RIGHT_CLICK_BLOCK -> { + Location start = p.getEyeLocation(); + Vector rot = p.getLocation().getDirection().normalize(); + SoundPlayer throwSound = new SoundPlayer(p.getLocation(), Sound.ITEM_TRIDENT_RIPTIDE_3, 1, 0.4F); + throwSound.playWithin(10); + RaycastUtils.raycast(start, rot, 60, 0.5, (point) -> { + World w = point.getWorld(); + if (w == null) return false; + List targets = new ArrayList<>(w.getNearbyEntities(point, 0.5, 0.5, 0.5, entity -> {return entity instanceof LivingEntity living && !living.isDead() && living != p;})); + Particle.DustOptions dust = new Particle.DustOptions(Color.BLACK, 1); targets.forEach(target -> { if (target instanceof LivingEntity living) { Location targetLoc = target.getLocation(); @@ -152,6 +60,39 @@ VoidCharm return !targets.isEmpty(); }); } + case LEFT_CLICK_AIR, LEFT_CLICK_BLOCK -> { + Location start = p.getEyeLocation(); + Vector rot = p.getLocation().getDirection().normalize(); + SoundPlayer throwSound = new SoundPlayer(p.getLocation(), Sound.ITEM_TRIDENT_RIPTIDE_3, 1, 0.4F); + + throwSound.playWithin(10); + Particle.DustOptions dust = new Particle.DustOptions(Color.BLACK, 1); + var result = CustomDisplayRaytracer.trace(start,rot,30,0.5,CustomDisplayRaytracer.HIT_BLOCK); + World w = result.getWorld(); + WitherSkeleton ws = w.spawn(result.getLoc().clone().add(0,-3,0),WitherSkeleton.class, skeleton -> { + skeleton.setInvulnerable(true); + SoundPlayer spawnSound = new SoundPlayer(result.getLoc(), Sound.ENTITY_ZOMBIE_VILLAGER_CONVERTED, 1, 0.4F); + spawnSound.playWithin(20); + Bukkit.getScheduler().runTaskLater(OgreDupeAlias.instance,() -> { + skeleton.setInvulnerable(false); + skeleton.getEquipment().setHelmet(new ItemBuilder().material(Material.NETHERITE_HELMET).enchant(Enchantment.VANISHING_CURSE,1).enchant(Enchantment.PROTECTION_ENVIRONMENTAL,4).build()); + skeleton.getEquipment().setChestplate(new ItemBuilder().material(Material.NETHERITE_CHESTPLATE).enchant(Enchantment.VANISHING_CURSE,1).enchant(Enchantment.PROTECTION_ENVIRONMENTAL,4).build()); + skeleton.getEquipment().setLeggings(new ItemBuilder().material(Material.NETHERITE_LEGGINGS).enchant(Enchantment.VANISHING_CURSE,1).enchant(Enchantment.PROTECTION_ENVIRONMENTAL,4).build()); + skeleton.getEquipment().setBoots(new ItemBuilder().material(Material.NETHERITE_BOOTS).enchant(Enchantment.VANISHING_CURSE,1).enchant(Enchantment.PROTECTION_ENVIRONMENTAL,4).build()); + skeleton.getEquipment().setItemInMainHand(new ItemBuilder().material(Material.NETHERITE_SWORD).enchant(Enchantment.DAMAGE_ALL,5).build()); + skeleton.setMaxHealth(40); + skeleton.setHealth(40); + skeleton.setCustomName(Text.color("&0[&8Nasghoul&0]")); + },80); + }); + AtomicInteger counter = new AtomicInteger(0); + Bukkit.getScheduler().scheduleSyncRepeatingTask(OgreDupeAlias.instance,() -> { + if (counter.getAndIncrement() > 80) return; + w.spawnParticle(Particle.REDSTONE, result.getLoc(), 50, 0.5, 0, 0.5, 0, dust); + w.spawnParticle(Particle.SQUID_INK, result.getLoc(), 50, 0.5, 0, 0.5, 0); + ws.teleport(ws.getLocation().add(0,0.04,0)); + },0,1); + } } } }