Best commit name frfr (admin util drag still broken)
This commit is contained in:
@@ -39,6 +39,8 @@ public class InteractionListener implements Listener {
|
||||
SnowChinegun.handleSnowChinegun(e);
|
||||
AK47.handleAK47(e);
|
||||
PotatoCannon.handlePotatoCannon(e);
|
||||
PlayerEventListener.handleEnderPearls(e);
|
||||
SPBItems.handleRifle(e);
|
||||
}
|
||||
catch (Exception ignore) {}
|
||||
}
|
||||
|
||||
@@ -15,9 +15,6 @@ 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
|
||||
@@ -43,7 +40,7 @@ public class PlayerEventListener implements Listener {
|
||||
catch (Exception ignore) {}
|
||||
}
|
||||
|
||||
private void handleEnderPearls(PlayerInteractEvent e) {
|
||||
public static void handleEnderPearls(PlayerInteractEvent e) {
|
||||
ItemStack item = e.getItem();
|
||||
Player p = e.getPlayer();
|
||||
Action a = e.getAction();
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package fun.ogre.ogredupealias.events;
|
||||
|
||||
import fun.ogre.ogredupealias.utils.DisplayUtils;
|
||||
import fun.ogre.ogredupealias.utils.PlayerUtils;
|
||||
import fun.ogre.ogredupealias.utils.SoundPlayer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
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.Listener;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SPBEventListener implements Listener {
|
||||
@EventHandler
|
||||
public void onProjectileHit(ProjectileHitEvent e) {
|
||||
Projectile proj = e.getEntity();
|
||||
if (proj.getType() == EntityType.SNOWBALL && proj.getShooter() instanceof Player shooter) {
|
||||
Snowball snowball = (Snowball) proj;
|
||||
if (snowball.getItem().getType() == Material.BLUE_DYE || snowball.getItem().getType() == Material.BLUE_DYE) {
|
||||
if (!e.getHitBlock().getType().equals(Material.COMMAND_BLOCK) && !e.getHitBlock().getType().equals(Material.CHAIN_COMMAND_BLOCK) && !e.getHitBlock().getType().equals(Material.REPEATING_COMMAND_BLOCK)) {
|
||||
SoundPlayer splatSound = new SoundPlayer(e.getHitBlock().getLocation(), Sound.ITEM_GLOW_INK_SAC_USE,1,1);
|
||||
splatSound.playWithin(10);
|
||||
List<String> tags = PlayerUtils.getTags(shooter);
|
||||
for (String tag : tags) {
|
||||
switch (tag) {
|
||||
case "SPBfire" -> {
|
||||
DisplayUtils.tempBlocks(e.getHitBlock(),Material.RED_TERRACOTTA,60);
|
||||
}
|
||||
case "SPBfrost" -> {
|
||||
DisplayUtils.tempBlocks(e.getHitBlock(),Material.BLUE_TERRACOTTA,60);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
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 fun.ogre.ogredupealias.plugin.funitems.*;
|
||||
import fun.ogre.ogredupealias.utils.*;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
@@ -13,6 +11,7 @@ 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.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -26,33 +25,33 @@ 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) {
|
||||
private static void handleAntiTurfWalk(PlayerMoveEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if (ServerUtils.hasTag(p,"TWplayer") && ServerUtils.hasTag(p,"TWat")) {
|
||||
if (ServerUtils.hasTag(p,"TWred")) {
|
||||
if (PlayerUtils.hasTag(p,"TWplayer") && PlayerUtils.hasTag(p,"TWat")) {
|
||||
if (PlayerUtils.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
|
||||
p.setVelocity(new Vector(0, 0.1, -0.5)); // Adjust the velocity values as needed
|
||||
}
|
||||
} else if (ServerUtils.hasTag(p,"TWblue")) {
|
||||
} else if (PlayerUtils.hasTag(p,"TWblue")) {
|
||||
if (hasBlockBelow(p, Material.RED_TERRACOTTA)) {
|
||||
p.setVelocity(new Vector(0, 0.25, 0.5)); // Adjust the velocity values as needed
|
||||
p.setVelocity(new Vector(0, 0.1, 0.5)); // Adjust the velocity values as needed
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onAOELand(ProjectileHitEvent e) {
|
||||
private void handleAOELand(ProjectileHitEvent e) {
|
||||
Entity ent = e.getEntity();
|
||||
if (e.getEntity().getShooter() instanceof Player shooter) {
|
||||
if (ServerUtils.hasTag(shooter, "TWbomber")) {
|
||||
if (PlayerUtils.hasTag(shooter, "TWbomber")) {
|
||||
if (!(ent instanceof Snowball)) return;
|
||||
if (shooter.getUniqueId().toString().equals("049460f7-21cb-42f5-8059-d42752bf406f") && shooter.isSneaking()) {
|
||||
if (e.getHitEntity() != null && e.getHitEntity() instanceof Player victim) {
|
||||
explodeOnLand(shooter,e.getHitEntity().getLocation(),3D,4);
|
||||
explodeOnLand(shooter,e.getHitEntity().getLocation(),4D,4);
|
||||
}
|
||||
if (e.getHitBlock() != null) {
|
||||
explodeOnLand(shooter,e.getHitBlock().getLocation(),3D,2);
|
||||
explodeOnLand(shooter,e.getHitBlock().getLocation(),8D,2);
|
||||
}
|
||||
}
|
||||
if (e.getHitEntity() != null && e.getHitEntity() instanceof Player) {
|
||||
@@ -66,59 +65,58 @@ public class TurfWarsEventListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onBlockHit(ProjectileHitEvent e) {
|
||||
private void handleHit(ProjectileHitEvent e) {
|
||||
if (e.getEntity().getShooter() instanceof Player shooter) {
|
||||
if (ServerUtils.hasTag(shooter, "TWplayer")) {
|
||||
if (PlayerUtils.hasTag(shooter, "TWplayer") && !(PlayerUtils.hasTag(shooter, "TWsniper"))) {
|
||||
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;
|
||||
if (PlayerUtils.hasTag(shooter,"TWbomber") || PlayerUtils.hasTag(shooter,"TWshredder")) return;
|
||||
e.getEntity().remove();
|
||||
twBreak(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void antiSpawnKill(PlayerMoveEvent e) {
|
||||
if (ServerUtils.hasTag(e.getPlayer(),"TWsk")) {
|
||||
private void handleAntiSpawnKill(PlayerMoveEvent e) {
|
||||
if (PlayerUtils.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");
|
||||
PlayerUtils.safeKill(e.getPlayer());
|
||||
PlayerUtils.removeTag(e.getPlayer(),"TWsk");
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
private void onShotgunShoot(EntityShootBowEvent e) {
|
||||
private void handleShotgunShoot(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);
|
||||
if (!PlayerUtils.hasTag(p,"TWshredder")) return;
|
||||
if (p.getUniqueId().toString().equals("049460f7-21cb-42f5-8059-d42752bf406f") && p.isSneaking()) {
|
||||
shredderShot(p,8,7D);
|
||||
}
|
||||
shredderShot(p,10,5D);
|
||||
shredderShot(p,8,10D);
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
private void onSnipePlayer(ProjectileHitEvent e) {
|
||||
private void handleShootPlayer(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 (PlayerUtils.hasSameTag(shooter,victim,"TWblue")) return;
|
||||
if (PlayerUtils.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);
|
||||
if (!PlayerUtils.hasTag(victim,"TWplayer")) return;
|
||||
if (PlayerUtils.hasTag(shooter,"TWplayer") && !PlayerUtils.hasTag(shooter,"TWshredder")) {
|
||||
PlayerUtils.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."));
|
||||
victim.sendMessage(Text.color("&9Game> &7You have been shot by &e" + shooter.getName() + "&7."));
|
||||
shooter.sendMessage(Text.color("&9Game> &7You shot &e" + victim.getName() + "&7."));
|
||||
hitSound.play(shooter);
|
||||
} else if (ServerUtils.hasTag(shooter,"TWshredder")) {
|
||||
ServerUtils.safeKill(victim);
|
||||
} else if (PlayerUtils.hasTag(shooter,"TWshredder")) {
|
||||
PlayerUtils.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);
|
||||
@@ -127,33 +125,74 @@ public class TurfWarsEventListener implements Listener {
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
private void onInfiltratorHit(EntityDamageByEntityEvent e) {
|
||||
private void handleSniperHitPlayer(ProjectileHitEvent e) {
|
||||
e.getEntity().remove();
|
||||
if (e.getHitEntity() instanceof Player victim && e.getEntity().getShooter() instanceof Player shooter && PlayerUtils.hasTag(shooter,"TWsniper")) {
|
||||
if (PlayerUtils.hasSameTag(shooter,victim,"TWblue")) return;
|
||||
if (PlayerUtils.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 (!PlayerUtils.hasTag(victim, "TWplayer")) return;
|
||||
PlayerUtils.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
private void handleSniperHitBlock(ProjectileHitEvent e) {
|
||||
if (e.getEntity().getShooter() instanceof Player shooter) {
|
||||
if (PlayerUtils.hasTag(shooter, "TWplayer") && (PlayerUtils.hasTag(shooter, "TWsniper"))) {
|
||||
if (e.getHitBlock() == null) return;
|
||||
Block block = e.getHitBlock();
|
||||
if (e.getHitBlock().getType() == Material.BLUE_WOOL || block.getType() == Material.RED_WOOL) {
|
||||
twBreak(block);
|
||||
} else if (e.getHitBlock().getType() == Material.BLUE_CONCRETE || block.getType() == Material.RED_CONCRETE) {
|
||||
twBreak(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
private void handleSniperShoot(EntityShootBowEvent e) {
|
||||
if (e.getEntity() instanceof Player p) {
|
||||
if (!PlayerUtils.hasTag(p,"TWsniper")) return;
|
||||
e.setCancelled(true);
|
||||
shredderShot(p,12,0D);
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
private void handleInfiltratorKill(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);
|
||||
if (PlayerUtils.hasSameTag(attacker,victim,"TWblue")) return;
|
||||
if (PlayerUtils.hasSameTag(attacker,victim,"TWred")) return;
|
||||
if (PlayerUtils.hasTag(attacker,"TWat")) return;
|
||||
if (PlayerUtils.hasTag(attacker, "TWinfiltrator") && PlayerUtils.hasTag(victim, "TWplayer")) {
|
||||
PlayerUtils.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) {
|
||||
private void handleInfiltratorHit(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."));
|
||||
if (PlayerUtils.hasSameTag(attacker,victim,"TWblue")) return;
|
||||
if (PlayerUtils.hasSameTag(attacker,victim,"TWred")) return;
|
||||
if (PlayerUtils.hasTag(victim, "TWinfiltrator") && PlayerUtils.hasTag(attacker, "TWplayer")) {
|
||||
PlayerUtils.safeKill(victim);
|
||||
victim.sendMessage(Text.color("&9Game> &7You have been bludgeoned by &e" + attacker.getName() + "&7."));
|
||||
attacker.sendMessage(Text.color("&9Game> &7You bludgeoned &e" + victim.getName() + "&7."));
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
private void onRespawn(PlayerRespawnEvent e) {
|
||||
if (ServerUtils.hasTag(e.getPlayer(),"TWplayer")) {
|
||||
ServerUtils.removeTag(e.getPlayer(),"oneshot");
|
||||
private void handleTurfWarsRespawn(PlayerRespawnEvent e) {
|
||||
if (PlayerUtils.hasTag(e.getPlayer(),"TWplayer")) {
|
||||
PlayerUtils.removeTag(e.getPlayer(),"oneshot");
|
||||
e.getPlayer().sendMessage(Text.color("&9Game> &7Respawned!"));
|
||||
}
|
||||
}
|
||||
@@ -183,9 +222,9 @@ public class TurfWarsEventListener implements Listener {
|
||||
}));
|
||||
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);
|
||||
if (PlayerUtils.hasSameTag(attacker,victim2,"TWblue")) return;
|
||||
if (PlayerUtils.hasSameTag(attacker,victim2,"TWred")) return;
|
||||
PlayerUtils.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!"));
|
||||
}
|
||||
|
||||
@@ -141,4 +141,10 @@ public abstract class ItemPresets {
|
||||
.flag(ItemFlag.HIDE_ENCHANTS)
|
||||
.flag(ItemFlag.HIDE_UNBREAKABLE)
|
||||
.build();
|
||||
public static ItemStack SPBRifle = ItemBuilder.create()
|
||||
.material(Material.IRON_HORSE_ARMOR)
|
||||
.name(Text.color("&f[SPB] &eRifle"))
|
||||
.lore(Text.color("&7&e▪ &fRight-Click:&7 Shoot"))
|
||||
.customModelData(1111)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ public abstract class CraftingKeys {
|
||||
|
||||
public static void initRecipes() {
|
||||
// my custom
|
||||
register(ItemPresets.SPBRifle, "[iron_horse_armor{}]");
|
||||
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{}]");
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package fun.ogre.ogredupealias.plugin.funitems;
|
||||
|
||||
import fun.ogre.ogredupealias.OgreDupeAlias;
|
||||
import fun.ogre.ogredupealias.plugin.ItemPresets;
|
||||
import fun.ogre.ogredupealias.utils.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import fun.ogre.ogredupealias.utils.PlayerUtils;
|
||||
import org.bukkit.Sound;
|
||||
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.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SPBItems {
|
||||
public static ItemStack bluePaint = new ItemStack(Material.BLUE_DYE, 1);
|
||||
public static ItemStack redPaint = new ItemStack(Material.RED_DYE, 1);
|
||||
public static void handleRifle(PlayerInteractEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
ItemStack stack = e.getItem();
|
||||
Action a = e.getAction();
|
||||
if (ItemUtils.matchDisplay(stack, ItemPresets.SPBRifle) && PlayerUtils.hasTag(p,"SPBplayer")) {
|
||||
e.setCancelled(true);
|
||||
switch (a) {
|
||||
case RIGHT_CLICK_BLOCK, RIGHT_CLICK_AIR -> {
|
||||
Vector vec = p.getLocation().getDirection();
|
||||
Snowball snowball = p.launchProjectile(Snowball.class);
|
||||
List<String> tags = PlayerUtils.getTags(p);
|
||||
for (String tag : tags) {
|
||||
switch (tag) {
|
||||
case "SPBfire" -> {
|
||||
snowball.setItem(redPaint);
|
||||
}
|
||||
case "SPBfrost" -> {
|
||||
snowball.setItem(bluePaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
snowball.setVelocity(vec.multiply(2));
|
||||
SoundPlayer shootSound = new SoundPlayer(p.getLocation(), Sound.ENTITY_ITEM_FRAME_REMOVE_ITEM,10,1);
|
||||
shootSound.playWithin(30);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,11 @@
|
||||
package fun.ogre.ogredupealias.utils;
|
||||
|
||||
import fun.ogre.ogredupealias.OgreDupeAlias;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.BiPredicate;
|
||||
@@ -11,6 +15,41 @@ import static fun.ogre.ogredupealias.OgreDupeAlias.instance;
|
||||
|
||||
public final class DisplayUtils {
|
||||
|
||||
public static void tempBlocks(Block centerBlock, Material desiredMaterial, int tickDuration) {
|
||||
// Store the original blocks' states and materials
|
||||
Block[][] originalBlocks = new Block[3][3];
|
||||
String[][] originalMaterials = new String[3][3];
|
||||
|
||||
for (int dx = -1; dx <= 1; dx++) {
|
||||
for (int dz = -1; dz <= 1; dz++) {
|
||||
Block block = centerBlock.getRelative(dx, 0, dz);
|
||||
originalBlocks[dx + 1][dz + 1] = block;
|
||||
originalMaterials[dx + 1][dz + 1] = block.getType().name();
|
||||
}
|
||||
}
|
||||
|
||||
// Modify the blocks to the desired material
|
||||
for (int dx = -1; dx <= 1; dx++) {
|
||||
for (int dz = -1; dz <= 1; dz++) {
|
||||
Block block = centerBlock.getRelative(dx, 0, dz);
|
||||
block.setType(desiredMaterial);
|
||||
}
|
||||
}
|
||||
|
||||
// Schedule a task to revert the blocks after the desired number of ticks
|
||||
Bukkit.getScheduler().runTaskLater(instance, () -> {
|
||||
for (int dx = -1; dx <= 1; dx++) {
|
||||
for (int dz = -1; dz <= 1; dz++) {
|
||||
Block block = centerBlock.getRelative(dx, 0, dz);
|
||||
Material originalMaterial = Material.getMaterial(originalMaterials[dx + 1][dz + 1]);
|
||||
if (originalMaterial != null) {
|
||||
block.setType(originalMaterial);
|
||||
}
|
||||
block.setBlockData(originalBlocks[dx + 1][dz + 1].getBlockData());
|
||||
}
|
||||
}
|
||||
}, tickDuration);
|
||||
}
|
||||
public static void ring(Location center, double radius, Consumer<Location> onPoint, BiPredicate<Location, Integer> condition) {
|
||||
for (int i = 0; i <= 360; i ++) {
|
||||
Location point = center.clone().add(radius * Math.sin(i), 0, radius * Math.cos(i));
|
||||
|
||||
38
src/main/java/fun/ogre/ogredupealias/utils/PlayerUtils.java
Normal file
38
src/main/java/fun/ogre/ogredupealias/utils/PlayerUtils.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package fun.ogre.ogredupealias.utils;
|
||||
|
||||
import fun.ogre.ogredupealias.OgreDupeAlias;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerUtils {
|
||||
public static List<String> getTags(Player player) {
|
||||
List<String> tags = new ArrayList<>();
|
||||
tags.addAll(player.getScoreboardTags());
|
||||
return tags;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -56,26 +56,6 @@ public class ServerUtils {
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user