Skip to content

Commit

Permalink
4.3.47
Browse files Browse the repository at this point in the history
  • Loading branch information
ZombieStriker committed Dec 29, 2018
1 parent 3adb0c8 commit 0f09a75
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 78 deletions.
10 changes: 10 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 7 additions & 1 deletion config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,10 @@ RequirePermissionToRide: false
disable_basegame_taming: false

disable_StatsInChat: false
disable_StatsInScoreboard: false
disable_StatsInScoreboard: false

horsestats:
default_min_speed: 0.1125
default_max_speed: 0.3375
default_min_jump: 0.4
default_max_jump: 1.0
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.46
version: 4.3.47
description: An awesome role-playing plugin for horses.
authors: [GetGoodKid,Zombie_Striker]
website: http://www.blueskullgames.com
Expand Down
104 changes: 56 additions & 48 deletions src/com/blueskullgames/horserpg/HorseRPG.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ public class HorseRPG extends JavaPlugin {
public static ConfigAccessor config;
public static Economy econ;
public static HashMap<Entity, RPGHorse> hSpawnedHorses;
public static HashMap<Player, RPGHorse> pCurrentHorse;
public static HashMap<Player, RPGHorse> offers;
public static HashMap<UUID, RPGHorse> pCurrentHorse;
public static HashMap<UUID, RPGHorse> offers;
public static HashMap<String, TreeSet<RPGHorse>> ownedHorses;
public static HashSet<RPGHorse> horses;
public static HorseRPG instance;
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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<RPGHorse>());
Expand All @@ -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);
Expand All @@ -762,15 +762,15 @@ 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;
}
}
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());
}

/**
Expand All @@ -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;
}
Expand Down Expand Up @@ -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.");
Expand All @@ -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) {
Expand All @@ -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)) {
Expand All @@ -896,7 +898,7 @@ public static void summonHorse(CommandSender sender, String[] args) {
}
}
h.summon(p);
pCurrentHorse.put(p, h);
pCurrentHorse.put(p.getUniqueId(), h);
}
}
}
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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));
Expand All @@ -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;
Expand All @@ -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%"
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand All @@ -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.");
}
Expand Down Expand Up @@ -1591,9 +1591,9 @@ private void initVariables() {
if (!config.getConfig().contains("enable-economy"))
config.overwriteConfig();

offers = new HashMap<Player, RPGHorse>();
offers = new HashMap<UUID, RPGHorse>();
ownedHorses = new HashMap<String, TreeSet<RPGHorse>>();
pCurrentHorse = new HashMap<Player, RPGHorse>();
pCurrentHorse = new HashMap<UUID, RPGHorse>();
hSpawnedHorses = new HashMap<Entity, RPGHorse>();
horses = new HashSet<RPGHorse>();
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -1969,8 +1978,8 @@ public List<String> 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()))
Expand Down Expand Up @@ -2229,5 +2238,4 @@ public static void showLeaderBoard(CommandSender sender, String[] args) {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(instance, new ScoreboardTask(p, oldsb), 200);
}
}

}

0 comments on commit 0f09a75

Please sign in to comment.