added levetation wand mechanic
This commit is contained in:
parent
3d71110f37
commit
04f731d7cd
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -17,3 +17,7 @@ commands:
|
|||||||
description: "Gives the player a Gravity Gauntlet"
|
description: "Gives the player a Gravity Gauntlet"
|
||||||
usage: "/gravitygauntlet"
|
usage: "/gravitygauntlet"
|
||||||
permission: CoswayUtil.GravityGauntlet
|
permission: CoswayUtil.GravityGauntlet
|
||||||
|
getwand:
|
||||||
|
description: "Gives player a levitation wand"
|
||||||
|
usage: "/getwand"
|
||||||
|
permission: CoswayUtil.wand
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -70,15 +70,20 @@ public final class CoswayUtil extends JavaPlugin implements Listener {
|
|||||||
// Register TotemShield
|
// Register TotemShield
|
||||||
new TotemShield(this);
|
new TotemShield(this);
|
||||||
// Register the ShadowStep listener
|
// Register the ShadowStep listener
|
||||||
|
new MobLevitationWand(this);
|
||||||
getServer().getPluginManager().registerEvents(new ShadowStep(this), this);
|
getServer().getPluginManager().registerEvents(new ShadowStep(this), this);
|
||||||
// Register command
|
//register levitation wand
|
||||||
this.getCommand("gravitygauntlet").setExecutor(new GravityGauntletCommand());
|
Bukkit.getPluginManager().registerEvents(new MobLevitationWand(this), this);
|
||||||
// Register the PhantomDodge listener
|
// Register the PhantomDodge listener
|
||||||
getServer().getPluginManager().registerEvents(new PhantomDodge(this), this);
|
getServer().getPluginManager().registerEvents(new PhantomDodge(this), this);
|
||||||
// Register the WitherContract listener
|
// Register the WitherContract listener
|
||||||
getServer().getPluginManager().registerEvents(new WitherContract(this), this);
|
getServer().getPluginManager().registerEvents(new WitherContract(this), this);
|
||||||
Bukkit.getPluginManager().registerEvents(new MobLevitationWand(this), this);
|
// Register commands
|
||||||
|
this.getCommand("gravitygauntlet").setExecutor(new GravityGauntletCommand());
|
||||||
this.getCommand("getwand").setExecutor(new GiveWandCommand());
|
this.getCommand("getwand").setExecutor(new GiveWandCommand());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -4,6 +4,8 @@ import org.bukkit.*;
|
|||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||||
|
import org.bukkit.event.player.PlayerAnimationType;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
@ -15,7 +17,7 @@ import java.util.HashMap;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class MobLevitationWand implements Listener {
|
public class MobLevitationWand implements Listener {
|
||||||
private final NamespacedKey wandKey = new NamespacedKey("your_plugin", "levitation_wand");
|
private final NamespacedKey wandKey = new NamespacedKey("coswayutil", "levitation_wand");
|
||||||
private final HashMap<UUID, Entity> levitatedMobs = new HashMap<>();
|
private final HashMap<UUID, Entity> levitatedMobs = new HashMap<>();
|
||||||
private final CoswayUtil plugin;
|
private final CoswayUtil plugin;
|
||||||
|
|
||||||
@ -53,6 +55,7 @@ public class MobLevitationWand implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean isLevitationWand(ItemStack item) {
|
private boolean isLevitationWand(ItemStack item) {
|
||||||
if (item == null || item.getType() != Material.STICK || !item.hasItemMeta()) return false;
|
if (item == null || item.getType() != Material.STICK || !item.hasItemMeta()) return false;
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
@ -78,6 +81,18 @@ public class MobLevitationWand implements Listener {
|
|||||||
|
|
||||||
Vector direction = player.getLocation().getDirection().normalize().multiply(5);
|
Vector direction = player.getLocation().getDirection().normalize().multiply(5);
|
||||||
Location newLocation = player.getLocation().add(direction);
|
Location newLocation = player.getLocation().add(direction);
|
||||||
|
World world = player.getWorld();
|
||||||
|
|
||||||
|
// Ensure the mob is not placed inside a solid block
|
||||||
|
while (newLocation.getBlock().getType().isSolid()) {
|
||||||
|
newLocation.add(0, 1, 0); // Move up until a free space is found
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure the mob is not underground
|
||||||
|
int highestY = world.getHighestBlockYAt(newLocation);
|
||||||
|
if (newLocation.getY() < highestY) {
|
||||||
|
newLocation.setY(highestY + 1); // Adjust to be above ground
|
||||||
|
}
|
||||||
|
|
||||||
entity.teleport(newLocation);
|
entity.teleport(newLocation);
|
||||||
|
|
||||||
@ -92,6 +107,7 @@ public class MobLevitationWand implements Listener {
|
|||||||
}.runTaskTimer(plugin, 0L, 2L);
|
}.runTaskTimer(plugin, 0L, 2L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void releaseMob(Player player) {
|
private void releaseMob(Player player) {
|
||||||
Entity entity = levitatedMobs.remove(player.getUniqueId());
|
Entity entity = levitatedMobs.remove(player.getUniqueId());
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
@ -104,7 +120,7 @@ public class MobLevitationWand implements Listener {
|
|||||||
ItemStack wand = new ItemStack(Material.STICK);
|
ItemStack wand = new ItemStack(Material.STICK);
|
||||||
ItemMeta meta = wand.getItemMeta();
|
ItemMeta meta = wand.getItemMeta();
|
||||||
meta.setDisplayName(ChatColor.LIGHT_PURPLE + "Levitation Wand");
|
meta.setDisplayName(ChatColor.LIGHT_PURPLE + "Levitation Wand");
|
||||||
meta.getPersistentDataContainer().set(new NamespacedKey("CoswayUtil", "levitation_wand"), PersistentDataType.STRING, "true");
|
meta.getPersistentDataContainer().set(new NamespacedKey("coswayutil", "levitation_wand"), PersistentDataType.STRING, "true");
|
||||||
wand.setItemMeta(meta);
|
wand.setItemMeta(meta);
|
||||||
return wand;
|
return wand;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user