From d022fe4f362ec327beebf9801eb5b5b54ef6b8c6 Mon Sep 17 00:00:00 2001 From: TheTelly1 <93684527+TheTelly1@users.noreply.github.com> Date: Fri, 30 Jun 2023 19:49:34 -0500 Subject: [PATCH] Best commit name frfr (admin util drag still broken) --- .../fun/ogre/ogredupealias/OgreDupeAlias.java | 25 +++-- .../commands/commands/GiveCustomCommand.java | 16 +++- .../events/InteractionListener.java | 2 + .../events/SPBEventListener.java | 41 +++++--- .../events/TurfWarsEventListener.java | 5 +- .../ogredupealias/plugin/ItemPresets.java | 12 ++- .../plugin/funitems/LaserPointer.java | 54 +++++++++++ .../plugin/funitems/Pickler.java | 83 ++++++++++++++++ .../plugin/funitems/SPBItems.java | 1 + .../ogredupealias/utils/DisplayUtils.java | 95 +++++++++++++------ .../ogre/ogredupealias/utils/PlayerUtils.java | 23 ++++- .../ogre/ogredupealias/utils/ServerUtils.java | 8 +- src/main/resources/plugin.yml | 8 +- 13 files changed, 311 insertions(+), 62 deletions(-) create mode 100644 src/main/java/fun/ogre/ogredupealias/plugin/funitems/LaserPointer.java create mode 100644 src/main/java/fun/ogre/ogredupealias/plugin/funitems/Pickler.java diff --git a/src/main/java/fun/ogre/ogredupealias/OgreDupeAlias.java b/src/main/java/fun/ogre/ogredupealias/OgreDupeAlias.java index c337482..73b6d01 100644 --- a/src/main/java/fun/ogre/ogredupealias/OgreDupeAlias.java +++ b/src/main/java/fun/ogre/ogredupealias/OgreDupeAlias.java @@ -4,6 +4,8 @@ import fun.ogre.ogredupealias.commands.commands.*; import fun.ogre.ogredupealias.data.Config; import fun.ogre.ogredupealias.events.*; import fun.ogre.ogredupealias.plugin.custom.forging.CraftingKeys; +import fun.ogre.ogredupealias.plugin.funitems.AdminUtility; +import fun.ogre.ogredupealias.plugin.funitems.Pickler; import fun.ogre.ogredupealias.plugin.funitems.PotatoCannon; import org.bukkit.Bukkit; import org.bukkit.plugin.PluginManager; @@ -35,17 +37,20 @@ public final class OgreDupeAlias extends JavaPlugin { public void init() { // Events - pm.registerEvents(new ChatEventListener(),this); - pm.registerEvents(new PlayerEventListener(),this); - pm.registerEvents(new CommandEventListener(),this); - pm.registerEvents(new BlockActionListener(),this); - pm.registerEvents(new EntityDeathListener(),this); - pm.registerEvents(new InteractionListener(),this); - pm.registerEvents(new InventoryActionListener(),this); - pm.registerEvents(new EntityDamageListener(),this); + pm.registerEvents(new ChatEventListener(), this); + pm.registerEvents(new PlayerEventListener(), this); + pm.registerEvents(new CommandEventListener(), this); + pm.registerEvents(new BlockActionListener(), this); + pm.registerEvents(new EntityDeathListener(), this); + pm.registerEvents(new InteractionListener(), this); + pm.registerEvents(new InventoryActionListener(), this); + pm.registerEvents(new EntityDamageListener(), this); pm.registerEvents(new SnowBallListener(), this); pm.registerEvents(new TurfWarsEventListener(), this); pm.registerEvents(new PotatoCannon(), this); + pm.registerEvents(new AdminUtility(), this); + pm.registerEvents(new Pickler(), this); + pm.registerEvents(new SPBEventListener(), this); // Commands getCommand("forcefield").setExecutor(new ForceFieldCommand()); @@ -67,6 +72,8 @@ public final class OgreDupeAlias extends JavaPlugin { getCommand("message").setTabCompleter(new MessageCommand()); getCommand("attackcooldown").setExecutor(new AttackCooldownCommand()); getCommand("attackcooldown").setTabCompleter(new AttackCooldownCommand()); + getCommand("givecustom").setExecutor(new GiveCustomCommand()); + getCommand("givecustom").setTabCompleter(new GiveCustomCommand()); } public void initConfig() { @@ -77,4 +84,4 @@ public final class OgreDupeAlias extends JavaPlugin { public static String prefix() { return Config.Plugin.prefix(); } -} +} \ No newline at end of file diff --git a/src/main/java/fun/ogre/ogredupealias/commands/commands/GiveCustomCommand.java b/src/main/java/fun/ogre/ogredupealias/commands/commands/GiveCustomCommand.java index 8584c5c..8163432 100644 --- a/src/main/java/fun/ogre/ogredupealias/commands/commands/GiveCustomCommand.java +++ b/src/main/java/fun/ogre/ogredupealias/commands/commands/GiveCustomCommand.java @@ -52,6 +52,18 @@ public class GiveCustomCommand implements TabExecutor { p.getInventory().addItem(ItemPresets.SPLEEFER); p.sendMessage(Text.ofAll("&bGiven you a Spleefer")); } + case "PotatoCannon" -> { + p.getInventory().addItem(ItemPresets.POTATOCANNON); + p.sendMessage(Text.ofAll("&bGiven you a potato cannon")); + } + case "LaserPointer" -> { + p.getInventory().addItem(ItemPresets.LASER_POINTER); + p.sendMessage(Text.ofAll("&bGiven you a Laser Pointer")); + } + case "Pickler" -> { + p.getInventory().addItem(ItemPresets.PICKLER); + p.sendMessage(Text.ofAll("&bGiven you a Pickler")); + } } } catch (Exception ex) { @@ -72,7 +84,9 @@ public class GiveCustomCommand implements TabExecutor { "NetSkyBlade", "SnowChinegun", "VoidCharm", - "Spleefer" + "Spleefer", + "PotatoCannon", + "LaserPointer" }) .build(); } diff --git a/src/main/java/fun/ogre/ogredupealias/events/InteractionListener.java b/src/main/java/fun/ogre/ogredupealias/events/InteractionListener.java index 3d399c8..3dfe873 100644 --- a/src/main/java/fun/ogre/ogredupealias/events/InteractionListener.java +++ b/src/main/java/fun/ogre/ogredupealias/events/InteractionListener.java @@ -41,6 +41,8 @@ public class InteractionListener implements Listener { PotatoCannon.handlePotatoCannon(e); PlayerEventListener.handleEnderPearls(e); SPBItems.handleRifle(e); + LaserPointer.handleLaserPointer(e); + Pickler.handlePickler(e); } catch (Exception ignore) {} } diff --git a/src/main/java/fun/ogre/ogredupealias/events/SPBEventListener.java b/src/main/java/fun/ogre/ogredupealias/events/SPBEventListener.java index 754e468..94f2c1e 100644 --- a/src/main/java/fun/ogre/ogredupealias/events/SPBEventListener.java +++ b/src/main/java/fun/ogre/ogredupealias/events/SPBEventListener.java @@ -7,6 +7,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; import org.bukkit.World; +import org.bukkit.block.data.type.Snow; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.entity.Projectile; @@ -20,26 +21,36 @@ import java.util.List; public class SPBEventListener implements Listener { @EventHandler public void onProjectileHit(ProjectileHitEvent e) { - Projectile proj = e.getEntity(); - if (proj.getType() == EntityType.SNOWBALL && proj.getShooter() instanceof Player shooter) { - Snowball snowball = (Snowball) proj; - if (snowball.getItem().getType() == Material.BLUE_DYE || snowball.getItem().getType() == Material.BLUE_DYE) { - if (!e.getHitBlock().getType().equals(Material.COMMAND_BLOCK) && !e.getHitBlock().getType().equals(Material.CHAIN_COMMAND_BLOCK) && !e.getHitBlock().getType().equals(Material.REPEATING_COMMAND_BLOCK)) { - SoundPlayer splatSound = new SoundPlayer(e.getHitBlock().getLocation(), Sound.ITEM_GLOW_INK_SAC_USE,1,1); - splatSound.playWithin(10); - List tags = PlayerUtils.getTags(shooter); - for (String tag : tags) { - switch (tag) { - case "SPBfire" -> { - DisplayUtils.tempBlocks(e.getHitBlock(),Material.RED_TERRACOTTA,60); - } - case "SPBfrost" -> { - DisplayUtils.tempBlocks(e.getHitBlock(),Material.BLUE_TERRACOTTA,60); + try { + Projectile proj = e.getEntity(); + if (proj instanceof Snowball && proj.getShooter() instanceof Player shooter) { + Snowball snowball = (Snowball) proj; + shooter.sendMessage("Hit a block"); + if (snowball.getItem().getType() == Material.BLUE_DYE || snowball.getItem().getType() == Material.BLUE_DYE) { + shooter.sendMessage("Passed dye check"); + if (!e.getHitBlock().getType().equals(Material.COMMAND_BLOCK) && !e.getHitBlock().getType().equals(Material.CHAIN_COMMAND_BLOCK) && !e.getHitBlock().getType().equals(Material.REPEATING_COMMAND_BLOCK)) { + shooter.sendMessage("Passed command block check"); + SoundPlayer splatSound = new SoundPlayer(e.getHitBlock().getLocation(), Sound.ITEM_GLOW_INK_SAC_USE,1,1); + splatSound.playWithin(10); + List tags = PlayerUtils.getTags(shooter); + for (String tag : tags) { + switch (tag) { + case "SPBfire" -> { + shooter.sendMessage("You were fire"); + DisplayUtils.tempBlocks(e.getHitBlock(),Material.RED_TERRACOTTA,2,600); + } + case "SPBfrost" -> { + shooter.sendMessage("You were frost"); + DisplayUtils.tempBlocks(e.getHitBlock(),Material.BLUE_TERRACOTTA,2,600); + } } } } } } + } catch (Exception ex) { + ex.printStackTrace(); } } + } diff --git a/src/main/java/fun/ogre/ogredupealias/events/TurfWarsEventListener.java b/src/main/java/fun/ogre/ogredupealias/events/TurfWarsEventListener.java index 7e7514d..85e2bff 100644 --- a/src/main/java/fun/ogre/ogredupealias/events/TurfWarsEventListener.java +++ b/src/main/java/fun/ogre/ogredupealias/events/TurfWarsEventListener.java @@ -93,8 +93,11 @@ 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,8,7D); + shredderShot(p,300,30D); } shredderShot(p,8,10D); } diff --git a/src/main/java/fun/ogre/ogredupealias/plugin/ItemPresets.java b/src/main/java/fun/ogre/ogredupealias/plugin/ItemPresets.java index 91bbd03..652b2a9 100644 --- a/src/main/java/fun/ogre/ogredupealias/plugin/ItemPresets.java +++ b/src/main/java/fun/ogre/ogredupealias/plugin/ItemPresets.java @@ -92,8 +92,8 @@ public abstract class ItemPresets { public static ItemStack LASER_POINTER = ItemBuilder.create() .material(Material.LIME_CANDLE) .name(Text.color("&2&l-&a&l[&bLaser Pointer&a&l]&2&l-")) - .lore(Text.color("&2▪ &aRight-Click:&7 Single Dot")) - .lore(Text.color("&2▪ &aLeft-Click:&7 Full Beam")) + .lore(Text.color("&2▪ &aRight-Click:&7 Full Beam")) + .lore(Text.color("&2▪ &aLeft-Click:&7 Select Block")) .customModelData(1111) .enchant(Enchantment.VANISHING_CURSE, 1) .flag(ItemFlag.HIDE_ENCHANTS) @@ -144,7 +144,13 @@ public abstract class ItemPresets { public static ItemStack SPBRifle = ItemBuilder.create() .material(Material.IRON_HORSE_ARMOR) .name(Text.color("&f[SPB] &eRifle")) - .lore(Text.color("&7&e▪ &fRight-Click:&7 Shoot")) + .lore(Text.color("&e▪ &fRight-Click:&7 Shoot")) + .customModelData(1111) + .build(); + public static ItemStack PICKLER = ItemBuilder.create() + .material(Material.SEA_PICKLE) + .name(Text.color("&2&lPickler")) + .lore(Text.color("&2▪ &aRight-Click:&7 Pickle-ify Someone")) .customModelData(1111) .build(); } diff --git a/src/main/java/fun/ogre/ogredupealias/plugin/funitems/LaserPointer.java b/src/main/java/fun/ogre/ogredupealias/plugin/funitems/LaserPointer.java new file mode 100644 index 0000000..23e4a4f --- /dev/null +++ b/src/main/java/fun/ogre/ogredupealias/plugin/funitems/LaserPointer.java @@ -0,0 +1,54 @@ +package fun.ogre.ogredupealias.plugin.funitems; + +import fun.ogre.ogredupealias.OgreDupeAlias; +import fun.ogre.ogredupealias.plugin.ItemPresets; +import fun.ogre.ogredupealias.utils.DisplayUtils; +import fun.ogre.ogredupealias.utils.ItemUtils; +import fun.ogre.ogredupealias.utils.RaycastUtils; +import org.bukkit.*; +import org.bukkit.entity.Player; +import org.bukkit.event.block.Action; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import java.util.concurrent.atomic.AtomicReference; + + +public class LaserPointer { + public static void handleLaserPointer(PlayerInteractEvent e) { + Player p = e.getPlayer(); + ItemStack stack = e.getItem(); + Action a = e.getAction(); + Location start = p.getEyeLocation(); + Vector rot = p.getLocation().getDirection(); + if (!ItemUtils.matchDisplay(stack, ItemPresets.LASER_POINTER)) return; + e.setCancelled(true); + switch (a) { + case RIGHT_CLICK_AIR, RIGHT_CLICK_BLOCK -> { + // Full beam + RaycastUtils.raycast(start,rot,30,0.1,(point) -> { + Particle.DustOptions dust = new Particle.DustOptions(Color.LIME, 0.5F); + point.getWorld().spawnParticle(Particle.REDSTONE,point,1,0,0,0,0,dust); + return !point.getBlock().getType().equals(Material.AIR); + }); + } + case LEFT_CLICK_AIR, LEFT_CLICK_BLOCK -> { + // Select Block + Location block = RaycastUtils.raycast(start,rot,60,0.5,(point) -> { + return !point.getBlock().isPassable(); + }); + AtomicReference counter = new AtomicReference<>(0); + Bukkit.getScheduler().scheduleSyncRepeatingTask(OgreDupeAlias.instance, () -> { + if (counter.get() > 60) return; + DisplayUtils.outLineBlock(block.getBlock(), (point) -> { + Particle.DustOptions dust = new Particle.DustOptions(Color.LIME, 0.5F); + block.getWorld().spawnParticle(Particle.REDSTONE,point,1,0,0,0,0,dust); + return false; + }); + counter.set(counter.get() + 1); + },0,1); + } + } + } +} diff --git a/src/main/java/fun/ogre/ogredupealias/plugin/funitems/Pickler.java b/src/main/java/fun/ogre/ogredupealias/plugin/funitems/Pickler.java new file mode 100644 index 0000000..92169dd --- /dev/null +++ b/src/main/java/fun/ogre/ogredupealias/plugin/funitems/Pickler.java @@ -0,0 +1,83 @@ +package fun.ogre.ogredupealias.plugin.funitems; + +import fun.ogre.ogredupealias.OgreDupeAlias; +import fun.ogre.ogredupealias.plugin.ItemPresets; +import fun.ogre.ogredupealias.utils.*; +import org.bukkit.*; +import org.bukkit.block.Block; +import org.bukkit.block.BlockState; +import org.bukkit.block.data.Waterlogged; +import org.bukkit.entity.Entity; +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.PlayerInteractAtEntityEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerMoveEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.Vector; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicReference; + +public class Pickler implements Listener { + public static void handlePickler(PlayerInteractEvent e) { + Player p = e.getPlayer(); + ItemStack stack = e.getItem(); + Action a = e.getAction(); + Location start = p.getEyeLocation(); + Vector rot = p.getLocation().getDirection(); + if (!ItemUtils.matchDisplay(stack, ItemPresets.PICKLER)) return; + e.setCancelled(true); + switch (a) { + case RIGHT_CLICK_AIR, RIGHT_CLICK_BLOCK -> { + // Pickle + 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 Player player && !player.isDead() && player != p; + })); + targets.forEach(target -> { + if (target instanceof Player targetedPlayer) { + // Player hit here + SoundPlayer pickleSound = new SoundPlayer(target.getLocation(), Sound.ITEM_GLOW_INK_SAC_USE, 1,1F); + pickleSound.playWithin(10); + Block pickleBlock = targetedPlayer.getLocation().getBlock(); + pickleBlock.setType(Material.SEA_PICKLE); + BlockState state = pickleBlock.getState(); + Waterlogged waterlogged = (Waterlogged) state.getBlockData(); + waterlogged.setWaterlogged(false); + pickleBlock.setBlockData(waterlogged, false); + PlayerUtils.addTag(targetedPlayer,"ODApickled"); + p.sendMessage(Text.color("&9Event> &7You have been turned &e" + targetedPlayer.getName() + "&7 into a pickle!")); + target.sendMessage(Text.color("&9Event> &7You have been turned into a pickle by &e" + p.getName() + "&7. Its the funniest thing they've ever seen!")); + targetedPlayer.setInvisible(true); + Bukkit.getScheduler().runTaskLater(OgreDupeAlias.instance,() -> { + PlayerUtils.removeTag(targetedPlayer,"ODApickled"); + target.getLocation().getBlock().setType(Material.AIR); + target.sendMessage(Text.color("&9Event> &7You are no longer a pickle.")); + targetedPlayer.setInvisible(false); + },120); + } + }); + return !targets.isEmpty(); + }); + } + } + } + @EventHandler + private void onMove(PlayerMoveEvent e) { + Player p = e.getPlayer(); + if (PlayerUtils.hasTag(p,"ODApickled")){ + e.setCancelled(true); + p.sendTitle(Text.color("&2&lI am a pickle"),Text.color("&aIts the funniest thing I've ever seen"), 0,1,1); + + } + } +} diff --git a/src/main/java/fun/ogre/ogredupealias/plugin/funitems/SPBItems.java b/src/main/java/fun/ogre/ogredupealias/plugin/funitems/SPBItems.java index f2a8104..6a62afe 100644 --- a/src/main/java/fun/ogre/ogredupealias/plugin/funitems/SPBItems.java +++ b/src/main/java/fun/ogre/ogredupealias/plugin/funitems/SPBItems.java @@ -43,6 +43,7 @@ public class SPBItems { } } snowball.setVelocity(vec.multiply(2)); + snowball.setShooter(p); SoundPlayer shootSound = new SoundPlayer(p.getLocation(), Sound.ENTITY_ITEM_FRAME_REMOVE_ITEM,10,1); shootSound.playWithin(30); } diff --git a/src/main/java/fun/ogre/ogredupealias/utils/DisplayUtils.java b/src/main/java/fun/ogre/ogredupealias/utils/DisplayUtils.java index 0f93b94..f7d1cea 100644 --- a/src/main/java/fun/ogre/ogredupealias/utils/DisplayUtils.java +++ b/src/main/java/fun/ogre/ogredupealias/utils/DisplayUtils.java @@ -4,52 +4,63 @@ import fun.ogre.ogredupealias.OgreDupeAlias; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Particle; import org.bukkit.block.Block; import org.bukkit.util.Vector; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.atomic.AtomicReference; import java.util.function.BiPredicate; import java.util.function.Consumer; +import java.util.function.Predicate; import static fun.ogre.ogredupealias.OgreDupeAlias.instance; public final class DisplayUtils { - public static void tempBlocks(Block centerBlock, Material desiredMaterial, int tickDuration) { - // Store the original blocks' states and materials - Block[][] originalBlocks = new Block[3][3]; - String[][] originalMaterials = new String[3][3]; - - for (int dx = -1; dx <= 1; dx++) { - for (int dz = -1; dz <= 1; dz++) { - Block block = centerBlock.getRelative(dx, 0, dz); - originalBlocks[dx + 1][dz + 1] = block; - originalMaterials[dx + 1][dz + 1] = block.getType().name(); + public static void tempBlocks(Block centerBlock, Material desiredMaterial, int radius, int tickDuration) { + Location loc = centerBlock.getLocation(); + List blocks = new ArrayList<>(); + forEachBlockIn(loc.clone().add(radius,radius,radius), loc.clone().subtract(radius,radius,radius), (point) -> { + Block b = point.getBlock(); + if (!b.getType().isAir() && loc.distance(point) <= radius) { + blocks.add(b); + b.setType(desiredMaterial); } - } - - // Modify the blocks to the desired material - for (int dx = -1; dx <= 1; dx++) { - for (int dz = -1; dz <= 1; dz++) { - Block block = centerBlock.getRelative(dx, 0, dz); - block.setType(desiredMaterial); - } - } - - // Schedule a task to revert the blocks after the desired number of ticks + }); Bukkit.getScheduler().runTaskLater(instance, () -> { - for (int dx = -1; dx <= 1; dx++) { - for (int dz = -1; dz <= 1; dz++) { - Block block = centerBlock.getRelative(dx, 0, dz); - Material originalMaterial = Material.getMaterial(originalMaterials[dx + 1][dz + 1]); - if (originalMaterial != null) { - block.setType(originalMaterial); - } - block.setBlockData(originalBlocks[dx + 1][dz + 1].getBlockData()); + for (Block block : blocks) { + Location point = block.getLocation(); + Block b2 = point.getBlock(); + b2.setType(block.getType()); + b2.setBlockData(block.getBlockData()); + } + }, 60); + } + + public static void forEachBlockIn(Location start, Location end, Consumer action) { + int[] min = { + Math.min(start.getBlockX(), end.getBlockX()), + Math.min(start.getBlockY(), end.getBlockY()), + Math.min(start.getBlockZ(), end.getBlockZ()) + }; + int[] max = { + Math.max(start.getBlockX(), end.getBlockX()), + Math.max(start.getBlockY(), end.getBlockY()), + Math.max(start.getBlockZ(), end.getBlockZ()) + }; + + for (int a = min[0]; a <= max[0]; a ++) { + for (int b = min[1]; b <= max[1]; b ++) { + for (int c = min[2]; c <= max[2]; c ++) { + Location loc = new Location(start.getWorld(), a, b, c); + action.accept(loc); } } - }, tickDuration); + } } + public static void ring(Location center, double radius, Consumer onPoint, BiPredicate condition) { for (int i = 0; i <= 360; i ++) { Location point = center.clone().add(radius * Math.sin(i), 0, radius * Math.cos(i)); @@ -69,4 +80,28 @@ public final class DisplayUtils { } }, 0, interval); } + public static void outLineBlock(Block block, Predicate hitCondition) { + Location loc = block.getLocation(); + Location b1 = loc.clone().add(0,0,0); + Location b2 = loc.clone().add(1,0,0); + Location b3 = loc.clone().add(0,0,1); + Location b4 = loc.clone().add(1,0,1); + Location t1 = loc.clone().add(0,1,0); + Location t2 = loc.clone().add(1,1,0); + Location t3 = loc.clone().add(0,1,1); + Location t4 = loc.clone().add(1,1,1); + + RaycastUtils.raycast(b1,b2,0.2, hitCondition); + RaycastUtils.raycast(b1,b3,0.2, hitCondition); + RaycastUtils.raycast(b2,b4,0.2, hitCondition); + RaycastUtils.raycast(b3,b4,0.2, hitCondition); + RaycastUtils.raycast(b1,t1,0.2, hitCondition); + RaycastUtils.raycast(b2,t2,0.2, hitCondition); + RaycastUtils.raycast(b3,t3,0.2, hitCondition); + RaycastUtils.raycast(b4,t4,0.2, hitCondition); + RaycastUtils.raycast(t1,t2,0.2, hitCondition); + RaycastUtils.raycast(t1,t3,0.2, hitCondition); + RaycastUtils.raycast(t3,t4,0.2, hitCondition); + RaycastUtils.raycast(t2,t4,0.2, hitCondition); + } } diff --git a/src/main/java/fun/ogre/ogredupealias/utils/PlayerUtils.java b/src/main/java/fun/ogre/ogredupealias/utils/PlayerUtils.java index f4a2e4a..99bc91b 100644 --- a/src/main/java/fun/ogre/ogredupealias/utils/PlayerUtils.java +++ b/src/main/java/fun/ogre/ogredupealias/utils/PlayerUtils.java @@ -2,8 +2,10 @@ package fun.ogre.ogredupealias.utils; import fun.ogre.ogredupealias.OgreDupeAlias; import org.bukkit.Bukkit; +import org.bukkit.Material; import org.bukkit.attribute.Attribute; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import org.bukkit.scoreboard.Scoreboard; import java.util.ArrayList; @@ -29,7 +31,26 @@ public class PlayerUtils { return hasTag(p1, tag) == hasTag(p2, tag); } public static void safeKill(Player p) { - if (p.getBedSpawnLocation() == null) return; + if (p.getBedSpawnLocation() == null) { + p.teleport(p.getWorld().getSpawnLocation()); + return; + } + if (hasTag(p,"TWjester") && (hasTag(p,"TWblue"))) { + ServerUtils.forEachPlayerRun(players -> { + return hasTag(players,"TWplayer") && hasTag(players, "TWblue"); + }, players -> { + players.getInventory().addItem(new ItemStack(Material.ARROW,1)); + players.sendMessage(Text.color("&9Game> &7Your jester has fallen! You have been given an arrow.")); + }); + } + if (hasTag(p,"TWjester") && (hasTag(p,"TWred"))) { + ServerUtils.forEachPlayerRun(players -> { + return hasTag(players,"TWplayer") && hasTag(players, "TWred"); + }, players -> { + players.getInventory().addItem(new ItemStack(Material.ARROW,1)); + players.sendMessage(Text.color("&9Game> &7Your jester has fallen! You have been given an arrow.")); + }); + } p.teleport(p.getBedSpawnLocation()); Bukkit.getScheduler().runTaskLater(OgreDupeAlias.instance, () -> { p.setHealth(p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue()); diff --git a/src/main/java/fun/ogre/ogredupealias/utils/ServerUtils.java b/src/main/java/fun/ogre/ogredupealias/utils/ServerUtils.java index 3887acd..c017619 100644 --- a/src/main/java/fun/ogre/ogredupealias/utils/ServerUtils.java +++ b/src/main/java/fun/ogre/ogredupealias/utils/ServerUtils.java @@ -51,7 +51,13 @@ public class ServerUtils { public static void forEachSpecified(Consumer consumer, Player... players) { Arrays.stream(players).forEach(consumer); } - + public static void forEachPlayerRun(Predicate condition, Consumer task) { + forEachPlayer(p -> { + if (condition.test(p)) { + task.accept(p); + } + }); + } public static void sendActionBar(Player p, String msg) { p.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(msg)); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 5563338..90805f0 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -29,7 +29,7 @@ permissions: oda.commands.irepair: description: Access to irepair. default: op - oda.commands.givecustoms: + oda.commands.givecustom: description: access custom items default: op oda.commands.attackcooldown: @@ -60,6 +60,12 @@ permissions: default: op commands: + givecustom: + description: give custom items + usage: /givecustom + permission: oda.command.givecustom + aliases: + - givec config: description: Config management usage: /config [get|set]