diff --git a/changelog.txt b/changelog.txt index 1b85612..263b8bb 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,12 @@ +Version 4.3.42 + Fixed horse speeds when generating a new horse. + Fixed ChnestedHorse inventory + Fixed /h set command messages + Fixed possible corruption if one horse cannot be saved. + +Version 4.3.41 + Fixed horse speeds + Version 4.3.40 Fixed issue where players can buy horses, even if they don't own any diff --git a/plugin.yml b/plugin.yml index c0f3257..aabd8fc 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: mcMMOHorse main: com.blueskullgames.horserpg.HorseRPG -version: 4.3.40 +version: 4.3.42 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 e6b467b..17cd5f8 100644 --- a/src/com/blueskullgames/horserpg/HorseRPG.java +++ b/src/com/blueskullgames/horserpg/HorseRPG.java @@ -1038,6 +1038,7 @@ public static void setHorseName(CommandSender sender, String[] args) { // "&aHorse %oldname% has been changed to %newname%" msg(p, RenameHorse.replace("%oldname%", oldname).replace("%newname%", h.name)); } + /** * Changes the currently spawned horse's name * @@ -1060,17 +1061,18 @@ public static void setHorseSpeed(CommandSender sender, String[] args) { msg(p, NO_HORSE_SUMMONED); return; } - double speed = 2.25; - //String oldname = h.name; + double speed = RPGHorse.s_generic_speed; + // String oldname = h.name; if (args[2].equalsIgnoreCase("random")) - h.generic_speed = Math.random()*speed; + h.generic_speed = Math.random() * speed; else { h.generic_speed = Double.parseDouble(args[2]); } // "&aHorse %oldname% has been changed to %newname%" - msg(p, ChangeSpeedHorse.replace("%oldname%", h.name).replace("%speed%", ""+h.generic_speed)); + msg(p, ChangeSpeedHorse.replace("%oldname%", h.name).replace("%speed%", "" + h.generic_speed)); } + /** * Changes the currently spawned horse's name * @@ -1093,19 +1095,18 @@ public static void setHorseJump(CommandSender sender, String[] args) { msg(p, NO_HORSE_SUMMONED); return; } - double speed = 2.25; - //String oldname = h.name; + double jump = RPGHorse.s_generic_jump; + // String oldname = h.name; if (args[2].equalsIgnoreCase("random")) - h.generic_jump = Math.random()*speed; + h.generic_jump = Math.random() * jump; else { h.generic_jump = Double.parseDouble(args[2]); } // "&aHorse %oldname% has been changed to %newname%" - msg(p, ChangeJumpHorse.replace("%oldname%", h.name).replace("%jump%", ""+h.generic_jump)); + msg(p, ChangeJumpHorse.replace("%oldname%", h.name).replace("%jump%", "" + h.generic_jump)); } - /** * Changes the current spawned horse's color * @@ -1684,6 +1685,8 @@ private void initHelp() { setHelp.put(H_SET_NAME, "&b/h set name &a"); setHelp.put(H_SET_COLOR, "&b/h set color &a"); setHelp.put(H_SET_STYLE, "&b/h set style &a"); + setHelp.put(H_SET_STYLE, "&b/h set speed &a<<0.1 - 0.3>|random>"); + setHelp.put(H_SET_STYLE, "&b/h set jump &a<<0.7>|random>"); setHelp.put(H_SET_TYPE, "&b/h set type &a"); } @@ -1726,9 +1729,16 @@ private void initHorses() { Style style = Style.valueOf(rs.getString("style")); Variant variant = Variant.valueOf(rs.getString("variant")); + double speed = rs.getDouble("defaultSpeed"); + double jump = rs.getDouble("defaultJump"); + if (jump <= 0) + jump = RPGHorse.s_generic_jump; + if (speed <= 0) + speed = RPGHorse.s_generic_speed; + 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, 2.25, 2.25, rs.getInt("sex") == 0); + rs.getInt("vitalityXP"), rs.getInt("wrathXP"), null, speed, jump, rs.getInt("sex") == 0); // TODO:Tempfix. Since I don't want users to use the sql, just set the dfefault // value to 2.25 @@ -1761,7 +1771,11 @@ public static void saveHorses(CommandSender sender) { if (savetype == 2) { for (TreeSet horseSet : ownedHorses.values()) { for (RPGHorse h : horseSet) { - h_config.saveHorse(h, false); + try { + h_config.saveHorse(h, false); + } catch (Error | Exception ed4) { + ed4.printStackTrace(); + } } } h_config.save(); @@ -1773,14 +1787,18 @@ public static void saveHorses(CommandSender sender) { statement.executeUpdate("drop table if exists horses"); statement.executeUpdate("create table horses ( name string, " + "owner string, " + "color string, " + "style string, " + "variant string, " + "godmode integer, " + "swiftnessXP integer, " - + "agilityXP integer, " + "vitalityXP integer, " + "wrathXP integer, sex integer)"); + + "agilityXP integer, " + "vitalityXP integer, " + "wrathXP integer, sex integer, defaultSpeed integer, defaultJump integer)"); for (TreeSet horseSet : ownedHorses.values()) { for (RPGHorse h : horseSet) - statement.executeUpdate("insert into horses values('" + h.name + "', '" + h.owner + "', '" - + h.color + "', '" + h.style + "', '" + h.variant + "', " + (h.godmode ? 1 : 0) + ", " - + h.swiftness.xp + ", " + h.agility.xp + ", " + h.vitality.xp + ", " + h.wrath.xp + ", " - + (h.isMale ? 0 : 1) + ")"); + try { + statement.executeUpdate("insert into horses values('" + h.name + "', '" + h.owner + "', '" + + h.color + "', '" + h.style + "', '" + h.variant + "', " + (h.godmode ? 1 : 0) + + ", " + h.swiftness.xp + ", " + h.agility.xp + ", " + h.vitality.xp + ", " + + h.wrath.xp + ", " + (h.isMale ? 0 : 1) + ", "+h.generic_speed+", "+h.generic_jump+")"); + } catch (Error | Exception ed4) { + ed4.printStackTrace(); + } } } @@ -1835,7 +1853,7 @@ public List onTabComplete(CommandSender sender, Command command, String a(r, "reload", args[0]); a(r, "gift", args[0]); } else { - if(args[0].equalsIgnoreCase("set")) { + if (args[0].equalsIgnoreCase("set")) { a(r, "name", args[1]); a(r, "speed", args[1]); a(r, "jump", args[1]); diff --git a/src/com/blueskullgames/horserpg/RPGHorse.java b/src/com/blueskullgames/horserpg/RPGHorse.java index 934b439..b935f90 100644 --- a/src/com/blueskullgames/horserpg/RPGHorse.java +++ b/src/com/blueskullgames/horserpg/RPGHorse.java @@ -77,8 +77,12 @@ public class RPGHorse implements Comparable { public boolean isMale; public boolean allowBreeding = false; - public double generic_speed = 2.25f; - public double generic_jump = 2.25f; + + public static double s_generic_speed = 0.25f; + public static double s_generic_jump = 0.7f; + + public double generic_speed = 0.25f; + public double generic_jump = 0.7f; public static BaseAtributeUtil attributeUtil = null; static { @@ -144,7 +148,7 @@ public static Variant randomVariant() { */ public RPGHorse(Player owner) { this(randomName(owner), owner.getName(), randomColor(), randomStyle(), Variant.HORSE, false, 0, 0, 0, 0, null, - 2.25, 2.25, Math.random() > 0.5); + s_generic_jump, s_generic_speed, Math.random() > 0.5); } /** @@ -403,6 +407,8 @@ public Entity summon(Player p) { inventory[0] = new ItemStack(Material.SADDLE); } if (horse instanceof org.bukkit.entity.ChestedHorse) { + if(hasChest) + ((org.bukkit.entity.ChestedHorse) horse).setCarryingChest(true); ((org.bukkit.entity.ChestedHorse) horse).getInventory().setContents(inventory); } else { try { diff --git a/src/com/blueskullgames/horserpg/configs/HorseConfigHandler.java b/src/com/blueskullgames/horserpg/configs/HorseConfigHandler.java index 235ff83..1f72e76 100644 --- a/src/com/blueskullgames/horserpg/configs/HorseConfigHandler.java +++ b/src/com/blueskullgames/horserpg/configs/HorseConfigHandler.java @@ -178,10 +178,10 @@ public RPGHorse getHorse(final String owner, String horseUUID) { double jumpPow = config.contains("Horses." + owner + "." + rpguuids + Keys.jump) ? config.getDouble("Horses." + owner + "." + rpguuids + Keys.jump) - : -1; + : RPGHorse.s_generic_jump; double sprintPow = config.contains("Horses." + owner + "." + rpguuids + Keys.sprint) ? config.getDouble("Horses." + owner + "." + rpguuids + Keys.sprint) - : -1; + : RPGHorse.s_generic_speed; boolean sex = config.contains("Horses." + owner + "." + rpguuids + Keys.sex) ? config.getBoolean("Horses." + owner + "." + rpguuids + Keys.sex)