Added a lot, and optimized some stuff, (Adminutility dragplayer is broken, i couldnt fix it)
This commit is contained in:
@@ -4,6 +4,7 @@ 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.PotatoCannon;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -42,6 +43,9 @@ public final class OgreDupeAlias extends JavaPlugin {
|
||||
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);
|
||||
|
||||
// Commands
|
||||
getCommand("forcefield").setExecutor(new ForceFieldCommand());
|
||||
|
||||
@@ -1,28 +1,139 @@
|
||||
package fun.ogre.ogredupealias.commands.commands;
|
||||
|
||||
import fun.ogre.ogredupealias.OgreDupeAlias;
|
||||
import fun.ogre.ogredupealias.commands.CmdExHandler;
|
||||
import fun.ogre.ogredupealias.events.EntityDamageListener;
|
||||
import fun.ogre.ogredupealias.events.InteractionListener;
|
||||
import fun.ogre.ogredupealias.plugin.RecipientList;
|
||||
import fun.ogre.ogredupealias.utils.DisplayUtils;
|
||||
import fun.ogre.ogredupealias.utils.SoundPlayer;
|
||||
import fun.ogre.ogredupealias.utils.Text;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ForceFieldCommand implements TabExecutor {
|
||||
|
||||
public static final RecipientList forceFieldProtected = new RecipientList();
|
||||
@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);
|
||||
|
||||
boolean isRecipient = forceFieldProtected.isRecipient(p);
|
||||
if (isRecipient) forceFieldProtected.removeRecipient(p);
|
||||
else forceFieldProtected.addRecipient(p);
|
||||
isRecipient = forceFieldProtected.isRecipient(p);
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(OgreDupeAlias.instance, () -> {
|
||||
if (forceFieldProtected.isRecipient(p)) {
|
||||
World w = p.getWorld();
|
||||
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;
|
||||
});
|
||||
}
|
||||
}, 0,2);
|
||||
sender.sendMessage(Text.builder()
|
||||
.message("&7[&bForceField&7] &8>> &3You are " + (isRecipient ? "&anow" : "&cno longer") + " &3a protected.")
|
||||
.prefix()
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package fun.ogre.ogredupealias.commands.commands;
|
||||
|
||||
import fun.ogre.ogredupealias.commands.CmdExHandler;
|
||||
import fun.ogre.ogredupealias.commands.TabComplBuilder;
|
||||
import fun.ogre.ogredupealias.plugin.ItemPresets;
|
||||
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.List;
|
||||
|
||||
public class GiveCustomCommand implements TabExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
try {
|
||||
Player p = (Player) sender;
|
||||
|
||||
if (args.length == 0) {
|
||||
p.sendMessage(Text.builder("&cYou must specify an item to give.").prefix().color().build());
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args[0]) {
|
||||
case "AdminUtility" -> {
|
||||
p.getInventory().addItem(ItemPresets.ADMIN_UTILITY);
|
||||
p.sendMessage(Text.ofAll("&bGiven you an Admin Utility"));
|
||||
}
|
||||
case "AK47" -> {
|
||||
p.getInventory().addItem(ItemPresets.AK47);
|
||||
p.sendMessage(Text.ofAll("&bGiven you an AK-47"));
|
||||
}
|
||||
case "Defender" -> {
|
||||
p.getInventory().addItem(ItemPresets.DEFENDER);
|
||||
p.sendMessage(Text.ofAll("&bGiven you a Defender"));
|
||||
}
|
||||
case "NetSkyBlade" -> {
|
||||
p.getInventory().addItem(ItemPresets.NETSKY_BLADE);
|
||||
p.sendMessage(Text.ofAll("&bGiven you a Netsky Blade"));
|
||||
}
|
||||
case "SnowChinegun" -> {
|
||||
p.getInventory().addItem(ItemPresets.SNOWCHINEGUN);
|
||||
p.sendMessage(Text.ofAll("&bGiven you an SnowChinegun"));
|
||||
}
|
||||
case "VoidCharm" -> {
|
||||
p.getInventory().addItem(ItemPresets.VOID_CHARM);
|
||||
p.sendMessage(Text.ofAll("&bGiven you a Void Charm"));
|
||||
}
|
||||
case "Spleefer" -> {
|
||||
p.getInventory().addItem(ItemPresets.SPLEEFER);
|
||||
p.sendMessage(Text.ofAll("&bGiven you a Spleefer"));
|
||||
}
|
||||
}
|
||||
}
|
||||
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 TabComplBuilder(sender, command, alias, args)
|
||||
.add(1, new String[] {
|
||||
"AdminUtility",
|
||||
"AK47",
|
||||
"Defender",
|
||||
"NetSkyBlade",
|
||||
"SnowChinegun",
|
||||
"VoidCharm",
|
||||
"Spleefer"
|
||||
})
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import fun.ogre.ogredupealias.data.PlacedStructures;
|
||||
import fun.ogre.ogredupealias.plugin.InventoryPresets;
|
||||
import fun.ogre.ogredupealias.plugin.ItemPresets;
|
||||
import fun.ogre.ogredupealias.plugin.RecipientList;
|
||||
import fun.ogre.ogredupealias.plugin.funitems.*;
|
||||
import fun.ogre.ogredupealias.utils.*;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -20,209 +21,29 @@ import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.beans.MethodDescriptor;
|
||||
import java.beans.beancontext.BeanContext;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
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<>();
|
||||
@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
|
||||
public void onClick(PlayerInteractEvent e) {
|
||||
try {
|
||||
this.processTable(e);
|
||||
this.handleNetskyBlade(e);
|
||||
this.handleDefender(e);
|
||||
this.handleAdminUtility(e);
|
||||
this.handleVoidCharm(e);
|
||||
this.handleLaserPointer(e);
|
||||
NetSkyBlade.handleNetskyBlade(e);
|
||||
Defender.handleDefender(e);
|
||||
AdminUtility.handleAdminUtility(e);
|
||||
VoidCharm.handleVoidCharm(e);
|
||||
SnowChinegun.handleSnowChinegun(e);
|
||||
AK47.handleAK47(e);
|
||||
PotatoCannon.handlePotatoCannon(e);
|
||||
}
|
||||
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) {
|
||||
final Player p = e.getPlayer();
|
||||
final Block b = e.getClickedBlock();
|
||||
@@ -232,329 +53,4 @@ public class InteractionListener implements Listener {
|
||||
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) {
|
||||
Player p = e.getPlayer();
|
||||
ItemStack stack = e.getItem();
|
||||
Action a = e.getAction();
|
||||
|
||||
if (ItemUtils.matchDisplay(stack, ItemPresets.NETSKY_BLADE) && !netskySwordCooldown.isOnCooldown(p.getUniqueId())) {
|
||||
netskySwordCooldown.setCooldown(p.getUniqueId(), 333);
|
||||
switch (a) {
|
||||
case LEFT_CLICK_BLOCK, LEFT_CLICK_AIR -> {
|
||||
Location start = p.getEyeLocation();
|
||||
Vector rotation = p.getEyeLocation().getDirection().normalize();
|
||||
SoundPlayer shootSound = new SoundPlayer(start, Sound.ENTITY_BLAZE_SHOOT, 1, 1);
|
||||
|
||||
shootSound.playWithin(20);
|
||||
|
||||
RaycastUtils.raycast(start, rotation, 30, 0.5, 1, (point, distance) -> {
|
||||
if (point == null || point.getWorld() == null) return false;
|
||||
|
||||
World w = point.getWorld();
|
||||
SoundPlayer popSound = new SoundPlayer(start, Sound.BLOCK_LAVA_POP, 1, 1);
|
||||
SoundPlayer hissSound = new SoundPlayer(start, Sound.BLOCK_LAVA_EXTINGUISH, 1, 1);
|
||||
|
||||
w.spawnParticle(Particle.FLAME, point, 1, 0, 0, 0, 0);
|
||||
w.spawnParticle(Particle.LAVA, point, 1, 0, 0, 0, 0);
|
||||
popSound.playWithin(3);
|
||||
|
||||
List<Entity> targets = new ArrayList<>(w.getNearbyEntities(point, 2, 2, 2, entity -> {
|
||||
return entity instanceof LivingEntity living && !living.isDead() && living != p;
|
||||
}));
|
||||
|
||||
targets.forEach(target -> {
|
||||
if (target instanceof LivingEntity living) {
|
||||
living.damage(5.0, p);
|
||||
living.setFireTicks(60);
|
||||
hissSound.playWithin(20);
|
||||
}
|
||||
});
|
||||
|
||||
return !targets.isEmpty() || !point.getBlock().isPassable();
|
||||
}, result -> {
|
||||
if (result == null || result.getWorld() == null) return;
|
||||
|
||||
World w = result.getWorld();
|
||||
SoundPlayer explodeSound = new SoundPlayer(result, Sound.ENTITY_GENERIC_EXPLODE, 3, 1.5F);
|
||||
|
||||
explodeSound.playWithin(500);
|
||||
w.spawnParticle(Particle.CAMPFIRE_COSY_SMOKE, result, 20, 0, 0, 0, 0.1);
|
||||
w.spawnParticle(Particle.LAVA, result, 120, 0, 0, 0, 1);
|
||||
});
|
||||
}
|
||||
case RIGHT_CLICK_AIR, RIGHT_CLICK_BLOCK -> {
|
||||
Location start = p.getEyeLocation();
|
||||
Vector rotation = p.getEyeLocation().getDirection().normalize();
|
||||
|
||||
p.getWorld().spawn(start, Fireball.class, fireball -> {
|
||||
fireball.setDirection(rotation);
|
||||
fireball.setVelocity(rotation);
|
||||
fireball.setShooter(p);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,20 @@ import fun.ogre.ogredupealias.data.Config;
|
||||
import fun.ogre.ogredupealias.utils.ItemUtils;
|
||||
import fun.ogre.ogredupealias.plugin.ItemPresets;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Item;
|
||||
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.PlayerItemConsumeEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import static org.bukkit.event.block.Action.RIGHT_CLICK_AIR;
|
||||
import static org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK;
|
||||
|
||||
public class PlayerEventListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
@@ -37,6 +43,20 @@ public class PlayerEventListener implements Listener {
|
||||
catch (Exception ignore) {}
|
||||
}
|
||||
|
||||
private void handleEnderPearls(PlayerInteractEvent e) {
|
||||
ItemStack item = e.getItem();
|
||||
Player p = e.getPlayer();
|
||||
Action a = e.getAction();
|
||||
switch (a) {
|
||||
case RIGHT_CLICK_BLOCK, RIGHT_CLICK_AIR -> {
|
||||
if (item.getType() == Material.ENDER_PEARL) {
|
||||
if (e.isCancelled()) return;
|
||||
p.setCooldown(Material.ENDER_PEARL, 30 * 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleFood(PlayerItemConsumeEvent e) {
|
||||
final ItemStack item = e.getItem();
|
||||
final Player p = e.getPlayer();
|
||||
@@ -48,5 +68,6 @@ public class PlayerEventListener implements Listener {
|
||||
if (e.isCancelled()) return;
|
||||
p.setCooldown(Material.ENCHANTED_GOLDEN_APPLE, 30 * 20);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
package fun.ogre.ogredupealias.events;
|
||||
|
||||
import fun.ogre.ogredupealias.utils.SoundPlayer;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.Snowball;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
|
||||
public class PotatoHitListener {
|
||||
@EventHandler
|
||||
public void onProjectileHit(ProjectileHitEvent e) {
|
||||
Projectile proj = e.getEntity();
|
||||
if (proj.getType() == EntityType.SNOWBALL && proj.getShooter() instanceof Player) {
|
||||
Snowball snowball = (Snowball) proj;
|
||||
if (snowball.getItem().getType() == Material.POTATO) {
|
||||
if (e.getHitEntity() instanceof Player) {
|
||||
Player victim = (Player) e.getHitEntity();
|
||||
Player shooter = (Player) snowball.getShooter();
|
||||
victim.damage(1, shooter);
|
||||
SoundPlayer splatSound = new SoundPlayer(victim.getLocation(), Sound.ITEM_GLOW_INK_SAC_USE,1,1);
|
||||
splatSound.playWithin(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package fun.ogre.ogredupealias.events;
|
||||
|
||||
import fun.ogre.ogredupealias.OgreDupeAlias;
|
||||
import fun.ogre.ogredupealias.data.Config;
|
||||
import fun.ogre.ogredupealias.plugin.ItemPresets;
|
||||
import fun.ogre.ogredupealias.utils.ItemUtils;
|
||||
import fun.ogre.ogredupealias.utils.Text;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class SnowBallListener implements Listener {
|
||||
private ItemStack snowStack = new ItemStack(Material.SNOWBALL, 4);
|
||||
@EventHandler
|
||||
public void onProjectileHitPLayer(ProjectileHitEvent e) {
|
||||
if (e.getEntity() instanceof Snowball) {
|
||||
if (e.getHitEntity() instanceof Player) {
|
||||
if (e.getEntity().getShooter() instanceof Player) {
|
||||
Player shooter = (Player) e.getEntity().getShooter();
|
||||
Player victim = (Player) e.getHitEntity();
|
||||
double health = victim.getHealth();
|
||||
victim.damage(1, shooter);
|
||||
Bukkit.getScheduler().runTaskLater(OgreDupeAlias.instance,() -> {
|
||||
victim.setHealth(health);
|
||||
},1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void onBreakSnow(BlockBreakEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
ItemStack itemInHand = p.getItemInHand();
|
||||
if (itemInHand != null) {
|
||||
if (e.getBlock().getType() == Material.SNOW_BLOCK) {
|
||||
final ItemStack stack = p.getItemInHand();
|
||||
if (ItemUtils.matchDisplay(stack, ItemPresets.SPLEEFER)) {
|
||||
e.setCancelled(true);
|
||||
e.getBlock().setType(Material.AIR);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
e.getPlayer().getInventory().addItem(snowStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onProjectileHitBlock(ProjectileHitEvent e) {
|
||||
if (e.getHitBlock() == null) return;
|
||||
if (e.getEntity() == null) return;
|
||||
Location hit = Objects.requireNonNull(e.getHitBlock()).getLocation();
|
||||
World world = hit.getWorld();
|
||||
if (e.getEntity().getShooter() instanceof Player) {
|
||||
Player shooter = (Player) e.getEntity().getShooter();
|
||||
if (e.getEntity() instanceof Snowball) {
|
||||
if (e.getHitBlock().getType() == Material.SNOW_BLOCK) {
|
||||
hit.getBlock().setType(Material.AIR);
|
||||
shooter.getInventory().addItem(snowStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
package fun.ogre.ogredupealias.events;
|
||||
|
||||
import fun.ogre.ogredupealias.utils.RaycastUtils;
|
||||
import fun.ogre.ogredupealias.utils.ServerUtils;
|
||||
import fun.ogre.ogredupealias.utils.SoundPlayer;
|
||||
import fun.ogre.ogredupealias.utils.Text;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
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 antiTurfWalk(PlayerMoveEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if (ServerUtils.hasTag(p,"TWplayer") && ServerUtils.hasTag(p,"TWat")) {
|
||||
if (ServerUtils.hasTag(p,"TWred")) {
|
||||
if (hasBlockBelow(p, Material.LIGHT_BLUE_TERRACOTTA)) {
|
||||
p.setVelocity(new Vector(0, 0.75, -0.5)); // Adjust the velocity values as needed
|
||||
}
|
||||
} else if (ServerUtils.hasTag(p,"TWblue")) {
|
||||
if (hasBlockBelow(p, Material.RED_TERRACOTTA)) {
|
||||
p.setVelocity(new Vector(0, 0.25, 0.5)); // Adjust the velocity values as needed
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onAOELand(ProjectileHitEvent e) {
|
||||
Entity ent = e.getEntity();
|
||||
if (e.getEntity().getShooter() instanceof Player shooter) {
|
||||
if (ServerUtils.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(),3D,4);
|
||||
}
|
||||
if (e.getHitBlock() != null) {
|
||||
explodeOnLand(shooter,e.getHitBlock().getLocation(),3D,2);
|
||||
}
|
||||
}
|
||||
if (e.getHitEntity() != null && e.getHitEntity() instanceof Player) {
|
||||
explodeOnLand(shooter,e.getHitEntity().getLocation(),1.5,3);
|
||||
}
|
||||
if (e.getHitBlock() != null) {
|
||||
explodeOnLand(shooter,e.getHitBlock().getLocation(),1.5,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onBlockHit(ProjectileHitEvent e) {
|
||||
if (e.getEntity().getShooter() instanceof Player shooter) {
|
||||
if (ServerUtils.hasTag(shooter, "TWplayer")) {
|
||||
if (e.getHitBlock() == null) return;;
|
||||
Block block = e.getHitBlock();
|
||||
if (e.getHitBlock().getType() == Material.BLUE_WOOL || block.getType() == Material.RED_WOOL) {
|
||||
e.getEntity().remove();
|
||||
twBreak(block);
|
||||
} else if (e.getHitBlock().getType() == Material.BLUE_CONCRETE || block.getType() == Material.RED_CONCRETE) {
|
||||
if (ServerUtils.hasTag(shooter,"TWbomber") || ServerUtils.hasTag(shooter,"TWshredder")) return;
|
||||
e.getEntity().remove();
|
||||
twBreak(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void antiSpawnKill(PlayerMoveEvent e) {
|
||||
if (ServerUtils.hasTag(e.getPlayer(),"TWsk")) {
|
||||
e.getPlayer().sendMessage(Text.color("&9Game> &c&lYou are not allowed to enter the other team's spawn! &7You have been killed!"));
|
||||
ServerUtils.safeKill(e.getPlayer());
|
||||
ServerUtils.removeTag(e.getPlayer(),"TWsk");
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
private void onShotgunShoot(EntityShootBowEvent e) {
|
||||
if (e.getEntity() instanceof Player p) {
|
||||
if (!ServerUtils.hasTag(p,"TWshredder")) return;
|
||||
if (p.getUniqueId().toString().equals("049460f7-21cb-42f5-8059-d42752bf406f")) {
|
||||
shredderShot(p,4,7D);
|
||||
}
|
||||
shredderShot(p,10,5D);
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
private void onSnipePlayer(ProjectileHitEvent e) {
|
||||
e.getEntity().remove();
|
||||
if (e.getHitEntity() instanceof Player victim && e.getEntity().getShooter() instanceof Player shooter) {
|
||||
if (ServerUtils.hasSameTag(shooter,victim,"TWblue")) return;
|
||||
if (ServerUtils.hasSameTag(shooter,victim,"TWred")) return;
|
||||
if (victim == shooter) return;
|
||||
SoundPlayer hitSound = new SoundPlayer(shooter.getLocation(),Sound.BLOCK_NOTE_BLOCK_BELL,10,2);
|
||||
if (e.getEntity() instanceof Arrow ent) {
|
||||
if (!ServerUtils.hasTag(victim,"TWplayer")) return;
|
||||
if (ServerUtils.hasTag(shooter,"TWplayer") && !ServerUtils.hasTag(shooter,"TWshredder")) {
|
||||
ServerUtils.safeKill(victim);
|
||||
ent.remove();
|
||||
victim.sendMessage(Text.color("&9Game> &7You have been sniped by &e" + shooter.getName() + "&7."));
|
||||
shooter.sendMessage(Text.color("&9Game> &7You sniped &e" + victim.getName() + "&7."));
|
||||
hitSound.play(shooter);
|
||||
} else if (ServerUtils.hasTag(shooter,"TWshredder")) {
|
||||
ServerUtils.safeKill(victim);
|
||||
victim.sendMessage(Text.color("&9Game> &7You have been blundered by &e" + shooter.getName() + "&7."));
|
||||
shooter.sendMessage(Text.color("&9Game> &7You blundered &e" + victim.getName() + "&7."));
|
||||
hitSound.play(shooter);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
private void onInfiltratorHit(EntityDamageByEntityEvent e) {
|
||||
if (e.getDamager() instanceof Player attacker && e.getEntity() instanceof Player victim) {
|
||||
if (ServerUtils.hasSameTag(attacker,victim,"TWblue")) return;
|
||||
if (ServerUtils.hasSameTag(attacker,victim,"TWred")) return;
|
||||
if (ServerUtils.hasTag(attacker, "TWinfiltrator") && ServerUtils.hasTag(victim, "TWplayer")) {
|
||||
ServerUtils.safeKill(victim);
|
||||
victim.sendMessage(Text.color("&9Game> &7You have been stabbed by &e" + attacker.getName() + "&7."));
|
||||
attacker.sendMessage(Text.color("&9Game> &7You stabbed &e" + victim.getName() + "&7."));
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
private void onInfiltratorKill(EntityDamageByEntityEvent e) {
|
||||
if (e.getDamager() instanceof Player attacker && e.getEntity() instanceof Player victim) {
|
||||
if (ServerUtils.hasSameTag(attacker,victim,"TWblue")) return;
|
||||
if (ServerUtils.hasSameTag(attacker,victim,"TWred")) return;
|
||||
if (ServerUtils.hasTag(victim, "TWinfiltrator") && ServerUtils.hasTag(attacker, "TWplayer")) {
|
||||
ServerUtils.safeKill(victim);
|
||||
victim.sendMessage(Text.color("&9Game> &7You have been stabbed by &e" + attacker.getName() + "&7."));
|
||||
attacker.sendMessage(Text.color("&9Game> &7You stabbed &e" + victim.getName() + "&7."));
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
private void onRespawn(PlayerRespawnEvent e) {
|
||||
if (ServerUtils.hasTag(e.getPlayer(),"TWplayer")) {
|
||||
ServerUtils.removeTag(e.getPlayer(),"oneshot");
|
||||
e.getPlayer().sendMessage(Text.color("&9Game> &7Respawned!"));
|
||||
}
|
||||
}
|
||||
|
||||
public void explodeWool(Location hitLoc, int radius) {
|
||||
World world = hitLoc.getWorld();
|
||||
int x = hitLoc.getBlockX();
|
||||
int y = hitLoc.getBlockY();
|
||||
int z = hitLoc.getBlockZ();
|
||||
for (int dx = -radius; dx <= radius; dx++) {
|
||||
for (int dy = -radius; dy <= radius; dy++) {
|
||||
for (int dz = -radius; dz <= radius; dz++) {
|
||||
Block block = world.getBlockAt(x + dx, y + dy, z + dz);
|
||||
if (block.getType() == Material.RED_WOOL || block.getType() == Material.BLUE_WOOL) {
|
||||
SoundPlayer breakSound = new SoundPlayer(block.getLocation(), Sound.BLOCK_WOOL_BREAK,0.5F,1);
|
||||
block.setType(Material.AIR);
|
||||
breakSound.playWithin(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void explodePlayers(Player attacker, Location hitLoc, Double radius) {
|
||||
List<LivingEntity> Hit = new ArrayList<>();
|
||||
List<Entity> targets = new ArrayList<>(hitLoc.getWorld().getNearbyEntities(hitLoc, radius,radius,radius, entity -> {
|
||||
return entity instanceof Player victim1 && !victim1.isDead() && victim1 != attacker;
|
||||
}));
|
||||
targets.forEach(target -> {
|
||||
if (target instanceof Player victim2) {
|
||||
if (ServerUtils.hasSameTag(attacker,victim2,"TWblue")) return;
|
||||
if (ServerUtils.hasSameTag(attacker,victim2,"TWred")) return;
|
||||
ServerUtils.safeKill(victim2);
|
||||
victim2.sendMessage(Text.color("&9Game>&7 You got 'sploded by &e" + attacker.getName() + "&7!"));
|
||||
attacker.sendMessage(Text.color("&9Game>&7 You 'sploded &e" + victim2.getName() + "&7!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
public void explodeOnLand(Player shooter, Location hitLoc, Double killRadius, Integer destroyRadius) {
|
||||
explodeWool(hitLoc, destroyRadius);
|
||||
explodePlayers(shooter, hitLoc, killRadius);
|
||||
hitLoc.getWorld().spawnParticle(Particle.EXPLOSION_HUGE, hitLoc,3);
|
||||
SoundPlayer explodeSound = new SoundPlayer(hitLoc, Sound.ENTITY_GENERIC_EXPLODE,10,1);
|
||||
explodeSound.playWithin(30);
|
||||
}
|
||||
public void shredderShot(Player shooter, Integer amount, Double angle) {
|
||||
for (int i = 0; i < amount; i++) {
|
||||
Vector vec = RaycastUtils.randomVector(shooter.getLocation().getDirection(), angle);
|
||||
Arrow arrow = shooter.launchProjectile(Arrow.class);
|
||||
arrow.setShooter(shooter);
|
||||
arrow.setVelocity(vec.multiply(2.5));
|
||||
}
|
||||
}
|
||||
public void twBreak(Block block) {
|
||||
Location loc = block.getLocation();
|
||||
BlockData fallingDustData = block.getType().createBlockData();
|
||||
block.setType(Material.AIR);
|
||||
block.getWorld().spawnParticle(Particle.BLOCK_DUST,loc.add(0.5D,0.5D,0.5D), 30, 0.5,0.5,0.5, fallingDustData);
|
||||
SoundPlayer breakSound = new SoundPlayer(loc,Sound.BLOCK_WOOL_BREAK,10,1);
|
||||
breakSound.playWithin(20);
|
||||
}
|
||||
}
|
||||
@@ -98,4 +98,47 @@ public abstract class ItemPresets {
|
||||
.enchant(Enchantment.VANISHING_CURSE, 1)
|
||||
.flag(ItemFlag.HIDE_ENCHANTS)
|
||||
.build();
|
||||
public static ItemStack SHIELD_GEN = ItemBuilder.create()
|
||||
.material(Material.BEACON)
|
||||
.name(Text.color("&5&l-&d&l[&bShield Generator&d&l]&5&l-"))
|
||||
.lore(Text.color("&1▪ &9/hat:&7 Personal Shield"))
|
||||
.lore(Text.color("&1▪ &9Place:&7 Stationary Shield"))
|
||||
.build();
|
||||
public static ItemStack SNOWCHINEGUN = ItemBuilder.create()
|
||||
.material(Material.IRON_HOE)
|
||||
.name(Text.color("&f&l&nSNOWCHINEGUN"))
|
||||
.lore(Text.color("&b▪ &fRight-Click:&7 BRRRRTTTTT"))
|
||||
.lore(Text.color("&b▪ &fLeft-Click:&7 Burst"))
|
||||
.customModelData(1111)
|
||||
.enchant(Enchantment.VANISHING_CURSE, 1)
|
||||
.flag(ItemFlag.HIDE_ENCHANTS)
|
||||
.build();
|
||||
public static ItemStack AK47 = ItemBuilder.create()
|
||||
.material(Material.ECHO_SHARD)
|
||||
.name(Text.color("&7&lAK&8-&647"))
|
||||
.lore(Text.color("&6▪ &fRight-Click:&7 Full Auto"))
|
||||
.lore(Text.color("&6▪ &fLeft-Click:&7 Single Shot"))
|
||||
.customModelData(1111)
|
||||
.enchant(Enchantment.VANISHING_CURSE, 1)
|
||||
.flag(ItemFlag.HIDE_ENCHANTS)
|
||||
.build();
|
||||
public static ItemStack SPLEEFER = ItemBuilder.create()
|
||||
.material(Material.NETHERITE_SHOVEL)
|
||||
.name(Text.color("&2&lSpleefer"))
|
||||
.lore(Text.color("&7For use at /warp spleef"))
|
||||
.enchant(Enchantment.DIG_SPEED, 5)
|
||||
.unbreakable(true)
|
||||
.flag(ItemFlag.HIDE_ENCHANTS)
|
||||
.flag(ItemFlag.HIDE_UNBREAKABLE)
|
||||
.build();
|
||||
public static ItemStack POTATOCANNON = ItemBuilder.create()
|
||||
.material(Material.GOLDEN_HOE)
|
||||
.name(Text.color("&6&lPotato Cannon"))
|
||||
.lore(Text.color("&e▪ &fLeft-Click:&7 Launch Potatoes"))
|
||||
.lore(Text.color("&e▪ &fRight-Click:&7 Load Potato (Max 6)"))
|
||||
.unbreakable(true)
|
||||
.enchant(Enchantment.DIG_SPEED, 5)
|
||||
.flag(ItemFlag.HIDE_ENCHANTS)
|
||||
.flag(ItemFlag.HIDE_UNBREAKABLE)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -14,10 +14,14 @@ public abstract class CraftingKeys {
|
||||
|
||||
public static void initRecipes() {
|
||||
// my custom
|
||||
register(ItemPresets.POTATOCANNON, "[potato{}, potato{}, potato{}, potato{}, golden_hoe{}, potato{}, potato{}, potato{}, potato{}]");
|
||||
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.SNOWCHINEGUN, "[snowball{}, snowball{}, snowball{}, snowball{}, iron_shovel{}, snowball{}, snowball{}, snowball{}, snowball{}]");
|
||||
register(ItemPresets.SPLEEFER, "[snowball{}, snowball{}, snowball{}, snowball{}, netherite_shovel{}, snowball{}, snowball{}, snowball{}, snowball{}]");
|
||||
register(ItemPresets.AK47, "[iron_nugget{}, iron_nugget{}, iron_nugget{}, iron_nugget{}, echo_shard{}, iron_nugget{}, iron_nugget{}, iron_nugget{}, iron_nugget{}]");
|
||||
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.SNAD,"[sand{}]");
|
||||
|
||||
129
src/main/java/fun/ogre/ogredupealias/plugin/funitems/AK47.java
Normal file
129
src/main/java/fun/ogre/ogredupealias/plugin/funitems/AK47.java
Normal file
@@ -0,0 +1,129 @@
|
||||
package fun.ogre.ogredupealias.plugin.funitems;
|
||||
|
||||
import fun.ogre.ogredupealias.OgreDupeAlias;
|
||||
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 org.bukkit.*;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.type.Bed;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Snowball;
|
||||
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.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AK47 {
|
||||
public static void handleAK47(PlayerInteractEvent e){
|
||||
Player p = e.getPlayer();
|
||||
ItemStack stack = e.getItem();
|
||||
Action a = e.getAction();
|
||||
Location start = p.getEyeLocation();
|
||||
Vector rot = p.getLocation().getDirection().normalize();
|
||||
World w = p.getWorld();
|
||||
if (!ItemUtils.matchDisplay(stack, ItemPresets.AK47)) return;
|
||||
e.setCancelled(true);
|
||||
switch (a) {
|
||||
case RIGHT_CLICK_AIR, RIGHT_CLICK_BLOCK -> {
|
||||
// Full auto
|
||||
int[] counter = {0};
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(OgreDupeAlias.instance,() -> {
|
||||
if (counter[0] > 3) return;
|
||||
counter[0]++;
|
||||
SoundPlayer shootSound = new SoundPlayer(p.getLocation(), Sound.BLOCK_PISTON_CONTRACT,10,1);
|
||||
shootSound.playWithin(30);
|
||||
Location realStart = p.getEyeLocation();
|
||||
Vector realRot = p.getLocation().getDirection().normalize();
|
||||
RaycastUtils.raycast(realStart,realRot,30,(point) -> {
|
||||
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;
|
||||
}));
|
||||
targets.forEach(target -> {
|
||||
if (target instanceof LivingEntity) {
|
||||
BlockData blockData = Material.RED_WOOL.createBlockData();
|
||||
SoundPlayer hitSound = new SoundPlayer(target.getLocation(), Sound.ITEM_DYE_USE,3,2);
|
||||
((LivingEntity) target).damage(10,p);
|
||||
hitSound.playWithin(20);
|
||||
w.spawnParticle(Particle.BLOCK_DUST,target.getLocation().add(0,1,0),30,0.25F,1,0.25F,blockData);
|
||||
}
|
||||
});
|
||||
w.spawnParticle(Particle.CRIT, point, 1, 0,0,0, 0);
|
||||
w.spawnParticle(Particle.SMOKE_NORMAL, point, 1, 0,0,0, 0.1F);
|
||||
return !targets.isEmpty() || !point.getBlock().isPassable();
|
||||
});
|
||||
},0,2);
|
||||
}
|
||||
case LEFT_CLICK_AIR, LEFT_CLICK_BLOCK -> {
|
||||
// Single shot
|
||||
SoundPlayer shootSound = new SoundPlayer(p.getLocation(), Sound.BLOCK_PISTON_CONTRACT,10,1);
|
||||
shootSound.playWithin(60);
|
||||
RaycastUtils.raycast(start,rot,30,(point) -> {
|
||||
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;
|
||||
}));
|
||||
targets.forEach(target -> {
|
||||
if (target instanceof LivingEntity) {
|
||||
BlockData blockData = Material.RED_WOOL.createBlockData();
|
||||
SoundPlayer hitSound = new SoundPlayer(target.getLocation(), Sound.ITEM_DYE_USE,3,2);
|
||||
((LivingEntity) target).damage(10,p);
|
||||
hitSound.playWithin(20);
|
||||
w.spawnParticle(Particle.BLOCK_DUST,target.getLocation().add(0,1,0),30,0.25F,1,0.25F,blockData);
|
||||
}
|
||||
});
|
||||
w.spawnParticle(Particle.CRIT, point, 1, 0,0,0, 0);
|
||||
w.spawnParticle(Particle.SMOKE_NORMAL, point, 1, 0,0,0, 0.1);
|
||||
return !targets.isEmpty() || !point.getBlock().isPassable();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
DO NOT GET WORLD FOR A RESULT UNLESS YOU WANT YOUR CONSOLE TO SPIT THIS OUT EVERY PICOSECOND
|
||||
|
||||
[16:34:12 WARN]: [ODA] Task #994 for OgreDupeAlias v2.0.0 generated an exception
|
||||
java.lang.IllegalArgumentException: data should be interface org.bukkit.block.data.BlockData got class org.bukkit.Material
|
||||
at org.bukkit.craftbukkit.v1_19_R3.CraftWorld.spawnParticle(CraftWorld.java:2077) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at org.bukkit.craftbukkit.v1_19_R3.CraftWorld.spawnParticle(CraftWorld.java:2072) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at org.bukkit.craftbukkit.v1_19_R3.CraftWorld.spawnParticle(CraftWorld.java:2061) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at org.bukkit.craftbukkit.v1_19_R3.CraftWorld.spawnParticle(CraftWorld.java:2041) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at org.bukkit.craftbukkit.v1_19_R3.CraftWorld.spawnParticle(CraftWorld.java:2021) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at org.bukkit.craftbukkit.v1_19_R3.CraftWorld.spawnParticle(CraftWorld.java:2016) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at fun.ogre.ogredupealias.plugin.funitems.AK47.lambda$handleAK47$3(AK47.java:56) ~[OgreDupeAlias-2.0.0.jar:?]
|
||||
at fun.ogre.ogredupealias.utils.RaycastUtils.lambda$raycast$0(RaycastUtils.java:55) ~[OgreDupeAlias-2.0.0.jar:?]
|
||||
at org.bukkit.craftbukkit.v1_19_R3.scheduler.CraftTask.run(CraftTask.java:101) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at org.bukkit.craftbukkit.v1_19_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1485) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:450) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1399) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1176) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:322) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at java.lang.Thread.run(Thread.java:833) ~[?:?]
|
||||
[15:56:53 WARN]: [ODA] Task #488173 for OgreDupeAlias v2.0.0 generated an exception
|
||||
java.lang.IllegalArgumentException: data should be interface org.bukkit.block.data.BlockData got class org.bukkit.Material
|
||||
at org.bukkit.craftbukkit.v1_19_R3.CraftWorld.spawnParticle(CraftWorld.java:2077) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at org.bukkit.craftbukkit.v1_19_R3.CraftWorld.spawnParticle(CraftWorld.java:2072) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at org.bukkit.craftbukkit.v1_19_R3.CraftWorld.spawnParticle(CraftWorld.java:2061) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at org.bukkit.craftbukkit.v1_19_R3.CraftWorld.spawnParticle(CraftWorld.java:2041) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at org.bukkit.craftbukkit.v1_19_R3.CraftWorld.spawnParticle(CraftWorld.java:2021) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at org.bukkit.craftbukkit.v1_19_R3.CraftWorld.spawnParticle(CraftWorld.java:2016) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at fun.ogre.ogredupealias.plugin.funitems.AK47.lambda$handleAK47$3(AK47.java:56) ~[OgreDupeAlias-2.0.0.jar:?]
|
||||
at fun.ogre.ogredupealias.utils.RaycastUtils.lambda$raycast$0(RaycastUtils.java:55) ~[OgreDupeAlias-2.0.0.jar:?]
|
||||
at org.bukkit.craftbukkit.v1_19_R3.scheduler.CraftTask.run(CraftTask.java:101) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at org.bukkit.craftbukkit.v1_19_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1485) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:450) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1399) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1176) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:322) ~[pufferfish-1.19.4.jar:git-Pufferfish-65]
|
||||
at java.lang.Thread.run(Thread.java:833) ~[?:?]
|
||||
*/
|
||||
@@ -0,0 +1,229 @@
|
||||
package fun.ogre.ogredupealias.plugin.funitems;
|
||||
|
||||
import fun.ogre.ogredupealias.OgreDupeAlias;
|
||||
import fun.ogre.ogredupealias.events.EntityDamageListener;
|
||||
import fun.ogre.ogredupealias.plugin.ItemPresets;
|
||||
import fun.ogre.ogredupealias.utils.*;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.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.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
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.util.Vector;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class AdminUtility implements Listener {
|
||||
public static final Map<UUID, UUID> playerDragMap = new HashMap<>();
|
||||
|
||||
@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 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;
|
||||
});
|
||||
}
|
||||
}
|
||||
public static 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package fun.ogre.ogredupealias.plugin.funitems;
|
||||
import fun.ogre.ogredupealias.OgreDupeAlias;
|
||||
import fun.ogre.ogredupealias.events.EntityDamageListener;
|
||||
import fun.ogre.ogredupealias.plugin.ItemPresets;
|
||||
import fun.ogre.ogredupealias.utils.*;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Defender {
|
||||
|
||||
public static void handleDefender(PlayerInteractEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
ItemStack stack = e.getItem();
|
||||
Action a = e.getAction();
|
||||
if (ItemUtils.matchDisplay(stack, ItemPresets.DEFENDER)) {
|
||||
e.setCancelled(true);
|
||||
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
|
||||
Location stunLoc = entity.getLocation();
|
||||
int[] counter = {0};
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(OgreDupeAlias.instance,() -> {
|
||||
if (counter[0] > 60) return;
|
||||
if (entity == null) return;
|
||||
target.teleport(stunLoc);
|
||||
counter[0]++;
|
||||
},0,1);
|
||||
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();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package fun.ogre.ogredupealias.plugin.funitems;
|
||||
|
||||
import fun.ogre.ogredupealias.plugin.ItemPresets;
|
||||
import fun.ogre.ogredupealias.utils.Cooldown;
|
||||
import fun.ogre.ogredupealias.utils.ItemUtils;
|
||||
import fun.ogre.ogredupealias.utils.RaycastUtils;
|
||||
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.entity.Entity;
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
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.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class NetSkyBlade {
|
||||
|
||||
private static final Cooldown<UUID> netskySwordCooldown = new Cooldown<>();
|
||||
public static void handleNetskyBlade(PlayerInteractEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
ItemStack stack = e.getItem();
|
||||
Action a = e.getAction();
|
||||
if (!p.isOp()) return;
|
||||
if (ItemUtils.matchDisplay(stack, ItemPresets.NETSKY_BLADE) && !netskySwordCooldown.isOnCooldown(p.getUniqueId())) {
|
||||
netskySwordCooldown.setCooldown(p.getUniqueId(), 333);
|
||||
switch (a) {
|
||||
case LEFT_CLICK_BLOCK, LEFT_CLICK_AIR -> {
|
||||
Location start = p.getEyeLocation();
|
||||
Vector rotation = p.getEyeLocation().getDirection().normalize();
|
||||
SoundPlayer shootSound = new SoundPlayer(start, Sound.ENTITY_BLAZE_SHOOT, 1, 1);
|
||||
|
||||
shootSound.playWithin(20);
|
||||
|
||||
RaycastUtils.raycast(start, rotation, 30, 0.5, 1, (point, distance) -> {
|
||||
if (point == null || point.getWorld() == null) return false;
|
||||
|
||||
World w = point.getWorld();
|
||||
SoundPlayer popSound = new SoundPlayer(start, Sound.BLOCK_LAVA_POP, 1, 1);
|
||||
SoundPlayer hissSound = new SoundPlayer(start, Sound.BLOCK_LAVA_EXTINGUISH, 1, 1);
|
||||
|
||||
w.spawnParticle(Particle.FLAME, point, 1, 0, 0, 0, 0);
|
||||
w.spawnParticle(Particle.LAVA, point, 1, 0, 0, 0, 0);
|
||||
popSound.playWithin(3);
|
||||
|
||||
List<Entity> targets = new ArrayList<>(w.getNearbyEntities(point, 2, 2, 2, entity -> {
|
||||
return entity instanceof LivingEntity living && !living.isDead() && living != p;
|
||||
}));
|
||||
|
||||
targets.forEach(target -> {
|
||||
if (target instanceof LivingEntity living) {
|
||||
living.damage(5.0, p);
|
||||
living.setFireTicks(60);
|
||||
hissSound.playWithin(20);
|
||||
}
|
||||
});
|
||||
|
||||
return !targets.isEmpty() || !point.getBlock().isPassable();
|
||||
}, result -> {
|
||||
if (result == null || result.getWorld() == null) return;
|
||||
|
||||
World w = result.getWorld();
|
||||
SoundPlayer explodeSound = new SoundPlayer(result, Sound.ENTITY_GENERIC_EXPLODE, 3, 1.5F);
|
||||
|
||||
explodeSound.playWithin(500);
|
||||
w.spawnParticle(Particle.CAMPFIRE_COSY_SMOKE, result, 20, 0, 0, 0, 0.1);
|
||||
w.spawnParticle(Particle.LAVA, result, 120, 0, 0, 0, 1);
|
||||
});
|
||||
}
|
||||
case RIGHT_CLICK_AIR, RIGHT_CLICK_BLOCK -> {
|
||||
Location start = p.getEyeLocation();
|
||||
Vector rotation = p.getEyeLocation().getDirection().normalize();
|
||||
|
||||
p.getWorld().spawn(start, Fireball.class, fireball -> {
|
||||
fireball.setDirection(rotation);
|
||||
fireball.setVelocity(rotation);
|
||||
fireball.setShooter(p);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package fun.ogre.ogredupealias.plugin.funitems;
|
||||
|
||||
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.Text;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Snowball;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class PotatoCannon implements Listener {
|
||||
private static final int MAX_POTATOES = 6;
|
||||
private static Map<Player, List<Snowball>> loadedPotatoesMap = new HashMap<>();
|
||||
|
||||
public static void handlePotatoCannon(PlayerInteractEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
ItemStack stack = e.getItem();
|
||||
Action a = e.getAction();
|
||||
Inventory inv = p.getInventory();
|
||||
if (ItemUtils.matchDisplay(stack, ItemPresets.POTATOCANNON)) {
|
||||
e.setCancelled(true);
|
||||
switch (a) {
|
||||
case RIGHT_CLICK_BLOCK, RIGHT_CLICK_AIR -> {
|
||||
//Load potatoes
|
||||
loadPotatoes(p);
|
||||
}
|
||||
case LEFT_CLICK_AIR, LEFT_CLICK_BLOCK -> {
|
||||
// Launch Potatoes
|
||||
launchPotatoes(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadPotatoes(Player p) {
|
||||
List<Snowball> loadedPotatoes = loadedPotatoesMap.getOrDefault(p, new ArrayList<>());
|
||||
int potatoesInLauncher = loadedPotatoes.size();
|
||||
|
||||
if (potatoesInLauncher >= MAX_POTATOES) {
|
||||
p.sendMessage(Text.ofAll("&7Potato launcher is already full."));
|
||||
return;
|
||||
}
|
||||
|
||||
int potatoesToLoad = Math.min(1, ItemUtils.itemCount(p, Material.POTATO));
|
||||
|
||||
if (potatoesToLoad > 0) {
|
||||
p.getInventory().removeItem(new ItemStack(Material.POTATO, 1));
|
||||
loadedPotatoes.add(null); // Add a null placeholder for each potato loaded
|
||||
loadedPotatoesMap.put(p, loadedPotatoes);
|
||||
p.sendMessage(Text.ofAll("&7Loaded &a" + (potatoesInLauncher + 1) + "/" + MAX_POTATOES + "&7 potatoes into the launcher."));
|
||||
|
||||
SoundPlayer loadSound = new SoundPlayer(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1, 0.1F);
|
||||
loadSound.play(p);
|
||||
} else {
|
||||
p.sendMessage(Text.ofAll("&7You are out of potatoes!"));
|
||||
SoundPlayer failSound = new SoundPlayer(p.getLocation(), Sound.BLOCK_STONE_BREAK, 1, 1F);
|
||||
failSound.play(p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void launchPotatoes(Player shooter) {
|
||||
List<Snowball> loadedPotatoes = loadedPotatoesMap.getOrDefault(shooter, new ArrayList<>());
|
||||
|
||||
if (loadedPotatoes.isEmpty()) {
|
||||
// Play sound when launcher is empty
|
||||
SoundPlayer failSound = new SoundPlayer(shooter.getLocation(), Sound.BLOCK_NOTE_BLOCK_HAT, 1, 1F);
|
||||
failSound.play(shooter);
|
||||
return;
|
||||
}
|
||||
|
||||
int potatoCount = loadedPotatoes.size();
|
||||
for (int i = 0; i < potatoCount; i++) {
|
||||
ItemStack potatoStack = new ItemStack(Material.POTATO, 1);
|
||||
Snowball launchedPotato = shooter.launchProjectile(Snowball.class);
|
||||
launchedPotato.setShooter(shooter);
|
||||
launchedPotato.setItem(potatoStack);
|
||||
launchedPotato.setVelocity(RaycastUtils.randomVector(shooter.getEyeLocation().getDirection(), 5));
|
||||
SoundPlayer launchSound = new SoundPlayer(shooter.getLocation(), Sound.BLOCK_PISTON_EXTEND, 1, 1F);
|
||||
launchSound.playWithin(10);
|
||||
}
|
||||
|
||||
loadedPotatoes.clear();
|
||||
loadedPotatoesMap.remove(shooter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package fun.ogre.ogredupealias.plugin.funitems;
|
||||
|
||||
import fun.ogre.ogredupealias.OgreDupeAlias;
|
||||
import fun.ogre.ogredupealias.events.EntityDamageListener;
|
||||
import fun.ogre.ogredupealias.plugin.ItemPresets;
|
||||
import fun.ogre.ogredupealias.utils.*;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import static org.bukkit.event.block.Action.*;
|
||||
|
||||
|
||||
public class SnowChinegun {
|
||||
public static void handleSnowChinegun(PlayerInteractEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
ItemStack stack = e.getItem();
|
||||
Action a = e.getAction();
|
||||
Inventory inv = p.getInventory();
|
||||
ItemStack snowballItem = new ItemStack(Material.SNOWBALL, 1);
|
||||
if (ItemUtils.matchDisplay(stack, ItemPresets.SNOWCHINEGUN)) {
|
||||
e.setCancelled(true);
|
||||
SoundPlayer shootSound = new SoundPlayer(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1,0.8F);
|
||||
SoundPlayer launchSound = new SoundPlayer(p.getLocation(), Sound.BLOCK_PISTON_EXTEND, 1,1.5F);
|
||||
switch (a) {
|
||||
case RIGHT_CLICK_BLOCK, RIGHT_CLICK_AIR -> {
|
||||
int[] counter = {0};
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(OgreDupeAlias.instance,() -> {
|
||||
if (counter[0] > 7) return;
|
||||
counter[0]++;
|
||||
if (!inv.contains(Material.SNOWBALL) && p.getGameMode().equals(GameMode.SURVIVAL)) return;
|
||||
Vector look = p.getLocation().getDirection();
|
||||
Snowball snowball = p.launchProjectile(Snowball.class);
|
||||
snowball.setShooter(p);
|
||||
snowball.setVelocity(look.multiply(3));
|
||||
shootSound.playWithin(20);
|
||||
inv.removeItem(snowballItem);
|
||||
|
||||
},0,1);
|
||||
}
|
||||
case LEFT_CLICK_AIR, LEFT_CLICK_BLOCK -> {
|
||||
if (p.getGameMode().equals(GameMode.CREATIVE) && p.isSneaking()) {
|
||||
for (int i = 0; i < 512; i++) {
|
||||
Vector vec = RaycastUtils.randomVector(p.getLocation().getDirection(), 60);
|
||||
Snowball snowball = p.launchProjectile(Snowball.class);
|
||||
snowball.setVelocity(vec);
|
||||
}
|
||||
}
|
||||
if (!inv.contains(Material.SNOWBALL) && p.getGameMode().equals(GameMode.SURVIVAL)) return;
|
||||
launchSound.playWithin(20);
|
||||
shootSound.playWithin(10);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if (!inv.contains(Material.SNOWBALL) && p.getGameMode().equals(GameMode.SURVIVAL)) return;
|
||||
Vector vec = RaycastUtils.randomVector(p.getLocation().getDirection(), 20);
|
||||
Snowball snowball = p.launchProjectile(Snowball.class);
|
||||
snowball.setShooter(p);
|
||||
snowball.setVelocity(vec.multiply(1.6));
|
||||
inv.removeItem(snowballItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package fun.ogre.ogredupealias.plugin.funitems;
|
||||
|
||||
import fun.ogre.ogredupealias.OgreDupeAlias;
|
||||
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 org.bukkit.*;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
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.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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 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);
|
||||
// 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);
|
||||
SoundPlayer bellSound = new SoundPlayer(target.getLocation(), Sound.ITEM_TRIDENT_THUNDER, 1,0.4F);
|
||||
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);
|
||||
w.spawnParticle(Particle.SQUID_INK, originalLoc, 50, 0.5, 0, 0.5, 0);
|
||||
counter[0]++;
|
||||
},0,1);
|
||||
}
|
||||
});
|
||||
// Every raytrace
|
||||
w.spawnParticle(Particle.REDSTONE, point, 1,0,0,0,0, dust);
|
||||
return !targets.isEmpty();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package fun.ogre.ogredupealias.utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
@@ -54,4 +55,13 @@ public final class ItemUtils {
|
||||
public static boolean matchDisplay(ItemStack item, ItemStack item2) {
|
||||
return getDisplay(item).equals(getDisplay(item2));
|
||||
}
|
||||
public static int itemCount(Player p, Material material) {
|
||||
int count = 0;
|
||||
for (ItemStack i : p.getInventory().getContents()) {
|
||||
if (i != null && i.getType() == material) {
|
||||
count += i.getAmount();
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,4 +57,25 @@ public final class RaycastUtils {
|
||||
}
|
||||
}, 0, tickInterval);
|
||||
}
|
||||
|
||||
public static Vector randomVector(Vector baseVector, double angle) {
|
||||
// Generate a random angle within the given range
|
||||
double randomAngle = Math.random() * angle;
|
||||
|
||||
// Generate a random rotation axis
|
||||
double randomAxisX = Math.random() - 0.5;
|
||||
double randomAxisY = Math.random() - 0.5;
|
||||
double randomAxisZ = Math.random() - 0.5;
|
||||
|
||||
// Normalize the rotation axis
|
||||
Vector rotationAxis = new Vector(randomAxisX, randomAxisY, randomAxisZ).normalize();
|
||||
|
||||
// Calculate the rotation angle
|
||||
double rotationAngle = Math.toRadians(randomAngle);
|
||||
|
||||
// Rotate the base vector around the rotation axis
|
||||
Vector offsetVector = baseVector.clone().rotateAroundAxis(rotationAxis, rotationAngle);
|
||||
|
||||
return offsetVector;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
package fun.ogre.ogredupealias.utils;
|
||||
|
||||
import fun.ogre.ogredupealias.OgreDupeAlias;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@@ -18,7 +23,7 @@ public class ServerUtils {
|
||||
}
|
||||
|
||||
public static List<Player> getStaff() {
|
||||
return getPlayers().stream().filter(Player::isOp).toList();
|
||||
return getPlayers().stream().filter(Player -> Player.hasPermission("oda.chat.seeflags")).toList();
|
||||
}
|
||||
|
||||
public static void forEachPlayer(Consumer<Player> consumer) {
|
||||
@@ -50,4 +55,34 @@ public class ServerUtils {
|
||||
public static void sendActionBar(Player p, String msg) {
|
||||
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(msg));
|
||||
}
|
||||
|
||||
|
||||
public static boolean hasTag(Player p, String tag) {
|
||||
return p.getScoreboardTags().contains(tag);
|
||||
}
|
||||
public static void addTag(Player p, String tag) {
|
||||
p.getScoreboardTags().add(tag);
|
||||
}
|
||||
public static void removeTag(Player p, String tag) {
|
||||
p.getScoreboardTags().remove(tag);
|
||||
}
|
||||
public static boolean hasSameTag(Player p1, Player p2, String tag) {
|
||||
return hasTag(p1, tag) == hasTag(p2, tag);
|
||||
}
|
||||
public static void safeKill(Player p) {
|
||||
if (p.getBedSpawnLocation() == null) return;
|
||||
p.teleport(p.getBedSpawnLocation());
|
||||
Bukkit.getScheduler().runTaskLater(OgreDupeAlias.instance, () -> {
|
||||
p.setHealth(p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue());
|
||||
}, 10);
|
||||
}
|
||||
public static boolean hasBlockBelow(Player player, Material material) {
|
||||
for (int y = player.getLocation().getBlockY() - 1; y >= player.getLocation().getBlockY() - 12; y--) {
|
||||
if (player.getWorld().getBlockAt(player.getLocation().getBlockX(), y, player.getLocation().getBlockZ()).getType() == material) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,9 +29,15 @@ permissions:
|
||||
oda.commands.irepair:
|
||||
description: Access to irepair.
|
||||
default: op
|
||||
oda.commands.givecustoms:
|
||||
description: access custom items
|
||||
default: op
|
||||
oda.commands.attackcooldown:
|
||||
description: Access to attackcooldown.
|
||||
default: op
|
||||
oda.chat.seeflags:
|
||||
description: Receive the chat filter flags
|
||||
default: op
|
||||
oda.chat.bypass:
|
||||
description: Bypass chat restrictions
|
||||
default: op
|
||||
|
||||
Reference in New Issue
Block a user