Skip to content

Commit

Permalink
v4.3.42
Browse files Browse the repository at this point in the history
  • Loading branch information
ZombieStriker committed Nov 12, 2018
1 parent 21021d0 commit ff4d7fd
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 23 deletions.
9 changes: 9 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
52 changes: 35 additions & 17 deletions src/com/blueskullgames/horserpg/HorseRPG.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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
*
Expand All @@ -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
*
Expand Down Expand Up @@ -1684,6 +1685,8 @@ private void initHelp() {
setHelp.put(H_SET_NAME, "&b/h set name &a<name|random>");
setHelp.put(H_SET_COLOR, "&b/h set color &a<color|random>");
setHelp.put(H_SET_STYLE, "&b/h set style &a<style|random>");
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<donkey|horse|mule|skele|zombie|rand>");

}
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -1761,7 +1771,11 @@ public static void saveHorses(CommandSender sender) {
if (savetype == 2) {
for (TreeSet<RPGHorse> 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();
Expand All @@ -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<RPGHorse> 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();
}
}
}

Expand Down Expand Up @@ -1835,7 +1853,7 @@ public List<String> 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]);
Expand Down
12 changes: 9 additions & 3 deletions src/com/blueskullgames/horserpg/RPGHorse.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ public class RPGHorse implements Comparable<RPGHorse> {
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 {
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ff4d7fd

Please sign in to comment.