Added AdminUtility, VoidCharm and Defender

This commit is contained in:
TheTelly1
2023-06-05 08:09:48 -05:00
parent d1a4c9f8f0
commit 8b73a8b3e6
7 changed files with 594 additions and 23 deletions

View File

@@ -44,6 +44,7 @@ public final class OgreDupeAlias extends JavaPlugin {
pm.registerEvents(new EntityDamageListener(),this); pm.registerEvents(new EntityDamageListener(),this);
// Commands // Commands
getCommand("forcefield").setExecutor(new ForceFieldCommand());
getCommand("config").setExecutor(new ConfigCommand()); getCommand("config").setExecutor(new ConfigCommand());
getCommand("config").setTabCompleter(new ConfigCommand()); getCommand("config").setTabCompleter(new ConfigCommand());
getCommand("mutechat").setExecutor(new MuteChatCommand()); getCommand("mutechat").setExecutor(new MuteChatCommand());

View File

@@ -0,0 +1,43 @@
package fun.ogre.ogredupealias.commands.commands;
import fun.ogre.ogredupealias.commands.CmdExHandler;
import fun.ogre.ogredupealias.events.EntityDamageListener;
import fun.ogre.ogredupealias.events.InteractionListener;
import fun.ogre.ogredupealias.utils.Text;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class ForceFieldCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
try {
Player p = (Player) sender;
boolean isRecipient = InteractionListener.forceFieldProtected.isRecipient(p);
if (isRecipient) InteractionListener.forceFieldProtected.removeRecipient(p);
else InteractionListener.forceFieldProtected.addRecipient(p);
isRecipient = InteractionListener.forceFieldProtected.isRecipient(p);
sender.sendMessage(Text.builder()
.message("&7[&bForceField&7] &8>> &3You are " + (isRecipient ? "&anow" : "&cno longer") + " &3a protected.")
.prefix()
.color()
.build());
}
catch (Exception ex) {
CmdExHandler handler = new CmdExHandler(ex,command);
sender.sendMessage(handler.getHelp());
}
return true;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return new ArrayList<>();
}
}

View File

@@ -1,45 +1,228 @@
package fun.ogre.ogredupealias.events; package fun.ogre.ogredupealias.events;
import fun.ogre.ogredupealias.OgreDupeAlias;
import fun.ogre.ogredupealias.data.PlacedStructures; import fun.ogre.ogredupealias.data.PlacedStructures;
import fun.ogre.ogredupealias.plugin.InventoryPresets; import fun.ogre.ogredupealias.plugin.InventoryPresets;
import fun.ogre.ogredupealias.plugin.ItemPresets; import fun.ogre.ogredupealias.plugin.ItemPresets;
import fun.ogre.ogredupealias.utils.Cooldown; import fun.ogre.ogredupealias.plugin.RecipientList;
import fun.ogre.ogredupealias.utils.ItemUtils; import fun.ogre.ogredupealias.utils.*;
import fun.ogre.ogredupealias.utils.RaycastUtils; import org.bukkit.*;
import fun.ogre.ogredupealias.utils.SoundPlayer;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Entity; import org.bukkit.entity.*;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.ArrayList; import java.util.*;
import java.util.List; import java.util.concurrent.atomic.AtomicReference;
import java.util.UUID;
public class InteractionListener implements Listener { public class InteractionListener implements Listener {
public static final RecipientList forceFieldProtected = new RecipientList();
public static final Map<UUID, UUID> playerDragMap = new HashMap<>();
private static final Cooldown<UUID> netskySwordCooldown = new Cooldown<>(); private static final Cooldown<UUID> netskySwordCooldown = new Cooldown<>();
@EventHandler
public void onMove(PlayerMoveEvent e) {
Player p = e.getPlayer();
playerDragMap.forEach((draggerID, draggedID) -> {
Player dragger = Bukkit.getPlayer(draggerID);
Player dragged = Bukkit.getPlayer(draggedID);
if (dragged == null || dragger == null) return;
Location start = dragger.getEyeLocation();
Vector rot = dragger.getLocation().getDirection().normalize();
Location destinsation = RaycastUtils.raycast(start, rot, 5, 1, point -> {
return false;
});
dragged.teleport(destinsation);
});
}
@EventHandler
public void forceFieldCheck(PlayerMoveEvent e) {
Player p = e.getPlayer();
World w = e.getFrom().getWorld();
if (forceFieldProtected.isRecipient(p)) {
Particle.DustOptions dust = new Particle.DustOptions(Color.AQUA, 0.5F);
DisplayUtils.ring(p.getEyeLocation(), 4, (point) -> {
w.spawnParticle(Particle.REDSTONE, point, 1,0,0,0,0, dust);
List<Entity> targets = new ArrayList<>(w.getNearbyEntities(point, 0.5,10,0.5, entity -> {
return entity instanceof LivingEntity living && !living.isDead() && living != p;
}));
targets.forEach(target -> {
if (target instanceof LivingEntity living) {
SoundPlayer blockSound = new SoundPlayer(target.getLocation(), Sound.ITEM_SHIELD_BLOCK, 1, 1);
Vector direction = target.getLocation().toVector().subtract(p.getEyeLocation().toVector()).normalize();
double strength = 2.0;
double verticalMultiplier = 0.5;
living.setVelocity(direction.multiply(strength).setY(verticalMultiplier));
blockSound.playWithin(10);
}
});
}, (point, angle) -> {
return angle % 9 == 0;
});
DisplayUtils.ring(p.getEyeLocation().add(0,0.5,0),3.968, (point) -> {
w.spawnParticle(Particle.REDSTONE, point, 1,0,0,0,0, dust);
}, (point, angle) -> {
return angle % 9 == 0;
});
DisplayUtils.ring(p.getEyeLocation().add(0,1,0),3.872, (point) -> {
w.spawnParticle(Particle.REDSTONE, point, 1,0,0,0,0, dust);
}, (point, angle) -> {
return angle % 9 == 0;
});
DisplayUtils.ring(p.getEyeLocation().add(0,1.5,0),3.708, (point) -> {
w.spawnParticle(Particle.REDSTONE, point, 1,0,0,0,0, dust);
}, (point, angle) -> {
return angle % 9 == 0;
});
DisplayUtils.ring(p.getEyeLocation().add(0,2,0),3.464, (point) -> {
w.spawnParticle(Particle.REDSTONE, point, 1,0,0,0,0, dust);
}, (point, angle) -> {
return angle % 9 == 0;
});
DisplayUtils.ring(p.getEyeLocation().add(0,2.5,0),3.122, (point) -> {
w.spawnParticle(Particle.REDSTONE, point, 1,0,0,0,0, dust);
}, (point, angle) -> {
return angle % 9 == 0;
});
DisplayUtils.ring(p.getEyeLocation().add(0,3,0),2.645, (point) -> {
w.spawnParticle(Particle.REDSTONE, point, 1,0,0,0,0, dust);
}, (point, angle) -> {
return angle % 9 == 0;
});
DisplayUtils.ring(p.getEyeLocation().add(0,3.5,0),1.936, (point) -> {
w.spawnParticle(Particle.REDSTONE, point, 1,0,0,0,0, dust);
}, (point, angle) -> {
return angle % 9 == 0;
});
DisplayUtils.ring(p.getEyeLocation().add(0,4,0),0.9, (point) -> {
w.spawnParticle(Particle.REDSTONE, point, 1,0,0,0,0, dust);
}, (point, angle) -> {
return angle % 9 == 0;
});
DisplayUtils.ring(p.getEyeLocation().add(0,-0.5,0),3.968, (point) -> {
w.spawnParticle(Particle.REDSTONE, point, 1,0,0,0,0, dust);
}, (point, angle) -> {
return angle % 9 == 0;
});
DisplayUtils.ring(p.getEyeLocation().add(0,-1,0),3.872, (point) -> {
w.spawnParticle(Particle.REDSTONE, point, 1,0,0,0,0, dust);
}, (point, angle) -> {
return angle % 9 == 0;
});
DisplayUtils.ring(p.getEyeLocation().add(0,-1.5,0),3.708, (point) -> {
w.spawnParticle(Particle.REDSTONE, point, 1,0,0,0,0, dust);
}, (point, angle) -> {
return angle % 9 == 0;
});
DisplayUtils.ring(p.getEyeLocation().add(0,-2,0),3.464, (point) -> {
w.spawnParticle(Particle.REDSTONE, point, 1,0,0,0,0, dust);
}, (point, angle) -> {
return angle % 9 == 0;
});
DisplayUtils.ring(p.getEyeLocation().add(0,-2.5,0),3.122, (point) -> {
w.spawnParticle(Particle.REDSTONE, point, 1,0,0,0,0, dust);
}, (point, angle) -> {
return angle % 9 == 0;
});
DisplayUtils.ring(p.getEyeLocation().add(0,-3,0),2.645, (point) -> {
w.spawnParticle(Particle.REDSTONE, point, 1,0,0,0,0, dust);
}, (point, angle) -> {
return angle % 9 == 0;
});
DisplayUtils.ring(p.getEyeLocation().add(0,-3.5,0),1.936, (point) -> {
w.spawnParticle(Particle.REDSTONE, point, 1,0,0,0,0, dust);
}, (point, angle) -> {
return angle % 9 == 0;
});
DisplayUtils.ring(p.getEyeLocation().add(0,-4,0),0.9, (point) -> {
w.spawnParticle(Particle.REDSTONE, point, 1,0,0,0,0, dust);
}, (point, angle) -> {
return angle % 9 == 0;
});
}
}
@EventHandler
public void onSwap(PlayerSwapHandItemsEvent e) {
Player p = e.getPlayer();
ItemStack stack = e.getOffHandItem();
if (!p.isOp()) return;
if (ItemUtils.matchDisplay(ItemPresets.ADMIN_UTILITY, stack) && !p.isSneaking()) {
e.setCancelled(true);
p.getWorld().spawn(p.getLocation(), Fireball.class, fireball -> {
fireball.setDirection(p.getLocation().getDirection());
fireball.setVelocity(p.getLocation().getDirection());
fireball.setShooter(p);
});
} else if (ItemUtils.matchDisplay(ItemPresets.ADMIN_UTILITY, stack)) {
e.setCancelled(true);
Vector rot = p.getLocation().getDirection();
Location loc = p.getEyeLocation();
World w = p.getWorld();
Particle.DustOptions dust = new Particle.DustOptions(Color.RED, 10.0F);
Location target = RaycastUtils.raycast(loc, rot, 60, 1, (point) -> {
return !point.getBlock().isPassable();
});
Location skyPoint = RaycastUtils.raycast(target,new Location(target.getWorld(),target.getX(),target.getY() + 50,target.getZ()), (point) -> {
w.spawnParticle(Particle.REDSTONE, point, 1,0,0,0,0, dust);
return false;
});
AtomicReference<Integer> i = new AtomicReference<>(0);
DisplayUtils.ring(skyPoint,30, (point) -> {
point.getWorld().spawn(point,Fireball.class,fireball -> {
Bukkit.getScheduler().runTaskLater(OgreDupeAlias.instance, () -> {
Vector vec = target.toVector().subtract(fireball.getLocation().toVector()).normalize();
double distance = target.distance(point);
fireball.setDirection(vec);
fireball.setVelocity(vec.multiply(5));
fireball.setShooter(p);
}, i.get() * 5);
i.set(i.get() + 1);
});
}, (point, angle) -> {
return angle % 40 == 0;
});
}
}
@EventHandler @EventHandler
public void onClick(PlayerInteractEvent e) { public void onClick(PlayerInteractEvent e) {
try { try {
this.processTable(e); this.processTable(e);
this.handleNetskyBlade(e); this.handleNetskyBlade(e);
this.handleDefender(e);
this.handleAdminUtility(e);
this.handleVoidCharm(e);
this.handleLaserPointer(e);
} }
catch (Exception ignore) {} catch (Exception ignore) {}
} }
private void handleLaserPointer(PlayerInteractEvent e) {
Player p = e.getPlayer();
ItemStack stack = e.getItem();
Action a = e.getAction();
e.setCancelled(true);
if (ItemUtils.matchDisplay(stack, ItemPresets.DEFENDER)) {
switch (a) {
case LEFT_CLICK_BLOCK, LEFT_CLICK_AIR -> {
// Beam here
}
case RIGHT_CLICK_AIR, RIGHT_CLICK_BLOCK -> {
Location start = p.getEyeLocation();
Vector rot = p.getEyeLocation().getDirection();
RaycastUtils.raycast(start,rot,60,1, (point) -> {
return !point.getBlock().isPassable();
});
}
}
}
}
private void processTable(PlayerInteractEvent e) { private void processTable(PlayerInteractEvent e) {
final Player p = e.getPlayer(); final Player p = e.getPlayer();
final Block b = e.getClickedBlock(); final Block b = e.getClickedBlock();
@@ -49,7 +232,268 @@ public class InteractionListener implements Listener {
p.openInventory(InventoryPresets.createCustomTable()); p.openInventory(InventoryPresets.createCustomTable());
} }
} }
private void handleDefender(PlayerInteractEvent e) {
Player p = e.getPlayer();
ItemStack stack = e.getItem();
Action a = e.getAction();
if (ItemUtils.matchDisplay(stack, ItemPresets.DEFENDER)) {
switch (a) {
case LEFT_CLICK_BLOCK, LEFT_CLICK_AIR -> {
Location start = p.getEyeLocation();
Vector rot = p.getLocation().getDirection().normalize();
RaycastUtils.raycast(start, rot, 60, 0.5, (point) -> {
World w = point.getWorld();
if (w == null) return false;
List<Entity> targets = new ArrayList<>(w.getNearbyEntities(point, 0.5, 0.5, 0.5, entity -> {
return entity instanceof LivingEntity living && !living.isDead() && living != p;
}));
// Create stuff here
SoundPlayer hit = new SoundPlayer(start, Sound.BLOCK_STONE_HIT, 0.3F, 2);
Particle.DustOptions dust = new Particle.DustOptions(Color.RED, 0.1F);
// Check for hits
targets.forEach(target -> {
if (target instanceof LivingEntity living) {
// Player hit here
living.damage(3, p);
hit.playWithin(10);
}
});
// Every raytrace
w.spawnParticle(Particle.CRIT, point, 3, 0, 0, 0, 0);
w.spawnParticle(Particle.REDSTONE, point, 1, 0, 0, 0, 0, dust);
return !targets.isEmpty();
});
}
case RIGHT_CLICK_AIR, RIGHT_CLICK_BLOCK -> {
Location start = p.getEyeLocation();
Vector rot = p.getLocation().getDirection().normalize();
RaycastUtils.raycast(start, rot, 12, 0.5, (point) -> {
World w = point.getWorld();
if (w == null) return false;
List<Entity> targets = new ArrayList<>(w.getNearbyEntities(point, 0.5, 0.5, 0.5, entity -> {
return entity instanceof LivingEntity living && !living.isDead() && living != p;
}));
// Create stuff here
SoundPlayer shoot = new SoundPlayer(start, Sound.BLOCK_NOTE_BLOCK_HAT, 0.3F, 2);
SoundPlayer zap = new SoundPlayer(start, Sound.ENTITY_BEE_HURT, 0.3F, 2);
Particle.DustOptions dust = new Particle.DustOptions(Color.AQUA, 1);
// Check for hits
targets.forEach(target -> {
if (target instanceof LivingEntity entity) {
// Player hit here
entity.addPotionEffect(PotionEffectType.SLOW.createEffect(240,9));
entity.addPotionEffect(PotionEffectType.JUMP.createEffect(240,128));
entity.addPotionEffect(PotionEffectType.BLINDNESS.createEffect(120,1));
entity.addPotionEffect(PotionEffectType.WEAKNESS.createEffect(600,60));
entity.damage(1, p);
zap.playWithin(15);
}
});
// Every raytrace
shoot.playWithin(15);
w.spawnParticle(Particle.SCRAPE, point, 1, 0, 0, 0, 0);
w.spawnParticle(Particle.REDSTONE, point, 1, 0, 0, 0, 0, dust);
return !targets.isEmpty();
});
}
}
}
}
private 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 LEFT_CLICK_BLOCK, LEFT_CLICK_AIR -> {
//test
}
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<Entity> targets = new ArrayList<>(w.getNearbyEntities(point, 0.5,0.5,0.5, entity -> {
return entity instanceof LivingEntity living && !living.isDead() && living != p;
}));
// Create stuff here
Particle.DustOptions dust = new Particle.DustOptions(Color.BLACK, 1);
SoundPlayer bellSound = new SoundPlayer(p.getLocation(), Sound.ITEM_TRIDENT_THUNDER, 1,0.4F);
// Check for hits
targets.forEach(target -> {
if (target instanceof LivingEntity living) {
// Player hit here
Location targetLoc = target.getLocation();
Location originalLoc = target.getLocation().add(0,0.1,0);
bellSound.playWithin(10);
int[] counter = {0};
Bukkit.getScheduler().scheduleSyncRepeatingTask(OgreDupeAlias.instance,() -> {
if (counter[0] > 60) return;
target.teleport(targetLoc.subtract(0, 0.05, 0));
w.spawnParticle(Particle.REDSTONE, originalLoc, 50, 0.5, 0, 0.5, 0, dust);
counter[0]++;
},0,1);
}
});
// Every raytrace
w.spawnParticle(Particle.REDSTONE, point, 1,0,0,0,0, dust);
return !targets.isEmpty();
});
}
}
}
}
private void handleAdminUtility(PlayerInteractEvent e) {
Player p = e.getPlayer();
ItemStack stack = e.getItem();
Action a = e.getAction();
if (!p.isOp()) return;
if (ItemUtils.matchDisplay(stack, ItemPresets.ADMIN_UTILITY)) {
switch (a) {
case LEFT_CLICK_BLOCK, LEFT_CLICK_AIR -> {
if (p.isSneaking()) {
Location start = p.getEyeLocation();
Vector rot = p.getLocation().getDirection().normalize();
Location center = p.getLocation();
List<LivingEntity> Hit = new ArrayList<>();
DisplayUtils.ring(center, 10, (point) -> {
RaycastUtils.raycast(center, point.toVector().subtract(center.toVector()).normalize(), 30, 0.3, 1, (location, distance) -> {
for (int i = 0; i < 20; i++) {
World w = point.getWorld();
if (w != null) {
List<Entity> targets = new ArrayList<>(w.getNearbyEntities(location, 0.5,0.5,0.5, entity -> {
return entity instanceof LivingEntity living && !living.isDead() && living != p;
}));
SoundPlayer hissSound = new SoundPlayer(start, Sound.BLOCK_LAVA_EXTINGUISH, 1, 1);
targets.forEach(target -> {
if (target instanceof LivingEntity living) {
living.damage(2, p);
living.setFireTicks(120);
hissSound.playWithin(10);
}
});
w.spawnParticle(Particle.FLAME, location, 1, 0,0,0, 0);
w.spawnParticle(Particle.SMOKE_NORMAL, location, 1, 0,0,0, 0.1);
return !targets.isEmpty() || !location.getBlock().isPassable();
}
}
return false;
}, result -> {
result.getWorld().spawnParticle(Particle.LAVA, result, 20, 0.5, 0.5, 0.5, 0);
});
}, (point, angle) -> {
return angle % 9 == 0;
});
} else {
Location start = p.getEyeLocation();
Vector rot = p.getLocation().getDirection().normalize();
RaycastUtils.raycast(start, rot, 60, 0.5, 1, (point, distance) -> {
for (int i = 0; i < 40; i++) {
World w = point.getWorld();
if (w == null) return false;
List<Entity> targets = new ArrayList<>(w.getNearbyEntities(point, 0.5,0.5,0.5, entity -> {
return entity instanceof LivingEntity living && !living.isDead() && living != p;
}));
SoundPlayer hissSound = new SoundPlayer(start, Sound.BLOCK_LAVA_EXTINGUISH, 1, 1);
targets.forEach(target -> {
if (target instanceof LivingEntity living) {
living.damage(2, p);
living.setFireTicks(120);
hissSound.playWithin(10);
}
});
w.spawnParticle(Particle.FLAME, point, 1, 0,0,0, 0);
w.spawnParticle(Particle.SMOKE_NORMAL, point, 1, 0,0,0, 0.1);
return !targets.isEmpty() || !point.getBlock().isPassable();
}
return false;
}, result -> {
result.getWorld().spawnParticle(Particle.LAVA, result, 20, 0.5, 0.5, 0.5, 0);
});
}
}
case RIGHT_CLICK_AIR, RIGHT_CLICK_BLOCK -> {
if (p.isSneaking()) {
Location start = p.getEyeLocation();
Vector rot = p.getLocation().getDirection().normalize();
RaycastUtils.raycast(start, rot, 60, 0.5, (point) -> {
World w = point.getWorld();
if (w == null) return false;
List<Entity> targets = new ArrayList<>(w.getNearbyEntities(point, 0.5,0.5,0.5, entity -> {
return entity instanceof LivingEntity living && !living.isDead() && living != p;
}));
// Create stuff here
SoundPlayer zap = new SoundPlayer(start, Sound.ENTITY_BEE_HURT, 0.3F, 1);
Particle.DustOptions dust = new Particle.DustOptions(Color.AQUA, 1);
// Check for hits
targets.forEach(target -> {
if (target instanceof LivingEntity living) {
// Player hit here
AtomicReference<Boolean> dead = new AtomicReference<>(false);
Bukkit.getScheduler().scheduleSyncRepeatingTask(OgreDupeAlias.instance, () -> {
if (living != null && !living.isDead() && !dead.get() && living.getHealth() > 0.0F) {
living.damage(1, p);
living.setNoDamageTicks(EntityDamageListener.NO_DAMAGE_TICKS);
living.setMaximumNoDamageTicks(EntityDamageListener.MAX_NO_DAMAGE_TICKS);
} else if (living != null && !dead.get()) {
dead.set(true);
living.setNoDamageTicks(EntityDamageListener.DEFAULT_NO_DAMAGE_TICKS);
living.setMaximumNoDamageTicks(EntityDamageListener.DEFAULT_MAX_NO_DAMAGE_TICKS);
}
},0,1);
}
});
// Every raytrace
zap.playWithin(10);
w.spawnParticle(Particle.END_ROD, point, 1, 0,0,0, 0);
w.spawnParticle(Particle.REDSTONE, point, 1,0,0,0,0, dust);
return !targets.isEmpty();
});
} else {
Player hashed = Bukkit.getPlayer(playerDragMap.get(p.getUniqueId()));
if (hashed == null) {
Location start = p.getEyeLocation();
Vector rot = p.getLocation().getDirection().normalize();
RaycastUtils.raycast(start, rot, 30,1, point -> {
World w = point.getWorld();
List<Entity> targets = new ArrayList<>(w.getNearbyEntities(point, 1,1,1, entity -> {
return entity instanceof Player player && !player.isDead() && player != p;
}));
if (targets.isEmpty()) return false;
Player target = ((Player) targets.get(0));
if (target.getName().equals("obvWolf") || target.getName().equals("ImproperIssues")) {
p.sendMessage(Text.ofAll("§cYou are not allowed to drag: §a" + target.getName()));
return true;
}
target.setAllowFlight(true);
target.setGlowing(true);
target.sendMessage(Text.ofAll("§3You are now being dragged by:§e " + p.getName()));
p.sendMessage(Text.ofAll("§3You are now dragging:§e " + target.getName()));
playerDragMap.put(p.getUniqueId(), targets.get(0).getUniqueId());
return true;
});
}
else {
hashed.setAllowFlight(false);
hashed.setGlowing(false);
hashed.sendMessage(Text.ofAll("§3You are no longer being dragged by:§e " + p.getName()));
p.sendMessage(Text.ofAll("§3You are no longer dragging:§e " + hashed.getName()));
playerDragMap.remove(p.getUniqueId());
}
}
}
}
}
}
private void handleNetskyBlade(PlayerInteractEvent e) { private void handleNetskyBlade(PlayerInteractEvent e) {
Player p = e.getPlayer(); Player p = e.getPlayer();
ItemStack stack = e.getItem(); ItemStack stack = e.getItem();
@@ -60,7 +504,7 @@ public class InteractionListener implements Listener {
switch (a) { switch (a) {
case LEFT_CLICK_BLOCK, LEFT_CLICK_AIR -> { case LEFT_CLICK_BLOCK, LEFT_CLICK_AIR -> {
Location start = p.getEyeLocation(); Location start = p.getEyeLocation();
Vector rotation = p.getLocation().getDirection().normalize(); Vector rotation = p.getEyeLocation().getDirection().normalize();
SoundPlayer shootSound = new SoundPlayer(start, Sound.ENTITY_BLAZE_SHOOT, 1, 1); SoundPlayer shootSound = new SoundPlayer(start, Sound.ENTITY_BLAZE_SHOOT, 1, 1);
shootSound.playWithin(20); shootSound.playWithin(20);
@@ -102,7 +546,7 @@ public class InteractionListener implements Listener {
} }
case RIGHT_CLICK_AIR, RIGHT_CLICK_BLOCK -> { case RIGHT_CLICK_AIR, RIGHT_CLICK_BLOCK -> {
Location start = p.getEyeLocation(); Location start = p.getEyeLocation();
Vector rotation = p.getLocation().getDirection().normalize(); Vector rotation = p.getEyeLocation().getDirection().normalize();
p.getWorld().spawn(start, Fireball.class, fireball -> { p.getWorld().spawn(start, Fireball.class, fireball -> {
fireball.setDirection(rotation); fireball.setDirection(rotation);

View File

@@ -59,4 +59,43 @@ public abstract class ItemPresets {
.lore(Text.color("&7- &dRight: &5Fireball")) .lore(Text.color("&7- &dRight: &5Fireball"))
.enchant(Enchantment.FIRE_ASPECT, 1) .enchant(Enchantment.FIRE_ASPECT, 1)
.build(); .build();
public static ItemStack ADMIN_UTILITY = ItemBuilder.create()
.material(Material.BLAZE_ROD)
.name(Text.color("&4-&c&l[&b&nAdministrative &3&nUtility&c&l]&4-"))
.lore(Text.color("&b▪ &3Right-Click:&7 Drag Player"))
.lore(Text.color("&b▪ &3Sneak Right-Click:&7 Zap Player"))
.lore(Text.color("&b▪ &3Left-Click:&7 Fire Beam"))
.lore(Text.color("&b▪ &3Sneak Left-Click:&7 Ring of Fire"))
.lore(Text.color("&b▪ &3Swap-Hands:&7 Fireball"))
.lore(Text.color("&b▪ &3Sneak Swap-Hands:&7 Orbital Strike"))
.customModelData(1111)
.enchant(Enchantment.VANISHING_CURSE, 1)
.flag(ItemFlag.HIDE_ENCHANTS)
.build();
public static ItemStack VOID_CHARM = ItemBuilder.create()
.material(Material.BLACK_STAINED_GLASS)
.name(Text.color("&0&l-&8&l[&7Void Charm&8&l]&0&l-"))
.lore(Text.color("&7▪ &4Right-Click:&7 Take Entity"))
.customModelData(1111)
.enchant(Enchantment.VANISHING_CURSE, 1)
.flag(ItemFlag.HIDE_ENCHANTS)
.build();
public static ItemStack DEFENDER = ItemBuilder.create()
.material(Material.PRISMARINE_SHARD)
.name(Text.color("&1&l-&9&l[&bDefender&9&l]&1&l-"))
.lore(Text.color("&1▪ &9Right-Click:&7 Stun"))
.lore(Text.color("&1▪ &9Left-Click:&7 Shoot"))
.customModelData(1111)
.enchant(Enchantment.VANISHING_CURSE, 1)
.flag(ItemFlag.HIDE_ENCHANTS)
.build();
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"))
.customModelData(1111)
.enchant(Enchantment.VANISHING_CURSE, 1)
.flag(ItemFlag.HIDE_ENCHANTS)
.build();
} }

View File

@@ -2,6 +2,7 @@ package fun.ogre.ogredupealias.plugin.custom.forging;
import fun.ogre.ogredupealias.plugin.ItemPresets; import fun.ogre.ogredupealias.plugin.ItemPresets;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Item;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.util.HashMap; import java.util.HashMap;
@@ -13,7 +14,11 @@ public abstract class CraftingKeys {
public static void initRecipes() { public static void initRecipes() {
// my custom // my custom
register(ItemPresets.LASER_POINTER, "[polished_blackstone_button{}, lime_concrete{}, lime_stained_glass{}, lime_concrete{}, diamond{}, lime_concrete{}, stick{}, lime_concrete{}, air{}]");
register(ItemPresets.DEFENDER, "[iron_nugget{}, iron_nugget{}, iron_nugget{}, iron_nugget{}, prismarine_shard{}, iron_nugget{}, iron_nugget{}, iron_nugget{}, iron_nugget{}]");
register(ItemPresets.ADMIN_UTILITY, "[air{}, air{}, barrier{}, air{}, blaze_rod{}, air{}, blaze_rod{}, air{}, air{}]");
register(ItemPresets.NETSKY_BLADE, "[end_crystal{}, ender_pearl{}]"); register(ItemPresets.NETSKY_BLADE, "[end_crystal{}, ender_pearl{}]");
register(ItemPresets.VOID_CHARM, "[black_stained_glass{}, black_stained_glass{}, black_stained_glass{}, black_stained_glass{}, barrier{}, black_stained_glass{}, black_stained_glass{}, black_stained_glass{}, black_stained_glass{}]");
//register(ItemPresets.TROLL_SWORD,"[dirt{}]"); //register(ItemPresets.TROLL_SWORD,"[dirt{}]");
register(ItemPresets.SNAD,"[sand{}]"); register(ItemPresets.SNAD,"[sand{}]");
register(ItemPresets.SNAD_COOKIE,"[air{}, sugar{}, air{}, sand{display:{Name:'{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"white\",\"text\":\"Snad\"}],\"text\":\"\"}'}}, cocoa_beans{}, sand{display:{Name:'{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"white\",\"text\":\"Snad\"}],\"text\":\"\"}'}}, air{}, sugar{}, air{}]"); register(ItemPresets.SNAD_COOKIE,"[air{}, sugar{}, air{}, sand{display:{Name:'{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"white\",\"text\":\"Snad\"}],\"text\":\"\"}'}}, cocoa_beans{}, sand{display:{Name:'{\"extra\":[{\"bold\":false,\"italic\":false,\"underlined\":false,\"strikethrough\":false,\"obfuscated\":false,\"color\":\"white\",\"text\":\"Snad\"}],\"text\":\"\"}'}}, air{}, sugar{}, air{}]");

View File

@@ -4,16 +4,49 @@ import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiPredicate;
import java.util.function.Consumer; import java.util.function.Consumer;
import static fun.ogre.ogredupealias.OgreDupeAlias.instance; import static fun.ogre.ogredupealias.OgreDupeAlias.instance;
public final class DisplayUtils { public final class DisplayUtils {
public static void ring(Location center, double radius, Consumer<Location> onPoint) { public static void ring(Location center, double radius, Consumer<Location> onPoint, BiPredicate<Location, Integer> condition) {
for (int i = 0; i <= 360; i ++) { for (int i = 0; i <= 360; i ++) {
Location point = center.clone().add(radius * Math.sin(i), 0, radius * Math.cos(i)); Location point = center.clone().add(radius * Math.sin(i), 0, radius * Math.cos(i));
onPoint.accept(point); if (condition.test(point, i)) {
onPoint.accept(point);
}
}
}
public static void sphere(Location center, double radius, Consumer<Location> onPoint, BiPredicate<Location, Double> condition) {
double radiusSquared = radius * radius;
int minX = (int) Math.floor(center.getX() - radius);
int minY = (int) Math.floor(center.getY() - radius);
int minZ = (int) Math.floor(center.getZ() - radius);
int maxX = (int) Math.ceil(center.getX() + radius);
int maxY = (int) Math.ceil(center.getY() + radius);
int maxZ = (int) Math.ceil(center.getZ() + radius);
for (int x = minX; x <= maxX; x++) {
double xSquared = (x - center.getX()) * (x - center.getX());
for (int y = minY; y <= maxY; y++) {
double ySquared = (y - center.getY()) * (y - center.getY());
for (int z = minZ; z <= maxZ; z++) {
double zSquared = (z - center.getZ()) * (z - center.getZ());
if (xSquared + ySquared + zSquared <= radiusSquared) {
Location point = new Location(center.getWorld(), x, y, z);
double distance = center.distance(point);
if (condition.test(point, distance)) {
onPoint.accept(point);
}
}
}
}
} }
} }
@@ -22,7 +55,7 @@ public final class DisplayUtils {
Bukkit.getScheduler().scheduleSyncRepeatingTask(instance, () -> { Bukkit.getScheduler().scheduleSyncRepeatingTask(instance, () -> {
if (currentRadius.get() <= radius) { if (currentRadius.get() <= radius) {
ring(center, currentRadius.get(), onPoint); ring(center, currentRadius.get(), onPoint, (point, angle) -> true);
currentRadius.set(currentRadius.get() + frequency); currentRadius.set(currentRadius.get() + frequency);
} }
}, 0, interval); }, 0, interval);

View File

@@ -114,4 +114,10 @@ commands:
permission: oda.commands.attackcooldown permission: oda.commands.attackcooldown
aliases: aliases:
- atkcool - atkcool
- attackcool - attackcool
forcefield:
description: Draws an impassible forcefield around you
usage: /forcefield
permission: oda.commands.forcefield
aliases:
- /ff