Best commit name frfr (admin util drag still broken)

This commit is contained in:
TheTelly1
2023-06-30 19:49:34 -05:00
parent 71cba48118
commit d022fe4f36
13 changed files with 311 additions and 62 deletions

View File

@@ -4,6 +4,8 @@ import fun.ogre.ogredupealias.commands.commands.*;
import fun.ogre.ogredupealias.data.Config; import fun.ogre.ogredupealias.data.Config;
import fun.ogre.ogredupealias.events.*; import fun.ogre.ogredupealias.events.*;
import fun.ogre.ogredupealias.plugin.custom.forging.CraftingKeys; import fun.ogre.ogredupealias.plugin.custom.forging.CraftingKeys;
import fun.ogre.ogredupealias.plugin.funitems.AdminUtility;
import fun.ogre.ogredupealias.plugin.funitems.Pickler;
import fun.ogre.ogredupealias.plugin.funitems.PotatoCannon; import fun.ogre.ogredupealias.plugin.funitems.PotatoCannon;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
@@ -35,17 +37,20 @@ public final class OgreDupeAlias extends JavaPlugin {
public void init() { public void init() {
// Events // Events
pm.registerEvents(new ChatEventListener(),this); pm.registerEvents(new ChatEventListener(), this);
pm.registerEvents(new PlayerEventListener(),this); pm.registerEvents(new PlayerEventListener(), this);
pm.registerEvents(new CommandEventListener(),this); pm.registerEvents(new CommandEventListener(), this);
pm.registerEvents(new BlockActionListener(),this); pm.registerEvents(new BlockActionListener(), this);
pm.registerEvents(new EntityDeathListener(),this); pm.registerEvents(new EntityDeathListener(), this);
pm.registerEvents(new InteractionListener(),this); pm.registerEvents(new InteractionListener(), this);
pm.registerEvents(new InventoryActionListener(),this); pm.registerEvents(new InventoryActionListener(), this);
pm.registerEvents(new EntityDamageListener(),this); pm.registerEvents(new EntityDamageListener(), this);
pm.registerEvents(new SnowBallListener(), this); pm.registerEvents(new SnowBallListener(), this);
pm.registerEvents(new TurfWarsEventListener(), this); pm.registerEvents(new TurfWarsEventListener(), this);
pm.registerEvents(new PotatoCannon(), this); pm.registerEvents(new PotatoCannon(), this);
pm.registerEvents(new AdminUtility(), this);
pm.registerEvents(new Pickler(), this);
pm.registerEvents(new SPBEventListener(), this);
// Commands // Commands
getCommand("forcefield").setExecutor(new ForceFieldCommand()); getCommand("forcefield").setExecutor(new ForceFieldCommand());
@@ -67,6 +72,8 @@ public final class OgreDupeAlias extends JavaPlugin {
getCommand("message").setTabCompleter(new MessageCommand()); getCommand("message").setTabCompleter(new MessageCommand());
getCommand("attackcooldown").setExecutor(new AttackCooldownCommand()); getCommand("attackcooldown").setExecutor(new AttackCooldownCommand());
getCommand("attackcooldown").setTabCompleter(new AttackCooldownCommand()); getCommand("attackcooldown").setTabCompleter(new AttackCooldownCommand());
getCommand("givecustom").setExecutor(new GiveCustomCommand());
getCommand("givecustom").setTabCompleter(new GiveCustomCommand());
} }
public void initConfig() { public void initConfig() {
@@ -77,4 +84,4 @@ public final class OgreDupeAlias extends JavaPlugin {
public static String prefix() { public static String prefix() {
return Config.Plugin.prefix(); return Config.Plugin.prefix();
} }
} }

View File

@@ -52,6 +52,18 @@ public class GiveCustomCommand implements TabExecutor {
p.getInventory().addItem(ItemPresets.SPLEEFER); p.getInventory().addItem(ItemPresets.SPLEEFER);
p.sendMessage(Text.ofAll("&bGiven you a Spleefer")); p.sendMessage(Text.ofAll("&bGiven you a Spleefer"));
} }
case "PotatoCannon" -> {
p.getInventory().addItem(ItemPresets.POTATOCANNON);
p.sendMessage(Text.ofAll("&bGiven you a potato cannon"));
}
case "LaserPointer" -> {
p.getInventory().addItem(ItemPresets.LASER_POINTER);
p.sendMessage(Text.ofAll("&bGiven you a Laser Pointer"));
}
case "Pickler" -> {
p.getInventory().addItem(ItemPresets.PICKLER);
p.sendMessage(Text.ofAll("&bGiven you a Pickler"));
}
} }
} }
catch (Exception ex) { catch (Exception ex) {
@@ -72,7 +84,9 @@ public class GiveCustomCommand implements TabExecutor {
"NetSkyBlade", "NetSkyBlade",
"SnowChinegun", "SnowChinegun",
"VoidCharm", "VoidCharm",
"Spleefer" "Spleefer",
"PotatoCannon",
"LaserPointer"
}) })
.build(); .build();
} }

View File

@@ -41,6 +41,8 @@ public class InteractionListener implements Listener {
PotatoCannon.handlePotatoCannon(e); PotatoCannon.handlePotatoCannon(e);
PlayerEventListener.handleEnderPearls(e); PlayerEventListener.handleEnderPearls(e);
SPBItems.handleRifle(e); SPBItems.handleRifle(e);
LaserPointer.handleLaserPointer(e);
Pickler.handlePickler(e);
} }
catch (Exception ignore) {} catch (Exception ignore) {}
} }

View File

@@ -7,6 +7,7 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.data.type.Snow;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
@@ -20,26 +21,36 @@ import java.util.List;
public class SPBEventListener implements Listener { public class SPBEventListener implements Listener {
@EventHandler @EventHandler
public void onProjectileHit(ProjectileHitEvent e) { public void onProjectileHit(ProjectileHitEvent e) {
Projectile proj = e.getEntity(); try {
if (proj.getType() == EntityType.SNOWBALL && proj.getShooter() instanceof Player shooter) { Projectile proj = e.getEntity();
Snowball snowball = (Snowball) proj; if (proj instanceof Snowball && proj.getShooter() instanceof Player shooter) {
if (snowball.getItem().getType() == Material.BLUE_DYE || snowball.getItem().getType() == Material.BLUE_DYE) { Snowball snowball = (Snowball) proj;
if (!e.getHitBlock().getType().equals(Material.COMMAND_BLOCK) && !e.getHitBlock().getType().equals(Material.CHAIN_COMMAND_BLOCK) && !e.getHitBlock().getType().equals(Material.REPEATING_COMMAND_BLOCK)) { shooter.sendMessage("Hit a block");
SoundPlayer splatSound = new SoundPlayer(e.getHitBlock().getLocation(), Sound.ITEM_GLOW_INK_SAC_USE,1,1); if (snowball.getItem().getType() == Material.BLUE_DYE || snowball.getItem().getType() == Material.BLUE_DYE) {
splatSound.playWithin(10); shooter.sendMessage("Passed dye check");
List<String> tags = PlayerUtils.getTags(shooter); if (!e.getHitBlock().getType().equals(Material.COMMAND_BLOCK) && !e.getHitBlock().getType().equals(Material.CHAIN_COMMAND_BLOCK) && !e.getHitBlock().getType().equals(Material.REPEATING_COMMAND_BLOCK)) {
for (String tag : tags) { shooter.sendMessage("Passed command block check");
switch (tag) { SoundPlayer splatSound = new SoundPlayer(e.getHitBlock().getLocation(), Sound.ITEM_GLOW_INK_SAC_USE,1,1);
case "SPBfire" -> { splatSound.playWithin(10);
DisplayUtils.tempBlocks(e.getHitBlock(),Material.RED_TERRACOTTA,60); List<String> tags = PlayerUtils.getTags(shooter);
} for (String tag : tags) {
case "SPBfrost" -> { switch (tag) {
DisplayUtils.tempBlocks(e.getHitBlock(),Material.BLUE_TERRACOTTA,60); case "SPBfire" -> {
shooter.sendMessage("You were fire");
DisplayUtils.tempBlocks(e.getHitBlock(),Material.RED_TERRACOTTA,2,600);
}
case "SPBfrost" -> {
shooter.sendMessage("You were frost");
DisplayUtils.tempBlocks(e.getHitBlock(),Material.BLUE_TERRACOTTA,2,600);
}
} }
} }
} }
} }
} }
} catch (Exception ex) {
ex.printStackTrace();
} }
} }
} }

View File

@@ -93,8 +93,11 @@ public class TurfWarsEventListener implements Listener {
private void handleShotgunShoot(EntityShootBowEvent e) { private void handleShotgunShoot(EntityShootBowEvent e) {
if (e.getEntity() instanceof Player p) { if (e.getEntity() instanceof Player p) {
if (!PlayerUtils.hasTag(p,"TWshredder")) return; if (!PlayerUtils.hasTag(p,"TWshredder")) return;
if (p.getUniqueId().toString().equals("049460f7-21cb-42f5-8059-d42752bf406f")) {
shredderShot(p,4,7D);
}
if (p.getUniqueId().toString().equals("049460f7-21cb-42f5-8059-d42752bf406f") && p.isSneaking()) { if (p.getUniqueId().toString().equals("049460f7-21cb-42f5-8059-d42752bf406f") && p.isSneaking()) {
shredderShot(p,8,7D); shredderShot(p,300,30D);
} }
shredderShot(p,8,10D); shredderShot(p,8,10D);
} }

View File

@@ -92,8 +92,8 @@ public abstract class ItemPresets {
public static ItemStack LASER_POINTER = ItemBuilder.create() public static ItemStack LASER_POINTER = ItemBuilder.create()
.material(Material.LIME_CANDLE) .material(Material.LIME_CANDLE)
.name(Text.color("&2&l-&a&l[&bLaser Pointer&a&l]&2&l-")) .name(Text.color("&2&l-&a&l[&bLaser Pointer&a&l]&2&l-"))
.lore(Text.color("&2▪ &aRight-Click:&7 Single Dot")) .lore(Text.color("&2▪ &aRight-Click:&7 Full Beam"))
.lore(Text.color("&2▪ &aLeft-Click:&7 Full Beam")) .lore(Text.color("&2▪ &aLeft-Click:&7 Select Block"))
.customModelData(1111) .customModelData(1111)
.enchant(Enchantment.VANISHING_CURSE, 1) .enchant(Enchantment.VANISHING_CURSE, 1)
.flag(ItemFlag.HIDE_ENCHANTS) .flag(ItemFlag.HIDE_ENCHANTS)
@@ -144,7 +144,13 @@ public abstract class ItemPresets {
public static ItemStack SPBRifle = ItemBuilder.create() public static ItemStack SPBRifle = ItemBuilder.create()
.material(Material.IRON_HORSE_ARMOR) .material(Material.IRON_HORSE_ARMOR)
.name(Text.color("&f[SPB] &eRifle")) .name(Text.color("&f[SPB] &eRifle"))
.lore(Text.color("&7&e▪ &fRight-Click:&7 Shoot")) .lore(Text.color("&e▪ &fRight-Click:&7 Shoot"))
.customModelData(1111)
.build();
public static ItemStack PICKLER = ItemBuilder.create()
.material(Material.SEA_PICKLE)
.name(Text.color("&2&lPickler"))
.lore(Text.color("&2▪ &aRight-Click:&7 Pickle-ify Someone"))
.customModelData(1111) .customModelData(1111)
.build(); .build();
} }

View File

@@ -0,0 +1,54 @@
package fun.ogre.ogredupealias.plugin.funitems;
import fun.ogre.ogredupealias.OgreDupeAlias;
import fun.ogre.ogredupealias.plugin.ItemPresets;
import fun.ogre.ogredupealias.utils.DisplayUtils;
import fun.ogre.ogredupealias.utils.ItemUtils;
import fun.ogre.ogredupealias.utils.RaycastUtils;
import org.bukkit.*;
import org.bukkit.entity.Player;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import java.util.concurrent.atomic.AtomicReference;
public class LaserPointer {
public static void handleLaserPointer(PlayerInteractEvent e) {
Player p = e.getPlayer();
ItemStack stack = e.getItem();
Action a = e.getAction();
Location start = p.getEyeLocation();
Vector rot = p.getLocation().getDirection();
if (!ItemUtils.matchDisplay(stack, ItemPresets.LASER_POINTER)) return;
e.setCancelled(true);
switch (a) {
case RIGHT_CLICK_AIR, RIGHT_CLICK_BLOCK -> {
// Full beam
RaycastUtils.raycast(start,rot,30,0.1,(point) -> {
Particle.DustOptions dust = new Particle.DustOptions(Color.LIME, 0.5F);
point.getWorld().spawnParticle(Particle.REDSTONE,point,1,0,0,0,0,dust);
return !point.getBlock().getType().equals(Material.AIR);
});
}
case LEFT_CLICK_AIR, LEFT_CLICK_BLOCK -> {
// Select Block
Location block = RaycastUtils.raycast(start,rot,60,0.5,(point) -> {
return !point.getBlock().isPassable();
});
AtomicReference<Integer> counter = new AtomicReference<>(0);
Bukkit.getScheduler().scheduleSyncRepeatingTask(OgreDupeAlias.instance, () -> {
if (counter.get() > 60) return;
DisplayUtils.outLineBlock(block.getBlock(), (point) -> {
Particle.DustOptions dust = new Particle.DustOptions(Color.LIME, 0.5F);
block.getWorld().spawnParticle(Particle.REDSTONE,point,1,0,0,0,0,dust);
return false;
});
counter.set(counter.get() + 1);
},0,1);
}
}
}
}

View File

@@ -0,0 +1,83 @@
package fun.ogre.ogredupealias.plugin.funitems;
import fun.ogre.ogredupealias.OgreDupeAlias;
import fun.ogre.ogredupealias.plugin.ItemPresets;
import fun.ogre.ogredupealias.utils.*;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.Waterlogged;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
public class Pickler implements Listener {
public static void handlePickler(PlayerInteractEvent e) {
Player p = e.getPlayer();
ItemStack stack = e.getItem();
Action a = e.getAction();
Location start = p.getEyeLocation();
Vector rot = p.getLocation().getDirection();
if (!ItemUtils.matchDisplay(stack, ItemPresets.PICKLER)) return;
e.setCancelled(true);
switch (a) {
case RIGHT_CLICK_AIR, RIGHT_CLICK_BLOCK -> {
// Pickle
SoundPlayer throwSound = new SoundPlayer(p.getLocation(), Sound.ITEM_TRIDENT_RIPTIDE_3, 1,0.4F);
throwSound.playWithin(10);
RaycastUtils.raycast(start, rot, 60, 0.5, (point) -> {
World w = point.getWorld();
if (w == null) return false;
List<Entity> targets = new ArrayList<>(w.getNearbyEntities(point, 0.5,0.5,0.5, entity -> {
return entity instanceof Player player && !player.isDead() && player != p;
}));
targets.forEach(target -> {
if (target instanceof Player targetedPlayer) {
// Player hit here
SoundPlayer pickleSound = new SoundPlayer(target.getLocation(), Sound.ITEM_GLOW_INK_SAC_USE, 1,1F);
pickleSound.playWithin(10);
Block pickleBlock = targetedPlayer.getLocation().getBlock();
pickleBlock.setType(Material.SEA_PICKLE);
BlockState state = pickleBlock.getState();
Waterlogged waterlogged = (Waterlogged) state.getBlockData();
waterlogged.setWaterlogged(false);
pickleBlock.setBlockData(waterlogged, false);
PlayerUtils.addTag(targetedPlayer,"ODApickled");
p.sendMessage(Text.color("&9Event> &7You have been turned &e" + targetedPlayer.getName() + "&7 into a pickle!"));
target.sendMessage(Text.color("&9Event> &7You have been turned into a pickle by &e" + p.getName() + "&7. Its the funniest thing they've ever seen!"));
targetedPlayer.setInvisible(true);
Bukkit.getScheduler().runTaskLater(OgreDupeAlias.instance,() -> {
PlayerUtils.removeTag(targetedPlayer,"ODApickled");
target.getLocation().getBlock().setType(Material.AIR);
target.sendMessage(Text.color("&9Event> &7You are no longer a pickle."));
targetedPlayer.setInvisible(false);
},120);
}
});
return !targets.isEmpty();
});
}
}
}
@EventHandler
private void onMove(PlayerMoveEvent e) {
Player p = e.getPlayer();
if (PlayerUtils.hasTag(p,"ODApickled")){
e.setCancelled(true);
p.sendTitle(Text.color("&2&lI am a pickle"),Text.color("&aIts the funniest thing I've ever seen"), 0,1,1);
}
}
}

View File

@@ -43,6 +43,7 @@ public class SPBItems {
} }
} }
snowball.setVelocity(vec.multiply(2)); snowball.setVelocity(vec.multiply(2));
snowball.setShooter(p);
SoundPlayer shootSound = new SoundPlayer(p.getLocation(), Sound.ENTITY_ITEM_FRAME_REMOVE_ITEM,10,1); SoundPlayer shootSound = new SoundPlayer(p.getLocation(), Sound.ENTITY_ITEM_FRAME_REMOVE_ITEM,10,1);
shootSound.playWithin(30); shootSound.playWithin(30);
} }

View File

@@ -4,52 +4,63 @@ import fun.ogre.ogredupealias.OgreDupeAlias;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.function.BiPredicate; import java.util.function.BiPredicate;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Predicate;
import static fun.ogre.ogredupealias.OgreDupeAlias.instance; import static fun.ogre.ogredupealias.OgreDupeAlias.instance;
public final class DisplayUtils { public final class DisplayUtils {
public static void tempBlocks(Block centerBlock, Material desiredMaterial, int tickDuration) { public static void tempBlocks(Block centerBlock, Material desiredMaterial, int radius, int tickDuration) {
// Store the original blocks' states and materials Location loc = centerBlock.getLocation();
Block[][] originalBlocks = new Block[3][3]; List<Block> blocks = new ArrayList<>();
String[][] originalMaterials = new String[3][3]; forEachBlockIn(loc.clone().add(radius,radius,radius), loc.clone().subtract(radius,radius,radius), (point) -> {
Block b = point.getBlock();
for (int dx = -1; dx <= 1; dx++) { if (!b.getType().isAir() && loc.distance(point) <= radius) {
for (int dz = -1; dz <= 1; dz++) { blocks.add(b);
Block block = centerBlock.getRelative(dx, 0, dz); b.setType(desiredMaterial);
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, () -> { Bukkit.getScheduler().runTaskLater(instance, () -> {
for (int dx = -1; dx <= 1; dx++) { for (Block block : blocks) {
for (int dz = -1; dz <= 1; dz++) { Location point = block.getLocation();
Block block = centerBlock.getRelative(dx, 0, dz); Block b2 = point.getBlock();
Material originalMaterial = Material.getMaterial(originalMaterials[dx + 1][dz + 1]); b2.setType(block.getType());
if (originalMaterial != null) { b2.setBlockData(block.getBlockData());
block.setType(originalMaterial); }
} }, 60);
block.setBlockData(originalBlocks[dx + 1][dz + 1].getBlockData()); }
public static void forEachBlockIn(Location start, Location end, Consumer<Location> action) {
int[] min = {
Math.min(start.getBlockX(), end.getBlockX()),
Math.min(start.getBlockY(), end.getBlockY()),
Math.min(start.getBlockZ(), end.getBlockZ())
};
int[] max = {
Math.max(start.getBlockX(), end.getBlockX()),
Math.max(start.getBlockY(), end.getBlockY()),
Math.max(start.getBlockZ(), end.getBlockZ())
};
for (int a = min[0]; a <= max[0]; a ++) {
for (int b = min[1]; b <= max[1]; b ++) {
for (int c = min[2]; c <= max[2]; c ++) {
Location loc = new Location(start.getWorld(), a, b, c);
action.accept(loc);
} }
} }
}, tickDuration); }
} }
public static void ring(Location center, double radius, Consumer<Location> onPoint, BiPredicate<Location, Integer> condition) { public static void ring(Location center, double radius, Consumer<Location> onPoint, BiPredicate<Location, Integer> condition) {
for (int i = 0; i <= 360; i ++) { for (int i = 0; i <= 360; i ++) {
Location point = center.clone().add(radius * Math.sin(i), 0, radius * Math.cos(i)); Location point = center.clone().add(radius * Math.sin(i), 0, radius * Math.cos(i));
@@ -69,4 +80,28 @@ public final class DisplayUtils {
} }
}, 0, interval); }, 0, interval);
} }
public static void outLineBlock(Block block, Predicate<Location> hitCondition) {
Location loc = block.getLocation();
Location b1 = loc.clone().add(0,0,0);
Location b2 = loc.clone().add(1,0,0);
Location b3 = loc.clone().add(0,0,1);
Location b4 = loc.clone().add(1,0,1);
Location t1 = loc.clone().add(0,1,0);
Location t2 = loc.clone().add(1,1,0);
Location t3 = loc.clone().add(0,1,1);
Location t4 = loc.clone().add(1,1,1);
RaycastUtils.raycast(b1,b2,0.2, hitCondition);
RaycastUtils.raycast(b1,b3,0.2, hitCondition);
RaycastUtils.raycast(b2,b4,0.2, hitCondition);
RaycastUtils.raycast(b3,b4,0.2, hitCondition);
RaycastUtils.raycast(b1,t1,0.2, hitCondition);
RaycastUtils.raycast(b2,t2,0.2, hitCondition);
RaycastUtils.raycast(b3,t3,0.2, hitCondition);
RaycastUtils.raycast(b4,t4,0.2, hitCondition);
RaycastUtils.raycast(t1,t2,0.2, hitCondition);
RaycastUtils.raycast(t1,t3,0.2, hitCondition);
RaycastUtils.raycast(t3,t4,0.2, hitCondition);
RaycastUtils.raycast(t2,t4,0.2, hitCondition);
}
} }

View File

@@ -2,8 +2,10 @@ package fun.ogre.ogredupealias.utils;
import fun.ogre.ogredupealias.OgreDupeAlias; import fun.ogre.ogredupealias.OgreDupeAlias;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Scoreboard;
import java.util.ArrayList; import java.util.ArrayList;
@@ -29,7 +31,26 @@ public class PlayerUtils {
return hasTag(p1, tag) == hasTag(p2, tag); return hasTag(p1, tag) == hasTag(p2, tag);
} }
public static void safeKill(Player p) { public static void safeKill(Player p) {
if (p.getBedSpawnLocation() == null) return; if (p.getBedSpawnLocation() == null) {
p.teleport(p.getWorld().getSpawnLocation());
return;
}
if (hasTag(p,"TWjester") && (hasTag(p,"TWblue"))) {
ServerUtils.forEachPlayerRun(players -> {
return hasTag(players,"TWplayer") && hasTag(players, "TWblue");
}, players -> {
players.getInventory().addItem(new ItemStack(Material.ARROW,1));
players.sendMessage(Text.color("&9Game> &7Your jester has fallen! You have been given an arrow."));
});
}
if (hasTag(p,"TWjester") && (hasTag(p,"TWred"))) {
ServerUtils.forEachPlayerRun(players -> {
return hasTag(players,"TWplayer") && hasTag(players, "TWred");
}, players -> {
players.getInventory().addItem(new ItemStack(Material.ARROW,1));
players.sendMessage(Text.color("&9Game> &7Your jester has fallen! You have been given an arrow."));
});
}
p.teleport(p.getBedSpawnLocation()); p.teleport(p.getBedSpawnLocation());
Bukkit.getScheduler().runTaskLater(OgreDupeAlias.instance, () -> { Bukkit.getScheduler().runTaskLater(OgreDupeAlias.instance, () -> {
p.setHealth(p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue()); p.setHealth(p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue());

View File

@@ -51,7 +51,13 @@ public class ServerUtils {
public static void forEachSpecified(Consumer<Player> consumer, Player... players) { public static void forEachSpecified(Consumer<Player> consumer, Player... players) {
Arrays.stream(players).forEach(consumer); Arrays.stream(players).forEach(consumer);
} }
public static void forEachPlayerRun(Predicate<Player> condition, Consumer<Player> task) {
forEachPlayer(p -> {
if (condition.test(p)) {
task.accept(p);
}
});
}
public static void sendActionBar(Player p, String msg) { public static void sendActionBar(Player p, String msg) {
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(msg)); p.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(msg));
} }

View File

@@ -29,7 +29,7 @@ permissions:
oda.commands.irepair: oda.commands.irepair:
description: Access to irepair. description: Access to irepair.
default: op default: op
oda.commands.givecustoms: oda.commands.givecustom:
description: access custom items description: access custom items
default: op default: op
oda.commands.attackcooldown: oda.commands.attackcooldown:
@@ -60,6 +60,12 @@ permissions:
default: op default: op
commands: commands:
givecustom:
description: give custom items
usage: /givecustom <customitem>
permission: oda.command.givecustom
aliases:
- givec
config: config:
description: Config management description: Config management
usage: /config [get|set] <path> <datatype> <value> usage: /config [get|set] <path> <datatype> <value>