diff --git a/changelog.txt b/changelog.txt index 0d00c87..853f3a3 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,13 @@ +Version 4.3.47 + Fixed horse location verification + Fixed issue where horses would become unregistered on player quit/chuck despawn. + +Version 4.3.46 + Made max horse speeds customizable + +Version 4.3.45b + Quickfix: Fixed autotaming util and permadeath systems + Version 4.3.45 Added ability to disable scoreboard messages for chat or for scoreboard. Added /h banishfor diff --git a/config.yml b/config.yml index c68afbd..1d7acac 100644 --- a/config.yml +++ b/config.yml @@ -96,4 +96,10 @@ RequirePermissionToRide: false disable_basegame_taming: false disable_StatsInChat: false -disable_StatsInScoreboard: false \ No newline at end of file +disable_StatsInScoreboard: false + +horsestats: + default_min_speed: 0.1125 + default_max_speed: 0.3375 + default_min_jump: 0.4 + default_max_jump: 1.0 \ No newline at end of file diff --git a/plugin.yml b/plugin.yml index 9dbc9bc..f3cec08 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: mcMMOHorse main: com.blueskullgames.horserpg.HorseRPG -version: 4.3.46 +version: 4.3.47 description: An awesome role-playing plugin for horses. authors: [GetGoodKid,Zombie_Striker] website: http://www.blueskullgames.com diff --git a/src/com/blueskullgames/horserpg/HorseRPG.java b/src/com/blueskullgames/horserpg/HorseRPG.java index 2cb2766..3e2133b 100644 --- a/src/com/blueskullgames/horserpg/HorseRPG.java +++ b/src/com/blueskullgames/horserpg/HorseRPG.java @@ -128,8 +128,8 @@ public class HorseRPG extends JavaPlugin { public static ConfigAccessor config; public static Economy econ; public static HashMap hSpawnedHorses; - public static HashMap pCurrentHorse; - public static HashMap offers; + public static HashMap pCurrentHorse; + public static HashMap offers; public static HashMap> ownedHorses; public static HashSet horses; public static HorseRPG instance; @@ -300,8 +300,8 @@ public static RPGHorse getHorseSpawned(Player p, String[] args, int offset) { */ public static RPGHorse currentHorse(Player p, String[] args, int offset) { if (args.length <= offset) { - if (pCurrentHorse.containsKey(p)) { - return pCurrentHorse.get(p); + if (pCurrentHorse.containsKey(p.getUniqueId())) { + return pCurrentHorse.get(p.getUniqueId()); } else if (ownedHorses.containsKey(p.getName()) && ownedHorses.get(p.getName()).size() > 0) return ownedHorses.get(p.getName()).first(); @@ -699,7 +699,7 @@ public static void claimHorse(CommandSender sender) { h.horse = horse; h.setName(h.name); - pCurrentHorse.put(p, h); + pCurrentHorse.put(p.getUniqueId(), h); hSpawnedHorses.put(horse, h); if (!ownedHorses.containsKey(p.getName())) ownedHorses.put(p.getName(), new TreeSet()); @@ -724,21 +724,21 @@ public static void buyHorse(CommandSender sender, boolean buy) { } Player p = (Player) sender; - if (!offers.containsKey(p)) { + if (!offers.containsKey(p.getUniqueId())) { msg(p, NO_OFFER_PENDING); return; } if (!buy) { - offers.remove(p); + offers.remove(p.getUniqueId()); msg(p, OFFER_DECLINED); return; } - if (pCurrentHorse.containsKey(p)) { + if (pCurrentHorse.containsKey(p.getUniqueId())) { msg(p, BANISH_HORSE); return; } - RPGHorse h = offers.get(p); + RPGHorse h = offers.get(p.getUniqueId()); EconomyResponse er1; try { er1 = econ.withdrawPlayer(p, h.price); @@ -762,7 +762,7 @@ public static void buyHorse(CommandSender sender, boolean buy) { for (Player seller : instance.getServer().getOnlinePlayers()) { if (seller.getName().equalsIgnoreCase(h.owner)) { - pCurrentHorse.remove(seller); + pCurrentHorse.remove(seller.getUniqueId()); msg(seller, "&b" + h.name + "&a sold to &b" + p.getName() + "&a for &b" + econ.format(h.price)); break; } @@ -770,7 +770,7 @@ public static void buyHorse(CommandSender sender, boolean buy) { h.banish(); msg(p, "&b" + h.name + "&a bought from &b" + h.owner + "&a for &b" + econ.format(h.price)); h.owner = p.getName(); - offers.remove(p); + offers.remove(p.getUniqueId()); } /** @@ -789,7 +789,7 @@ public static void sellHorse(CommandSender sender, String[] args) { return; } Player p = (Player) sender; - if (!pCurrentHorse.containsKey(p)) { + if (!pCurrentHorse.containsKey(p.getUniqueId())) { msg(p, "&aPlease summon the horse first."); return; } @@ -823,9 +823,9 @@ public static void sellHorse(CommandSender sender, String[] args) { return; } - RPGHorse h = pCurrentHorse.get(p); + RPGHorse h = pCurrentHorse.get(p.getUniqueId()); h.price = cost; - offers.put(buyer, h); + offers.put(buyer.getUniqueId(), h); Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(instance, new OfferTask(p), 1200); msg(p, "&aOffering &b" + h.name + "&a at &b" + econ.format(cost) + "&a for &b60 seconds."); @@ -851,7 +851,7 @@ public static void summonHorse(CommandSender sender, String[] args) { * "&a is already summoned."); return; } */ - RPGHorse h = getHorseNotSpawned(p, args, 1); + RPGHorse h = null;// getHorseNotSpawned(p, args, 1); if (!hasHorses(p)) { h = null; if (freeHorse) { @@ -872,6 +872,8 @@ public static void summonHorse(CommandSender sender, String[] args) { msg(p, NO_HORSES); } } + } else { + h = getHorseNotSpawned(p, args, 1); } if (h != null) { if (hSpawnedHorses.containsKey(h.horse)) { @@ -896,7 +898,7 @@ public static void summonHorse(CommandSender sender, String[] args) { } } h.summon(p); - pCurrentHorse.put(p, h); + pCurrentHorse.put(p.getUniqueId(), h); } } } @@ -928,12 +930,12 @@ public static void banishHorse(CommandSender sender, String[] args, boolean forc p = (Player) sender; } - if (!pCurrentHorse.containsKey(p)) { + if (!pCurrentHorse.containsKey(p.getUniqueId())) { msg(sender, NO_HORSE_SUMMONED); return; } RPGHorse horse = (forced ? args.length > 2 : args.length > 1) ? getHorseSpawned(p, args, forced ? 2 : 1) - : pCurrentHorse.get(p); + : pCurrentHorse.get(p.getUniqueId()); if (horse == null) { msg(sender, NO_HORSE_SUMMONED); return; @@ -942,10 +944,6 @@ public static void banishHorse(CommandSender sender, String[] args, boolean forc msg(sender, BANISH_LOADED_CHUNK); return; } - if ((sender instanceof Player && horse.horse.getLocation().getWorld() != ((Player) sender).getWorld())) { - msg(sender, BANISH_LOADED_CHUNK); - return; - } if (forced) { if (p.getWorld() == horse.horse.getWorld()) { if (p.getLocation().distanceSquared(horse.horse.getLocation()) >= 10000) { @@ -979,11 +977,11 @@ public static void banishHorse(CommandSender sender, String[] args, boolean forc } } horse.banish(); - if (pCurrentHorse.get(p) == horse) { - pCurrentHorse.remove(p); + if (pCurrentHorse.get(p.getUniqueId()) == horse) { + pCurrentHorse.remove(p.getUniqueId()); for (RPGHorse others : ownedHorses.get(p.getName())) { if (hSpawnedHorses.containsKey(others.horse)) { - pCurrentHorse.put(p, others); + pCurrentHorse.put(p.getUniqueId(), others); break; } } @@ -1107,7 +1105,7 @@ public static void setHorseName(CommandSender sender, String[] args) { return; } - RPGHorse h = pCurrentHorse.get(p); + RPGHorse h = pCurrentHorse.get(p.getUniqueId()); if (h == null) { msg(p, NO_HORSE_SUMMONED); return; @@ -1144,7 +1142,7 @@ public static void setHorseSpeed(CommandSender sender, String[] args) { return; } - RPGHorse h = pCurrentHorse.get(p); + RPGHorse h = pCurrentHorse.get(p.getUniqueId()); if (h == null) { msg(p, NO_HORSE_SUMMONED); return; @@ -1153,13 +1151,12 @@ public static void setHorseSpeed(CommandSender sender, String[] args) { // String oldname = h.name; if (args[2].equalsIgnoreCase("random")) - h.generic_speed = Math.random() * speed; + h.generic_speed = speed; else { h.generic_speed = Double.parseDouble(args[2]); } if (h.horse != null) { - if (h.generic_speed > 0) - RPGHorse.attributeUtil.setSpeed(h.horse, h.generic_speed); + RPGHorse.attributeUtil.setSpeed(h.horse, h.generic_speed); } // "&aHorse %oldname% has been changed to %newname%" msg(p, ChangeSpeedHorse.replace("%oldname%", h.name).replace("%speed%", "" + h.generic_speed)); @@ -1182,7 +1179,7 @@ public static void setHorseJump(CommandSender sender, String[] args) { return; } - RPGHorse h = pCurrentHorse.get(p); + RPGHorse h = pCurrentHorse.get(p.getUniqueId()); if (h == null) { msg(p, NO_HORSE_SUMMONED); return; @@ -1191,14 +1188,13 @@ public static void setHorseJump(CommandSender sender, String[] args) { // String oldname = h.name; if (args[2].equalsIgnoreCase("random")) - h.generic_jump = Math.random() * jump; + h.generic_jump = jump; else { h.generic_jump = Double.parseDouble(args[2]); } if (h.horse != null) { - if (h.generic_jump > 0) - RPGHorse.attributeUtil.setJumpHeight(h.horse, h.generic_jump); + RPGHorse.attributeUtil.setJumpHeight(h.horse, h.generic_jump); } // "&aHorse %oldname% has been changed to %newname%" @@ -1222,7 +1218,7 @@ public static void setHorseColor(CommandSender sender, String[] args) { return; } - RPGHorse h = pCurrentHorse.get(p); + RPGHorse h = pCurrentHorse.get(p.getUniqueId()); if (h == null) { msg(p, NO_HORSE_SUMMONED); return; @@ -1262,7 +1258,7 @@ public static void setHorseStyle(CommandSender sender, String[] args) { return; } - RPGHorse h = pCurrentHorse.get(p); + RPGHorse h = pCurrentHorse.get(p.getUniqueId()); if (h == null) { msg(p, NO_HORSE_SUMMONED); return; @@ -1303,7 +1299,7 @@ public static void setHorseVariant(CommandSender sender, String[] args) { return; } - RPGHorse h = pCurrentHorse.get(p); + RPGHorse h = pCurrentHorse.get(p.getUniqueId()); if (h == null) { msg(p, NO_HORSE_SUMMONED); return; @@ -1405,9 +1401,9 @@ public static void createHorse(CommandSender sender, String[] args, boolean gift hName += " " + args[i]; h.setName(hName); } - if (!pCurrentHorse.containsKey(p)) { + if (!pCurrentHorse.containsKey(p.getUniqueId())) { h.summon(p); - pCurrentHorse.put(p, h); + pCurrentHorse.put(p.getUniqueId(), h); } msg(p, HORSE_BRED); } @@ -1432,12 +1428,16 @@ public static void deleteHorse(CommandSender sender, String[] args) { if (h == null) return; - pCurrentHorse.remove(p); + pCurrentHorse.remove(p.getUniqueId()); h.banish(); ownedHorses.get(p.getName()).remove(h); horses.remove(h); // Test if this removes horses. h_config.removeHorse(h); + if (hSpawnedHorses.containsKey(h.horse)) { + h.horse.remove(); + hSpawnedHorses.remove(h.horse); + } msg(p, "&b" + h.name + "&a won't be bothering you anymore."); } @@ -1591,9 +1591,9 @@ private void initVariables() { if (!config.getConfig().contains("enable-economy")) config.overwriteConfig(); - offers = new HashMap(); + offers = new HashMap(); ownedHorses = new HashMap>(); - pCurrentHorse = new HashMap(); + pCurrentHorse = new HashMap(); hSpawnedHorses = new HashMap(); horses = new HashSet(); } @@ -1689,6 +1689,15 @@ private void initConfig() { if (fc.contains("disable_StatsInChat")) DisableshowStatsInChat = fc.getBoolean("disable_StatsInChat"); + if (fc.contains("horsestats.default_min_speed")) + RPGHorse.minSpeed = fc.getDouble("horsestats.default_min_speed"); + if (fc.contains("horsestats.default_max_speed")) + RPGHorse.maxSpeed = fc.getDouble("horsestats.default_max_speed"); + if (fc.contains("horsestats.default_min_jump")) + RPGHorse.minJump = fc.getDouble("horsestats.default_min_jump"); + if (fc.contains("horsestats.default_max_jump")) + RPGHorse.maxJump = fc.getDouble("horsestats.default_max_jump"); + /* * if (!h_config.containsGlobalVariable(Keys.G_nobanish.toString())) { * h_config.setGlobalVar(Keys.G_nobanish.toString(), false); }else { @@ -1834,14 +1843,14 @@ private void initHorses() { double speed = rs.getDouble("defaultSpeed"); double jump = rs.getDouble("defaultJump"); - if (jump <= 0) + if (jump <= 0 || jump > RPGHorse.maxJump) jump = RPGHorse.getRandomJump(); - if (speed <= 0) + if (speed <= 0 || speed > RPGHorse.maxSpeed) speed = RPGHorse.getRandomSpeed(); RPGHorse h = new RPGHorse(rs.getString("name"), owner, color, style, variant, rs.getInt("godmode") == 1, rs.getInt("swiftnessXP"), rs.getInt("agilityXP"), - rs.getInt("vitalityXP"), rs.getInt("wrathXP"), null, speed, jump, rs.getInt("sex") == 0); + rs.getInt("vitalityXP"), rs.getInt("wrathXP"), null, jump, speed, rs.getInt("sex") == 0); // TODO:Tempfix. Since I don't want users to use the sql, just set the dfefault // value to 2.25 @@ -1969,8 +1978,8 @@ public List onTabComplete(CommandSender sender, Command command, String } if (args[0].equalsIgnoreCase("banishFor")) { if (args.length == 2) { - for (Player player : pCurrentHorse.keySet()) { - a(r, player.getName(), args[1]); + for (UUID player : pCurrentHorse.keySet()) { + a(r, Bukkit.getPlayer(player).getName(), args[1]); } } else { if (ownedHorses.containsKey(sender.getName())) @@ -2229,5 +2238,4 @@ public static void showLeaderBoard(CommandSender sender, String[] args) { Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(instance, new ScoreboardTask(p, oldsb), 200); } } - } diff --git a/src/com/blueskullgames/horserpg/RPGHorse.java b/src/com/blueskullgames/horserpg/RPGHorse.java index 6efd0ee..c7be974 100644 --- a/src/com/blueskullgames/horserpg/RPGHorse.java +++ b/src/com/blueskullgames/horserpg/RPGHorse.java @@ -80,12 +80,18 @@ public class RPGHorse implements Comparable { public double generic_speed = 0.25f; public double generic_jump = 0.7f; + public static double minSpeed = 0.1125; + public static double maxSpeed = 0.33; + public static double minJump = 0.4; + public static double maxJump = 1.0; + + public static double getRandomSpeed() { - return ((0.3375-0.1125)*Math.random())+0.1125; + return ((maxSpeed-minSpeed)*Math.random())+minSpeed; } public static double getRandomJump() { - return ((1.0-0.4)*Math.random())+0.4; + return ((maxJump-minJump)*Math.random())+minJump; } @@ -253,7 +259,7 @@ public RPGHorse(String name, String owner, Color color, Style style, Variant var */ public void setName(String newName) { int add = 0; - String testName = newName; + String testName = newName.replaceAll("\u00a7", "&"); if(newName.length() == 0) return; if (HorseRPG.ownedHorses.containsKey(owner)) diff --git a/src/com/blueskullgames/horserpg/configs/HorseConfigHandler.java b/src/com/blueskullgames/horserpg/configs/HorseConfigHandler.java index 30a5d54..5aa9baf 100644 --- a/src/com/blueskullgames/horserpg/configs/HorseConfigHandler.java +++ b/src/com/blueskullgames/horserpg/configs/HorseConfigHandler.java @@ -184,10 +184,10 @@ public RPGHorse getHorse(final String owner, String horseUUID) { ? config.getDouble("Horses." + owner + "." + rpguuids + Keys.sprint) : RPGHorse.getRandomSpeed(); - if (jumpPow >= 2.25) - jumpPow = 0.7; - if (sprintPow > 1) - sprintPow = 0.25; + if (jumpPow > RPGHorse.maxJump) + jumpPow = RPGHorse.getRandomJump(); + if (sprintPow > RPGHorse.maxSpeed) + sprintPow = RPGHorse.getRandomSpeed(); boolean sex = config.contains("Horses." + owner + "." + rpguuids + Keys.sex) ? config.getBoolean("Horses." + owner + "." + rpguuids + Keys.sex) @@ -236,7 +236,7 @@ public void run() { if (rpgHorse.horse != null) { HorseRPG.hSpawnedHorses.put(rpgHorse.horse, rpgHorse); if (Bukkit.getPlayer(owner) != null) - HorseRPG.pCurrentHorse.put(Bukkit.getPlayer(owner), rpgHorse); + HorseRPG.pCurrentHorse.put(Bukkit.getPlayer(owner).getUniqueId(), rpgHorse); } else { HorseRPG.instance.getLogger() .warning(ChatColor.RED + " The horse " + horsename + " for player " + owner diff --git a/src/com/blueskullgames/horserpg/listeners/HorseListener.java b/src/com/blueskullgames/horserpg/listeners/HorseListener.java index feec9da..3a0b4ec 100644 --- a/src/com/blueskullgames/horserpg/listeners/HorseListener.java +++ b/src/com/blueskullgames/horserpg/listeners/HorseListener.java @@ -159,7 +159,11 @@ public void onHorseDeath(EntityDeathEvent evt) { } if (HorseRPG.permanentDeath) { - HorseRPG.horses.remove(h); + if(HorseRPG.hSpawnedHorses.containsKey(h.horse)) { + //h.horse.remove(); + HorseRPG.hSpawnedHorses.remove(h.horse); + } + HorseRPG.horses.remove(h); //Remove the horse from the list of all horses }else { evt.getDrops().clear(); @@ -191,7 +195,7 @@ public void onHorseJump(HorseJumpEvent evt) { } catch (Exception | Error e) { p = (Player) horse.getPassenger(); } - RPGHorse h = HorseRPG.pCurrentHorse.get(p); + RPGHorse h = HorseRPG.pCurrentHorse.get(p.getUniqueId()); if (h != null) { if (evt.getPower() < 0.45) { Swiftness swiftness = h.swiftness; diff --git a/src/com/blueskullgames/horserpg/listeners/PlayerListener.java b/src/com/blueskullgames/horserpg/listeners/PlayerListener.java index 67b1b1f..be821f6 100644 --- a/src/com/blueskullgames/horserpg/listeners/PlayerListener.java +++ b/src/com/blueskullgames/horserpg/listeners/PlayerListener.java @@ -1,6 +1,8 @@ package com.blueskullgames.horserpg.listeners; -import org.bukkit.Material; +import java.util.UUID; + +import org.bukkit.*; import org.bukkit.entity.AbstractHorse; import org.bukkit.entity.Entity; import org.bukkit.entity.Horse; @@ -22,16 +24,35 @@ public class PlayerListener implements Listener { @EventHandler - public void onJoin(PlayerJoinEvent event) { + public void onJoin(final PlayerJoinEvent event) { // if(HorseRPG.banishonquit) // return; - for (Player p : HorseRPG.pCurrentHorse.keySet()) { - if (p.getUniqueId().equals(event.getPlayer().getUniqueId())) { - HorseRPG.pCurrentHorse.put(event.getPlayer(), HorseRPG.pCurrentHorse.get(p)); + for (UUID p : HorseRPG.pCurrentHorse.keySet()) { + if (p.equals(event.getPlayer().getUniqueId())) { + // HorseRPG.pCurrentHorse.put(event.getPlayer(), HorseRPG.pCurrentHorse.get(p)); break; } } + // if (HorseRPG.banishonquit) { + new BukkitRunnable() { + public void run() { + for (RPGHorse rpg : HorseRPG.ownedHorses.get(event.getPlayer().getName())) { + if (rpg.horse != null && !rpg.horse.isValid()) { + for (Entity e : rpg.horse.getNearbyEntities(30, 30, 30)) { + if (e.getType() == rpg.horse.getType() && e.getUniqueId().equals(rpg.horse.getUniqueId())) { + HorseRPG.hSpawnedHorses.put(e, HorseRPG.hSpawnedHorses.remove(rpg.horse)); + rpg.horse.remove(); + rpg.horse = e; + break; + } + } + } + } + } + }.runTaskLater(HorseRPG.instance, 2); + + // } } /** @@ -55,7 +76,7 @@ public void onPlayerMove(PlayerMoveEvent event) { if (!p.getLocation().getWorld().equals(event.getTo().getWorld())) return; - RPGHorse h = HorseRPG.pCurrentHorse.get(p); + RPGHorse h = HorseRPG.pCurrentHorse.get(p.getUniqueId()); if (h != null) h.travel(distance); } @@ -66,20 +87,16 @@ public void onPlayerMove(PlayerMoveEvent event) { **/ @EventHandler public void onPlayerQuit(PlayerQuitEvent evt) { - if (/* !HorseRPG.nobanishment || */HorseRPG.banishonquit) { + if (HorseRPG.banishonquit) { if (HorseRPG.ownedHorses.containsKey(evt.getPlayer().getName())) for (RPGHorse h : HorseRPG.ownedHorses.get(evt.getPlayer().getName())) { - if (h != null && h.horse != null && HorseRPG.hSpawnedHorses.containsKey(h.horse)) + if (h != null && h.horse != null && HorseRPG.hSpawnedHorses.containsKey(h.horse)) { HorseRPG.hSpawnedHorses.remove(h.horse).banish(); + } } } } - @EventHandler(priority = EventPriority.LOW) - public void onMountHorseEventHorse(PlayerInteractEntityEvent event) { - - } - /** * Player Feeding Horse Event **/ @@ -123,7 +140,7 @@ public void onPlayerFeedingHorse(PlayerInteractEntityEvent event) { public void run() { if (p.getVehicle() != null) if (p.getVehicle().equals(horse)) { - HorseRPG.pCurrentHorse.put(p, rpg); + HorseRPG.pCurrentHorse.put(p.getUniqueId(), rpg); } } }.runTaskLater(HorseRPG.instance, 2); diff --git a/src/com/blueskullgames/horserpg/tasks/OfferTask.java b/src/com/blueskullgames/horserpg/tasks/OfferTask.java index c908720..d4d14c6 100644 --- a/src/com/blueskullgames/horserpg/tasks/OfferTask.java +++ b/src/com/blueskullgames/horserpg/tasks/OfferTask.java @@ -17,6 +17,6 @@ public OfferTask(Player p) { @Override public void run() { - HorseRPG.offers.remove(p); + HorseRPG.offers.remove(p.getUniqueId()); } } \ No newline at end of file diff --git a/src/com/blueskullgames/horserpg/utils/ShopManager.java b/src/com/blueskullgames/horserpg/utils/ShopManager.java index f9fbcca..17ab835 100644 --- a/src/com/blueskullgames/horserpg/utils/ShopManager.java +++ b/src/com/blueskullgames/horserpg/utils/ShopManager.java @@ -90,8 +90,8 @@ public void onClickInv(InventoryClickEvent e) { HorseRPG.ownedHorses.put(e.getWhoClicked().getName(), new TreeSet()); HorseRPG.ownedHorses.get(e.getWhoClicked().getName()).add(horse); HorseRPG.horses.add(horse); - if (!HorseRPG.pCurrentHorse.containsKey(e.getWhoClicked())) { - HorseRPG.pCurrentHorse.put((Player) e.getWhoClicked(), horse); + if (!HorseRPG.pCurrentHorse.containsKey(e.getWhoClicked().getUniqueId())) { + HorseRPG.pCurrentHorse.put(((Player) e.getWhoClicked()).getUniqueId(), horse); } HorseRPG.msg(e.getWhoClicked(), HorseRPG.BOUGHT_HORSE + horse.name + "!"); HorseRPG.msg(e.getWhoClicked(), HorseRPG.BOUGHT_HORSE_EXP1); diff --git a/src/com/blueskullgames/horserpg/utils/TameToClaimListener.java b/src/com/blueskullgames/horserpg/utils/TameToClaimListener.java index bcfab75..e0f66aa 100644 --- a/src/com/blueskullgames/horserpg/utils/TameToClaimListener.java +++ b/src/com/blueskullgames/horserpg/utils/TameToClaimListener.java @@ -48,6 +48,10 @@ public void onTame(final PlayerInteractEntityEvent e) { return; } + if (HorseRPG.hSpawnedHorses.containsKey(e.getRightClicked())) { + return; + } + new BukkitRunnable() { int i = 0; @@ -58,10 +62,12 @@ public void run() { cancel(); } try { + if (((org.bukkit.entity.AbstractHorse) e.getRightClicked()).getPassenger() == null) { cancel(); return; } + if (((org.bukkit.entity.AbstractHorse) e.getRightClicked()).isTamed()) { if (((org.bukkit.entity.AbstractHorse) e.getRightClicked()).getInventory() .getSaddle() == null) { @@ -82,7 +88,7 @@ public void run() { takenfrom = e.getPlayer().getInventory().first(Material.SADDLE); if (takenfrom > -1) { used = e.getPlayer().getInventory().getItem(takenfrom); - slot=takenfrom; + slot = takenfrom; } } if (used != null) {