Skip to content

Commit

Permalink
Added MoneyChance
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel0916 committed Feb 27, 2014
1 parent ca6f99c commit 693accb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/main/java/de/daniel0916/KillMoney/KillMoney.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,21 @@ public static void HandleMoneyForMob(Player Killer, EntityType Mob) {
String w2 = KillMoney.cfg.getString("KillMoney.Worlds.2");
String w3 = KillMoney.cfg.getString("KillMoney.Worlds.3");

double Price = GetPriceFromEntityType(Mob);
if (Price <= 0)
{
return;
}

if (KillMoney.cfg.getBoolean("KillMoney.Enabled")) {
double Price = GetPriceFromEntityType(Mob);
if (Price <= 0)
{
return;
}

String percentString = cfg.getString("KillMoney.Mob." + GetNameFromEntityType(Mob) + ".MoneyChance");
int percent = Integer.parseInt(percentString.replaceAll("%", ""));
if (percent < 100) {
if ((Math.random() * 100) > percent) {
return;
}
}

if (w.equals(w1)) {
if (KillMoney.econ.hasAccount(Killer.getName())) {
PlayerMoneyGiveEvent giveevent = new PlayerMoneyGiveEvent(Killer, Mob, Price, KillMoney.prefix, KillMoney.cfg.getString("KillMoney.Mob." + GetNameFromEntityType(Mob) + ".Message"));
Expand Down Expand Up @@ -261,6 +269,14 @@ public static void HandleMoneyForPlayer(Player Killer, Player p) {
double DeathPrice = KillMoney.cfg.getDouble("KillMoney.Player.DeathPrice");
double MinimumMoney = KillMoney.cfg.getDouble("KillMoney.Player.MinimumMoney");

String percentString = cfg.getString("KillMoney.Player.MoneyChance");
int percent = Integer.parseInt(percentString.replaceAll("%", ""));
if (percent < 100) {
if ((Math.random() * 100) > percent) {
return;
}
}

if (KillMoney.econ.hasAccount(p.getName())) {
PlayerMoneyTakeByPlayerEvent takeevent = new PlayerMoneyTakeByPlayerEvent(p, Killer, DeathPrice, KillMoney.prefix, KillMoney.cfg.getString("KillMoney.Player.DeathMessage"));
Bukkit.getServer().getPluginManager().callEvent(takeevent);
Expand Down
17 changes: 17 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,68 +19,85 @@ KillMoney:
showDeathMessage: true
KillMessage: '&aYou have get Money for Killing &b<Player>'
DeathMessage: '&eYou lost Money for been killed from &b<Killer>'
MoneyChance: 100%
Mob:
Creeper:
Price: 1.0
showMessage: true
Message: '&aYou have get Money for Killing a &9Creeper'
MoneyChance: 100%
Zombie:
Price: 1.0
showMessage: true
Message: '&aYou have get Money for Killing a &9Zombie'
MoneyChance: 100%
Spider:
Price: 1.0
showMessage: true
Message: '&aYou have get Money for Killing a &9Spider'
MoneyChance: 100%
Skeleton:
Price: 1.0
showMessage: true
Message: '&aYou have get Money for Killing a &9Skeleton'
MoneyChance: 100%
Blaze:
Price: 1.0
showMessage: true
Message: '&aYou have get Money for Killing a &9Blaze'
MoneyChance: 100%
Cave_Spider:
Price: 1.0
showMessage: true
Message: '&aYou have get Money for Killing a &9Cave Spider'
MoneyChance: 100%
Ender_Dragon:
Price: 1.0
showMessage: true
Message: '&aYou have get Money for Killing a &9Ender Dragon'
MoneyChance: 100%
Enderman:
Price: 1.0
showMessage: true
Message: '&aYou have get Money for Killing a &9Enderman'
MoneyChance: 100%
Ghast:
Price: 1.0
showMessage: true
Message: '&aYou have get Money for Killing a &9Ghast'
MoneyChance: 100%
Giant:
Price: 1.0
showMessage: true
Message: '&aYou have get Money for Killing a &9Giant'
MoneyChance: 100%
Magma_Cube:
Price: 1.0
showMessage: true
Message: '&aYou have get Money for Killing a &9Magma Cube'
MoneyChance: 100%
Pig_Zombie:
Price: 1.0
showMessage: true
Message: '&aYou have get Money for Killing a &9Pig Zombie'
MoneyChance: 100%
Silverfish:
Price: 1.0
showMessage: true
Message: '&aYou have get Money for Killing a &9Silverfish'
MoneyChance: 100%
Slime:
Price: 1.0
showMessage: true
Message: '&aYou have get Money for Killing a &9Slime'
MoneyChance: 100%
Witch:
Price: 1.0
showMessage: true
Message: '&aYou have get Money for Killing a &9Witch'
MoneyChance: 100%
Wither:
Price: 1.0
showMessage: true
Message: '&aYou have get Money for Killing a &9Wither'
MoneyChance: 100%

0 comments on commit 693accb

Please sign in to comment.