Bukkit Horse disabling horse spawn around blocks
I need to know if there is a way to check if there are any blocks within a radius of 3 around the user(NOT ABOVE OR BELOW). At the moment there is a bug in the game where if you spawn in a horse right next to a wall, you glitch through it. and on an RPG server, I don't particularly want that. I am trying to set up an If statement where if a player has blocks around him within a radius of 3 or so it will display "there is no room for your horse, instead of spawning it."
any help is appreciated
here is my current code(sorry that the code is quite long to read):
package io.github.bxnie.events;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Donkey;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Horse.Color;
import org.bukkit.entity.Horse.Variant;
import org.bukkit.entity.Llama;
import org.bukkit.entity.Player;
import org.bukkit.entity.SkeletonHorse;
import org.bukkit.entity.ZombieHorse;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.vehicle.VehicleExitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitScheduler;
import io.github.bxnie.FiorePlugin;
public class HorseSpawn implements Listener {
private HashMap<UUID, Long> cooldownwhite = new HashMap<UUID, Long>();
private HashMap<UUID, Long> horsecombat = new HashMap<UUID, Long>();
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
if(e.getAction() == Action.RIGHT_CLICK_AIR){
Player p = e.getPlayer();
ItemStack item = e.getItem();
if(!(item.getType() == Material.SADDLE)) {
return;
} else {
if(item.getItemMeta().getDisplayName().equals(ChatColor.WHITE + "White Horse")) {
if (horsecombat.containsKey(p.getUniqueId()) && horsecombat.get(p.getUniqueId()) > System.currentTimeMillis()) {
e.setCancelled(true);
p.sendMessage(ChatColor.RED + "Your horse is afraid to come out..");
} else {
if(cooldownwhite.containsKey(p.getUniqueId()) && cooldownwhite.get(p.getUniqueId()) > System.currentTimeMillis()) {
e.setCancelled(true);
long remainingTime = cooldownwhite.get(p.getUniqueId()) - System.currentTimeMillis();
p.sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.RED + "Horses" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + ChatColor.ITALIC + " You cannot spawn your horse for another " + ChatColor.RED + ChatColor.ITALIC + remainingTime/1000 + ChatColor.GRAY + ChatColor.ITALIC + " seconds");
} else {
cooldownwhite.put(p.getUniqueId(), System.currentTimeMillis() + (10 * 1000));
if(item.getItemMeta().hasLore()) {
if (p.hasPermission("fh.skin.skeletonactive") || p.hasPermission("fh.skin.zombieactive")) {
if (p.hasPermission("fh.skin.skeletonactive")) {
SkeletonHorse horsewhite = (SkeletonHorse) p.getWorld().spawn(p.getLocation(), SkeletonHorse.class);
horsewhite.setAdult();
horsewhite.setTamed(true);
horsewhite.setOwner(p);
horsewhite.getInventory().setSaddle(new ItemStack(Material.SADDLE));
horsewhite.setPassenger(p);
horsewhite.setJumpStrength(1.2);
horsewhite.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.65);
horsewhite.setInvulnerable(true);
horsewhite.setCustomName(item.getItemMeta().getLore().get(2));
horsewhite.setCustomNameVisible(true);
}
if (p.hasPermission("fh.skin.zombieactive")) {
ZombieHorse horsewhite = (ZombieHorse) p.getWorld().spawn(p.getLocation(), ZombieHorse.class);
horsewhite.setAdult();
horsewhite.setTamed(true);
horsewhite.setOwner(p);
horsewhite.getInventory().setSaddle(new ItemStack(Material.SADDLE));
horsewhite.setPassenger(p);
horsewhite.setJumpStrength(1.2);
horsewhite.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.65);
horsewhite.setInvulnerable(true);
horsewhite.setCustomName(item.getItemMeta().getLore().get(2));
horsewhite.setCustomNameVisible(true);
}
} else {
Horse horsewhite = (Horse) p.getWorld().spawn(p.getLocation(), Horse.class);
horsewhite.setAdult();
horsewhite.setTamed(true);
horsewhite.setOwner(p);
horsewhite.getInventory().setSaddle(new ItemStack(Material.SADDLE));
horsewhite.setPassenger(p);
horsewhite.setJumpStrength(1.2);
horsewhite.setColor(Color.WHITE);
horsewhite.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.65);
horsewhite.setInvulnerable(true);
horsewhite.setCustomName(item.getItemMeta().getLore().get(2));
horsewhite.setCustomNameVisible(true);
}
}
}
}
}
}
}
}
@EventHandler
public void onPLayerDismount(VehicleExitEvent e) {
if(e.getExited() instanceof Player) {
if(e.getVehicle() instanceof Horse) {
Horse horse = (Horse) e.getVehicle();
if(horse.getCustomName() != null) {
horse.remove();
}
}
}
}
@EventHandler
public void CombatChecker(EntityDamageByEntityEvent e) {
if ((e.getEntity() instanceof Player) && (e.getDamager() instanceof Player)) {
final Player player = (Player) e.getDamager();
final Player target = (Player) e.getEntity();
horsecombat.remove(player.getUniqueId());
horsecombat.remove(target.getUniqueId());
horsecombat.put(player.getUniqueId(), System.currentTimeMillis() + (15 * 1000));
horsecombat.put(target.getUniqueId(), System.currentTimeMillis() + (15 * 1000));
}
}
}
minecraft bukkit
add a comment |
I need to know if there is a way to check if there are any blocks within a radius of 3 around the user(NOT ABOVE OR BELOW). At the moment there is a bug in the game where if you spawn in a horse right next to a wall, you glitch through it. and on an RPG server, I don't particularly want that. I am trying to set up an If statement where if a player has blocks around him within a radius of 3 or so it will display "there is no room for your horse, instead of spawning it."
any help is appreciated
here is my current code(sorry that the code is quite long to read):
package io.github.bxnie.events;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Donkey;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Horse.Color;
import org.bukkit.entity.Horse.Variant;
import org.bukkit.entity.Llama;
import org.bukkit.entity.Player;
import org.bukkit.entity.SkeletonHorse;
import org.bukkit.entity.ZombieHorse;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.vehicle.VehicleExitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitScheduler;
import io.github.bxnie.FiorePlugin;
public class HorseSpawn implements Listener {
private HashMap<UUID, Long> cooldownwhite = new HashMap<UUID, Long>();
private HashMap<UUID, Long> horsecombat = new HashMap<UUID, Long>();
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
if(e.getAction() == Action.RIGHT_CLICK_AIR){
Player p = e.getPlayer();
ItemStack item = e.getItem();
if(!(item.getType() == Material.SADDLE)) {
return;
} else {
if(item.getItemMeta().getDisplayName().equals(ChatColor.WHITE + "White Horse")) {
if (horsecombat.containsKey(p.getUniqueId()) && horsecombat.get(p.getUniqueId()) > System.currentTimeMillis()) {
e.setCancelled(true);
p.sendMessage(ChatColor.RED + "Your horse is afraid to come out..");
} else {
if(cooldownwhite.containsKey(p.getUniqueId()) && cooldownwhite.get(p.getUniqueId()) > System.currentTimeMillis()) {
e.setCancelled(true);
long remainingTime = cooldownwhite.get(p.getUniqueId()) - System.currentTimeMillis();
p.sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.RED + "Horses" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + ChatColor.ITALIC + " You cannot spawn your horse for another " + ChatColor.RED + ChatColor.ITALIC + remainingTime/1000 + ChatColor.GRAY + ChatColor.ITALIC + " seconds");
} else {
cooldownwhite.put(p.getUniqueId(), System.currentTimeMillis() + (10 * 1000));
if(item.getItemMeta().hasLore()) {
if (p.hasPermission("fh.skin.skeletonactive") || p.hasPermission("fh.skin.zombieactive")) {
if (p.hasPermission("fh.skin.skeletonactive")) {
SkeletonHorse horsewhite = (SkeletonHorse) p.getWorld().spawn(p.getLocation(), SkeletonHorse.class);
horsewhite.setAdult();
horsewhite.setTamed(true);
horsewhite.setOwner(p);
horsewhite.getInventory().setSaddle(new ItemStack(Material.SADDLE));
horsewhite.setPassenger(p);
horsewhite.setJumpStrength(1.2);
horsewhite.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.65);
horsewhite.setInvulnerable(true);
horsewhite.setCustomName(item.getItemMeta().getLore().get(2));
horsewhite.setCustomNameVisible(true);
}
if (p.hasPermission("fh.skin.zombieactive")) {
ZombieHorse horsewhite = (ZombieHorse) p.getWorld().spawn(p.getLocation(), ZombieHorse.class);
horsewhite.setAdult();
horsewhite.setTamed(true);
horsewhite.setOwner(p);
horsewhite.getInventory().setSaddle(new ItemStack(Material.SADDLE));
horsewhite.setPassenger(p);
horsewhite.setJumpStrength(1.2);
horsewhite.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.65);
horsewhite.setInvulnerable(true);
horsewhite.setCustomName(item.getItemMeta().getLore().get(2));
horsewhite.setCustomNameVisible(true);
}
} else {
Horse horsewhite = (Horse) p.getWorld().spawn(p.getLocation(), Horse.class);
horsewhite.setAdult();
horsewhite.setTamed(true);
horsewhite.setOwner(p);
horsewhite.getInventory().setSaddle(new ItemStack(Material.SADDLE));
horsewhite.setPassenger(p);
horsewhite.setJumpStrength(1.2);
horsewhite.setColor(Color.WHITE);
horsewhite.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.65);
horsewhite.setInvulnerable(true);
horsewhite.setCustomName(item.getItemMeta().getLore().get(2));
horsewhite.setCustomNameVisible(true);
}
}
}
}
}
}
}
}
@EventHandler
public void onPLayerDismount(VehicleExitEvent e) {
if(e.getExited() instanceof Player) {
if(e.getVehicle() instanceof Horse) {
Horse horse = (Horse) e.getVehicle();
if(horse.getCustomName() != null) {
horse.remove();
}
}
}
}
@EventHandler
public void CombatChecker(EntityDamageByEntityEvent e) {
if ((e.getEntity() instanceof Player) && (e.getDamager() instanceof Player)) {
final Player player = (Player) e.getDamager();
final Player target = (Player) e.getEntity();
horsecombat.remove(player.getUniqueId());
horsecombat.remove(target.getUniqueId());
horsecombat.put(player.getUniqueId(), System.currentTimeMillis() + (15 * 1000));
horsecombat.put(target.getUniqueId(), System.currentTimeMillis() + (15 * 1000));
}
}
}
minecraft bukkit
You can get the player's location withplayer.getLocation()
. Use that as a start position and loop x blocks (your radius) from it
– Squiddie
Nov 21 '18 at 12:45
thankyou ill give it a shot
– Ben Parkes
Nov 21 '18 at 23:41
add a comment |
I need to know if there is a way to check if there are any blocks within a radius of 3 around the user(NOT ABOVE OR BELOW). At the moment there is a bug in the game where if you spawn in a horse right next to a wall, you glitch through it. and on an RPG server, I don't particularly want that. I am trying to set up an If statement where if a player has blocks around him within a radius of 3 or so it will display "there is no room for your horse, instead of spawning it."
any help is appreciated
here is my current code(sorry that the code is quite long to read):
package io.github.bxnie.events;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Donkey;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Horse.Color;
import org.bukkit.entity.Horse.Variant;
import org.bukkit.entity.Llama;
import org.bukkit.entity.Player;
import org.bukkit.entity.SkeletonHorse;
import org.bukkit.entity.ZombieHorse;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.vehicle.VehicleExitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitScheduler;
import io.github.bxnie.FiorePlugin;
public class HorseSpawn implements Listener {
private HashMap<UUID, Long> cooldownwhite = new HashMap<UUID, Long>();
private HashMap<UUID, Long> horsecombat = new HashMap<UUID, Long>();
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
if(e.getAction() == Action.RIGHT_CLICK_AIR){
Player p = e.getPlayer();
ItemStack item = e.getItem();
if(!(item.getType() == Material.SADDLE)) {
return;
} else {
if(item.getItemMeta().getDisplayName().equals(ChatColor.WHITE + "White Horse")) {
if (horsecombat.containsKey(p.getUniqueId()) && horsecombat.get(p.getUniqueId()) > System.currentTimeMillis()) {
e.setCancelled(true);
p.sendMessage(ChatColor.RED + "Your horse is afraid to come out..");
} else {
if(cooldownwhite.containsKey(p.getUniqueId()) && cooldownwhite.get(p.getUniqueId()) > System.currentTimeMillis()) {
e.setCancelled(true);
long remainingTime = cooldownwhite.get(p.getUniqueId()) - System.currentTimeMillis();
p.sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.RED + "Horses" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + ChatColor.ITALIC + " You cannot spawn your horse for another " + ChatColor.RED + ChatColor.ITALIC + remainingTime/1000 + ChatColor.GRAY + ChatColor.ITALIC + " seconds");
} else {
cooldownwhite.put(p.getUniqueId(), System.currentTimeMillis() + (10 * 1000));
if(item.getItemMeta().hasLore()) {
if (p.hasPermission("fh.skin.skeletonactive") || p.hasPermission("fh.skin.zombieactive")) {
if (p.hasPermission("fh.skin.skeletonactive")) {
SkeletonHorse horsewhite = (SkeletonHorse) p.getWorld().spawn(p.getLocation(), SkeletonHorse.class);
horsewhite.setAdult();
horsewhite.setTamed(true);
horsewhite.setOwner(p);
horsewhite.getInventory().setSaddle(new ItemStack(Material.SADDLE));
horsewhite.setPassenger(p);
horsewhite.setJumpStrength(1.2);
horsewhite.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.65);
horsewhite.setInvulnerable(true);
horsewhite.setCustomName(item.getItemMeta().getLore().get(2));
horsewhite.setCustomNameVisible(true);
}
if (p.hasPermission("fh.skin.zombieactive")) {
ZombieHorse horsewhite = (ZombieHorse) p.getWorld().spawn(p.getLocation(), ZombieHorse.class);
horsewhite.setAdult();
horsewhite.setTamed(true);
horsewhite.setOwner(p);
horsewhite.getInventory().setSaddle(new ItemStack(Material.SADDLE));
horsewhite.setPassenger(p);
horsewhite.setJumpStrength(1.2);
horsewhite.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.65);
horsewhite.setInvulnerable(true);
horsewhite.setCustomName(item.getItemMeta().getLore().get(2));
horsewhite.setCustomNameVisible(true);
}
} else {
Horse horsewhite = (Horse) p.getWorld().spawn(p.getLocation(), Horse.class);
horsewhite.setAdult();
horsewhite.setTamed(true);
horsewhite.setOwner(p);
horsewhite.getInventory().setSaddle(new ItemStack(Material.SADDLE));
horsewhite.setPassenger(p);
horsewhite.setJumpStrength(1.2);
horsewhite.setColor(Color.WHITE);
horsewhite.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.65);
horsewhite.setInvulnerable(true);
horsewhite.setCustomName(item.getItemMeta().getLore().get(2));
horsewhite.setCustomNameVisible(true);
}
}
}
}
}
}
}
}
@EventHandler
public void onPLayerDismount(VehicleExitEvent e) {
if(e.getExited() instanceof Player) {
if(e.getVehicle() instanceof Horse) {
Horse horse = (Horse) e.getVehicle();
if(horse.getCustomName() != null) {
horse.remove();
}
}
}
}
@EventHandler
public void CombatChecker(EntityDamageByEntityEvent e) {
if ((e.getEntity() instanceof Player) && (e.getDamager() instanceof Player)) {
final Player player = (Player) e.getDamager();
final Player target = (Player) e.getEntity();
horsecombat.remove(player.getUniqueId());
horsecombat.remove(target.getUniqueId());
horsecombat.put(player.getUniqueId(), System.currentTimeMillis() + (15 * 1000));
horsecombat.put(target.getUniqueId(), System.currentTimeMillis() + (15 * 1000));
}
}
}
minecraft bukkit
I need to know if there is a way to check if there are any blocks within a radius of 3 around the user(NOT ABOVE OR BELOW). At the moment there is a bug in the game where if you spawn in a horse right next to a wall, you glitch through it. and on an RPG server, I don't particularly want that. I am trying to set up an If statement where if a player has blocks around him within a radius of 3 or so it will display "there is no room for your horse, instead of spawning it."
any help is appreciated
here is my current code(sorry that the code is quite long to read):
package io.github.bxnie.events;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Donkey;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Horse.Color;
import org.bukkit.entity.Horse.Variant;
import org.bukkit.entity.Llama;
import org.bukkit.entity.Player;
import org.bukkit.entity.SkeletonHorse;
import org.bukkit.entity.ZombieHorse;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.vehicle.VehicleExitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitScheduler;
import io.github.bxnie.FiorePlugin;
public class HorseSpawn implements Listener {
private HashMap<UUID, Long> cooldownwhite = new HashMap<UUID, Long>();
private HashMap<UUID, Long> horsecombat = new HashMap<UUID, Long>();
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
if(e.getAction() == Action.RIGHT_CLICK_AIR){
Player p = e.getPlayer();
ItemStack item = e.getItem();
if(!(item.getType() == Material.SADDLE)) {
return;
} else {
if(item.getItemMeta().getDisplayName().equals(ChatColor.WHITE + "White Horse")) {
if (horsecombat.containsKey(p.getUniqueId()) && horsecombat.get(p.getUniqueId()) > System.currentTimeMillis()) {
e.setCancelled(true);
p.sendMessage(ChatColor.RED + "Your horse is afraid to come out..");
} else {
if(cooldownwhite.containsKey(p.getUniqueId()) && cooldownwhite.get(p.getUniqueId()) > System.currentTimeMillis()) {
e.setCancelled(true);
long remainingTime = cooldownwhite.get(p.getUniqueId()) - System.currentTimeMillis();
p.sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.RED + "Horses" + ChatColor.DARK_GRAY + "]" + ChatColor.GRAY + ChatColor.ITALIC + " You cannot spawn your horse for another " + ChatColor.RED + ChatColor.ITALIC + remainingTime/1000 + ChatColor.GRAY + ChatColor.ITALIC + " seconds");
} else {
cooldownwhite.put(p.getUniqueId(), System.currentTimeMillis() + (10 * 1000));
if(item.getItemMeta().hasLore()) {
if (p.hasPermission("fh.skin.skeletonactive") || p.hasPermission("fh.skin.zombieactive")) {
if (p.hasPermission("fh.skin.skeletonactive")) {
SkeletonHorse horsewhite = (SkeletonHorse) p.getWorld().spawn(p.getLocation(), SkeletonHorse.class);
horsewhite.setAdult();
horsewhite.setTamed(true);
horsewhite.setOwner(p);
horsewhite.getInventory().setSaddle(new ItemStack(Material.SADDLE));
horsewhite.setPassenger(p);
horsewhite.setJumpStrength(1.2);
horsewhite.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.65);
horsewhite.setInvulnerable(true);
horsewhite.setCustomName(item.getItemMeta().getLore().get(2));
horsewhite.setCustomNameVisible(true);
}
if (p.hasPermission("fh.skin.zombieactive")) {
ZombieHorse horsewhite = (ZombieHorse) p.getWorld().spawn(p.getLocation(), ZombieHorse.class);
horsewhite.setAdult();
horsewhite.setTamed(true);
horsewhite.setOwner(p);
horsewhite.getInventory().setSaddle(new ItemStack(Material.SADDLE));
horsewhite.setPassenger(p);
horsewhite.setJumpStrength(1.2);
horsewhite.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.65);
horsewhite.setInvulnerable(true);
horsewhite.setCustomName(item.getItemMeta().getLore().get(2));
horsewhite.setCustomNameVisible(true);
}
} else {
Horse horsewhite = (Horse) p.getWorld().spawn(p.getLocation(), Horse.class);
horsewhite.setAdult();
horsewhite.setTamed(true);
horsewhite.setOwner(p);
horsewhite.getInventory().setSaddle(new ItemStack(Material.SADDLE));
horsewhite.setPassenger(p);
horsewhite.setJumpStrength(1.2);
horsewhite.setColor(Color.WHITE);
horsewhite.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(0.65);
horsewhite.setInvulnerable(true);
horsewhite.setCustomName(item.getItemMeta().getLore().get(2));
horsewhite.setCustomNameVisible(true);
}
}
}
}
}
}
}
}
@EventHandler
public void onPLayerDismount(VehicleExitEvent e) {
if(e.getExited() instanceof Player) {
if(e.getVehicle() instanceof Horse) {
Horse horse = (Horse) e.getVehicle();
if(horse.getCustomName() != null) {
horse.remove();
}
}
}
}
@EventHandler
public void CombatChecker(EntityDamageByEntityEvent e) {
if ((e.getEntity() instanceof Player) && (e.getDamager() instanceof Player)) {
final Player player = (Player) e.getDamager();
final Player target = (Player) e.getEntity();
horsecombat.remove(player.getUniqueId());
horsecombat.remove(target.getUniqueId());
horsecombat.put(player.getUniqueId(), System.currentTimeMillis() + (15 * 1000));
horsecombat.put(target.getUniqueId(), System.currentTimeMillis() + (15 * 1000));
}
}
}
minecraft bukkit
minecraft bukkit
asked Nov 21 '18 at 0:44
Ben ParkesBen Parkes
84
84
You can get the player's location withplayer.getLocation()
. Use that as a start position and loop x blocks (your radius) from it
– Squiddie
Nov 21 '18 at 12:45
thankyou ill give it a shot
– Ben Parkes
Nov 21 '18 at 23:41
add a comment |
You can get the player's location withplayer.getLocation()
. Use that as a start position and loop x blocks (your radius) from it
– Squiddie
Nov 21 '18 at 12:45
thankyou ill give it a shot
– Ben Parkes
Nov 21 '18 at 23:41
You can get the player's location with
player.getLocation()
. Use that as a start position and loop x blocks (your radius) from it– Squiddie
Nov 21 '18 at 12:45
You can get the player's location with
player.getLocation()
. Use that as a start position and loop x blocks (your radius) from it– Squiddie
Nov 21 '18 at 12:45
thankyou ill give it a shot
– Ben Parkes
Nov 21 '18 at 23:41
thankyou ill give it a shot
– Ben Parkes
Nov 21 '18 at 23:41
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53403755%2fbukkit-horse-disabling-horse-spawn-around-blocks%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53403755%2fbukkit-horse-disabling-horse-spawn-around-blocks%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You can get the player's location with
player.getLocation()
. Use that as a start position and loop x blocks (your radius) from it– Squiddie
Nov 21 '18 at 12:45
thankyou ill give it a shot
– Ben Parkes
Nov 21 '18 at 23:41