mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
Random update. :D
This commit is contained in:
parent
ca2949dcaf
commit
945fb5ed55
@ -1,5 +1,7 @@
|
|||||||
package com.gmail.nossr50;
|
package com.gmail.nossr50;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -17,6 +19,8 @@ import com.gmail.nossr50.events.McMMOItemSpawnEvent;
|
|||||||
|
|
||||||
public class m {
|
public class m {
|
||||||
|
|
||||||
|
private static Random random = new Random();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a capitalized version of the target string.
|
* Gets a capitalized version of the target string.
|
||||||
*
|
*
|
||||||
@ -224,7 +228,7 @@ public class m {
|
|||||||
* @param chance The percentage chance for the item to drop
|
* @param chance The percentage chance for the item to drop
|
||||||
*/
|
*/
|
||||||
public static void mcRandomDropItem(Location location, ItemStack is, double chance) {
|
public static void mcRandomDropItem(Location location, ItemStack is, double chance) {
|
||||||
if (Math.random() * 100 < chance) {
|
if (random.nextInt(100) < chance) {
|
||||||
mcDropItem(location, is);
|
mcDropItem(location, is);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.gmail.nossr50.skills;
|
package com.gmail.nossr50.skills;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
@ -14,6 +16,8 @@ import com.gmail.nossr50.party.Party;
|
|||||||
|
|
||||||
public class Acrobatics {
|
public class Acrobatics {
|
||||||
|
|
||||||
|
private static Random random = new Random();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for fall damage reduction.
|
* Check for fall damage reduction.
|
||||||
*
|
*
|
||||||
@ -39,7 +43,7 @@ public class Acrobatics {
|
|||||||
acrovar = acrovar * 2;
|
acrovar = acrovar * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((acrovar > MAX_BONUS_LEVEL || Math.random() * 1000 <= acrovar) && mcPermissions.getInstance().roll(player)) {
|
if ((acrovar > MAX_BONUS_LEVEL || random.nextInt(1000) <= acrovar) && mcPermissions.getInstance().roll(player)) {
|
||||||
int threshold = 7;
|
int threshold = 7;
|
||||||
|
|
||||||
if (gracefulRoll) {
|
if (gracefulRoll) {
|
||||||
@ -103,7 +107,7 @@ public class Acrobatics {
|
|||||||
int skillLevel = PPd.getSkillLevel(SkillType.ACROBATICS);
|
int skillLevel = PPd.getSkillLevel(SkillType.ACROBATICS);
|
||||||
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||||
|
|
||||||
if (Math.random() * 4000 <= skillCheck && mcPermissions.getInstance().dodge(defender)) {
|
if (random.nextInt(4000) <= skillCheck && mcPermissions.getInstance().dodge(defender)) {
|
||||||
defender.sendMessage(mcLocale.getString("Acrobatics.Dodge"));
|
defender.sendMessage(mcLocale.getString("Acrobatics.Dodge"));
|
||||||
|
|
||||||
if (System.currentTimeMillis() >= (5000 + PPd.getRespawnATS()) && defender.getHealth() >= 1) {
|
if (System.currentTimeMillis() >= (5000 + PPd.getRespawnATS()) && defender.getHealth() >= 1) {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.gmail.nossr50.skills;
|
package com.gmail.nossr50.skills;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -17,6 +19,8 @@ import com.gmail.nossr50.party.Party;
|
|||||||
|
|
||||||
public class Archery {
|
public class Archery {
|
||||||
|
|
||||||
|
private static Random random = new Random();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Track arrows fired for later retrieval.
|
* Track arrows fired for later retrieval.
|
||||||
*
|
*
|
||||||
@ -32,7 +36,7 @@ public class Archery {
|
|||||||
plugin.arrowTracker.put(entity, 0);
|
plugin.arrowTracker.put(entity, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skillLevel > MAX_BONUS_LEVEL || (Math.random() * 1000 <= skillLevel)) {
|
if (skillLevel > MAX_BONUS_LEVEL || (random.nextInt(1000) <= skillLevel)) {
|
||||||
plugin.arrowTracker.put(entity, 1);
|
plugin.arrowTracker.put(entity, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,7 +59,7 @@ public class Archery {
|
|||||||
|
|
||||||
PlayerProfile PPa = Users.getProfile(attacker);
|
PlayerProfile PPa = Users.getProfile(attacker);
|
||||||
|
|
||||||
if (Math.random() * 100 <= IGNITION_CHANCE) {
|
if (random.nextInt(100) <= IGNITION_CHANCE) {
|
||||||
int ignition = 20;
|
int ignition = 20;
|
||||||
|
|
||||||
/* Add 20 ticks for every 200 skill levels */
|
/* Add 20 ticks for every 200 skill levels */
|
||||||
@ -94,14 +98,14 @@ public class Archery {
|
|||||||
Location loc = defender.getLocation();
|
Location loc = defender.getLocation();
|
||||||
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||||
|
|
||||||
if (Math.random() * 10 > 5) {
|
if (random.nextInt(10) > 5) {
|
||||||
loc.setPitch(90);
|
loc.setPitch(90);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
loc.setPitch(-90);
|
loc.setPitch(-90);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Math.random() * 2000 <= skillCheck && mcPermissions.getInstance().daze(attacker)) {
|
if (random.nextInt(2000) <= skillCheck && mcPermissions.getInstance().daze(attacker)) {
|
||||||
defender.teleport(loc);
|
defender.teleport(loc);
|
||||||
defender.sendMessage(mcLocale.getString("Combat.TouchedFuzzy"));
|
defender.sendMessage(mcLocale.getString("Combat.TouchedFuzzy"));
|
||||||
attacker.sendMessage(mcLocale.getString("Combat.TargetDazed"));
|
attacker.sendMessage(mcLocale.getString("Combat.TargetDazed"));
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.gmail.nossr50.skills;
|
package com.gmail.nossr50.skills;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.entity.AnimalTamer;
|
import org.bukkit.entity.AnimalTamer;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
@ -18,6 +20,8 @@ import com.gmail.nossr50.party.Party;
|
|||||||
|
|
||||||
public class Axes {
|
public class Axes {
|
||||||
|
|
||||||
|
private static Random random = new Random();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply bonus to damage done by axes.
|
* Apply bonus to damage done by axes.
|
||||||
*
|
*
|
||||||
@ -72,7 +76,7 @@ public class Axes {
|
|||||||
int skillLevel = PPa.getSkillLevel(SkillType.AXES);
|
int skillLevel = PPa.getSkillLevel(SkillType.AXES);
|
||||||
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||||
|
|
||||||
if (Math.random() * 2000 <= skillCheck && !entity.isDead()){
|
if (random.nextInt(2000) <= skillCheck && !entity.isDead()){
|
||||||
int damage = event.getDamage();
|
int damage = event.getDamage();
|
||||||
|
|
||||||
if (entity instanceof Player){
|
if (entity instanceof Player){
|
||||||
@ -133,7 +137,7 @@ public class Axes {
|
|||||||
final int GREATER_IMPACT_CHANCE = 25;
|
final int GREATER_IMPACT_CHANCE = 25;
|
||||||
final double GREATER_IMPACT_MULTIPLIER = 1.5;
|
final double GREATER_IMPACT_MULTIPLIER = 1.5;
|
||||||
|
|
||||||
if (Math.random() * 100 <= GREATER_IMPACT_CHANCE) {
|
if (random.nextInt(100) <= GREATER_IMPACT_CHANCE) {
|
||||||
event.setDamage(event.getDamage() + 2);
|
event.setDamage(event.getDamage() + 2);
|
||||||
target.setVelocity(attacker.getLocation().getDirection().normalize().multiply(GREATER_IMPACT_MULTIPLIER));
|
target.setVelocity(attacker.getLocation().getDirection().normalize().multiply(GREATER_IMPACT_MULTIPLIER));
|
||||||
attacker.sendMessage(mcLocale.getString("Axes.GreaterImpactOnEnemy"));
|
attacker.sendMessage(mcLocale.getString("Axes.GreaterImpactOnEnemy"));
|
||||||
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -25,6 +26,8 @@ import com.gmail.nossr50.locale.mcLocale;
|
|||||||
|
|
||||||
public class BlastMining {
|
public class BlastMining {
|
||||||
|
|
||||||
|
private static Random random = new Random();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for what blocks drop from the explosion.
|
* Handler for what blocks drop from the explosion.
|
||||||
*
|
*
|
||||||
@ -43,7 +46,7 @@ public class BlastMining {
|
|||||||
while (iterator2.hasNext()) {
|
while (iterator2.hasNext()) {
|
||||||
Block temp = iterator2.next();
|
Block temp = iterator2.next();
|
||||||
|
|
||||||
if ((float) Math.random() < (yield + oreBonus)) {
|
if (random.nextFloat() < (yield + oreBonus)) {
|
||||||
blocksDropped.add(temp);
|
blocksDropped.add(temp);
|
||||||
Mining.miningDrops(temp);
|
Mining.miningDrops(temp);
|
||||||
|
|
||||||
@ -66,7 +69,7 @@ public class BlastMining {
|
|||||||
while (iterator3.hasNext()) {
|
while (iterator3.hasNext()) {
|
||||||
Block temp = iterator3.next();
|
Block temp = iterator3.next();
|
||||||
|
|
||||||
if ((float) Math.random() < (yield - debrisReduction))
|
if (random.nextFloat() < (yield - debrisReduction))
|
||||||
Mining.miningDrops(temp);
|
Mining.miningDrops(temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.skills;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -25,6 +26,8 @@ import org.getspout.spoutapi.sound.SoundEffect;
|
|||||||
|
|
||||||
public class Excavation {
|
public class Excavation {
|
||||||
|
|
||||||
|
private static Random random = new Random();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check to see if a block can be broken by Giga Drill Breaker.
|
* Check to see if a block can be broken by Giga Drill Breaker.
|
||||||
*
|
*
|
||||||
@ -101,7 +104,7 @@ public class Excavation {
|
|||||||
|
|
||||||
for (ExcavationTreasure treasure : treasures) {
|
for (ExcavationTreasure treasure : treasures) {
|
||||||
if (skillLevel >= treasure.getDropLevel()) {
|
if (skillLevel >= treasure.getDropLevel()) {
|
||||||
if (Math.random() * 100 <= treasure.getDropChance()) {
|
if (random.nextInt(100) <= treasure.getDropChance()) {
|
||||||
xp += treasure.getXp();
|
xp += treasure.getXp();
|
||||||
is.add(treasure.getDrop());
|
is.add(treasure.getDrop());
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package com.gmail.nossr50.skills;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -29,6 +30,8 @@ import com.gmail.nossr50.locale.mcLocale;
|
|||||||
|
|
||||||
public class Fishing {
|
public class Fishing {
|
||||||
|
|
||||||
|
private static Random random = new Random();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the player's current fishing loot tier.
|
* Get the player's current fishing loot tier.
|
||||||
*
|
*
|
||||||
@ -95,9 +98,9 @@ public class Fishing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (LoadProperties.fishingDrops) {
|
if (LoadProperties.fishingDrops) {
|
||||||
FishingTreasure treasure = rewards.get((int) (Math.random() * rewards.size()));
|
FishingTreasure treasure = rewards.get(random.nextInt(rewards.size()));
|
||||||
|
|
||||||
if (Math.random() * 100 <= treasure.getDropChance()) {
|
if (random.nextInt(100) <= treasure.getDropChance()) {
|
||||||
Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp(), player);
|
Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp(), player);
|
||||||
theCatch.setItemStack(treasure.getDrop());
|
theCatch.setItemStack(treasure.getDrop());
|
||||||
}
|
}
|
||||||
@ -106,7 +109,7 @@ public class Fishing {
|
|||||||
theCatch.setItemStack(new ItemStack(Material.RAW_FISH));
|
theCatch.setItemStack(new ItemStack(Material.RAW_FISH));
|
||||||
}
|
}
|
||||||
|
|
||||||
theCatch.getItemStack().setDurability((short) (Math.random() * theCatch.getItemStack().getType().getMaxDurability())); //Change durability to random value
|
theCatch.getItemStack().setDurability((short) (random.nextInt(theCatch.getItemStack().getType().getMaxDurability()))); //Change durability to random value
|
||||||
|
|
||||||
m.mcDropItem(player.getLocation(), new ItemStack(Material.RAW_FISH)); //Always drop a fish
|
m.mcDropItem(player.getLocation(), new ItemStack(Material.RAW_FISH)); //Always drop a fish
|
||||||
PP.addXP(SkillType.FISHING, LoadProperties.mfishing, player);
|
PP.addXP(SkillType.FISHING, LoadProperties.mfishing, player);
|
||||||
@ -132,7 +135,7 @@ public class Fishing {
|
|||||||
|
|
||||||
player.sendMessage(mcLocale.getString("Fishing.ItemFound"));
|
player.sendMessage(mcLocale.getString("Fishing.ItemFound"));
|
||||||
if (ItemChecks.isArmor(fishingResults) || ItemChecks.isTool(fishingResults)) {
|
if (ItemChecks.isArmor(fishingResults) || ItemChecks.isTool(fishingResults)) {
|
||||||
if (Math.random() * 100 <= ENCHANTMENT_CHANCE) {
|
if (random.nextInt(100) <= ENCHANTMENT_CHANCE) {
|
||||||
for (Enchantment newEnchant : Enchantment.values()) {
|
for (Enchantment newEnchant : Enchantment.values()) {
|
||||||
if (newEnchant.canEnchantItem(fishingResults)) {
|
if (newEnchant.canEnchantItem(fishingResults)) {
|
||||||
Map<Enchantment, Integer> resultEnchantments = fishingResults.getEnchantments();
|
Map<Enchantment, Integer> resultEnchantments = fishingResults.getEnchantments();
|
||||||
@ -144,9 +147,9 @@ public class Fishing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Actual chance to have an enchantment is related to your fishing skill */
|
/* Actual chance to have an enchantment is related to your fishing skill */
|
||||||
if (Math.random() * 15 < Fishing.getFishingLootTier(PP)) {
|
if (random.nextInt(15) < Fishing.getFishingLootTier(PP)) {
|
||||||
enchanted = true;
|
enchanted = true;
|
||||||
int randomEnchantLevel = (int) (Math.random() * newEnchant.getMaxLevel()) + 1;
|
int randomEnchantLevel = random.nextInt(newEnchant.getMaxLevel()) + 1;
|
||||||
|
|
||||||
if (randomEnchantLevel < newEnchant.getStartLevel()) {
|
if (randomEnchantLevel < newEnchant.getStartLevel()) {
|
||||||
randomEnchantLevel = newEnchant.getStartLevel();
|
randomEnchantLevel = newEnchant.getStartLevel();
|
||||||
@ -171,7 +174,7 @@ public class Fishing {
|
|||||||
* @param event The event to modify
|
* @param event The event to modify
|
||||||
*/
|
*/
|
||||||
public static void shakeMob(PlayerFishEvent event) {
|
public static void shakeMob(PlayerFishEvent event) {
|
||||||
final int DROP_NUMBER = (int) (Math.random() * 101);
|
final int DROP_NUMBER = random.nextInt(100);
|
||||||
|
|
||||||
LivingEntity le = (LivingEntity) event.getCaught();
|
LivingEntity le = (LivingEntity) event.getCaught();
|
||||||
EntityType type = le.getType();
|
EntityType type = le.getType();
|
||||||
@ -275,7 +278,7 @@ public class Fishing {
|
|||||||
wool.setColor(sheep.getColor());
|
wool.setColor(sheep.getColor());
|
||||||
|
|
||||||
ItemStack theWool = wool.toItemStack();
|
ItemStack theWool = wool.toItemStack();
|
||||||
theWool.setAmount((int)(Math.random() * 6));
|
theWool.setAmount(1 + random.nextInt(6));
|
||||||
|
|
||||||
m.mcDropItem(loc, theWool);
|
m.mcDropItem(loc, theWool);
|
||||||
sheep.setSheared(true);
|
sheep.setSheared(true);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.gmail.nossr50.skills;
|
package com.gmail.nossr50.skills;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.CropState;
|
import org.bukkit.CropState;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -22,6 +24,8 @@ import com.gmail.nossr50.runnables.GreenThumbTimer;
|
|||||||
|
|
||||||
public class Herbalism {
|
public class Herbalism {
|
||||||
|
|
||||||
|
private static Random random = new Random();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activate the Green Terra ability.
|
* Activate the Green Terra ability.
|
||||||
*
|
*
|
||||||
@ -137,7 +141,7 @@ public class Herbalism {
|
|||||||
if (b.getType().equals(Material.CACTUS)) {
|
if (b.getType().equals(Material.CACTUS)) {
|
||||||
mat = Material.CACTUS;
|
mat = Material.CACTUS;
|
||||||
if (!b.hasMetadata("mcmmoPlacedBlock")) {
|
if (!b.hasMetadata("mcmmoPlacedBlock")) {
|
||||||
if(herbLevel > MAX_BONUS_LEVEL || (Math.random() * 1000 <= herbLevel)) {
|
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
|
||||||
catciDrops++;
|
catciDrops++;
|
||||||
}
|
}
|
||||||
xp += LoadProperties.mcactus;
|
xp += LoadProperties.mcactus;
|
||||||
@ -193,7 +197,7 @@ public class Herbalism {
|
|||||||
if (b.getType().equals(Material.SUGAR_CANE_BLOCK)) {
|
if (b.getType().equals(Material.SUGAR_CANE_BLOCK)) {
|
||||||
mat = Material.SUGAR_CANE;
|
mat = Material.SUGAR_CANE;
|
||||||
if (!b.hasMetadata("mcmmoPlacedBlock")) {
|
if (!b.hasMetadata("mcmmoPlacedBlock")) {
|
||||||
if(herbLevel > MAX_BONUS_LEVEL || (Math.random() * 1000 <= herbLevel)) {
|
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
|
||||||
caneDrops++;
|
caneDrops++;
|
||||||
}
|
}
|
||||||
xp += LoadProperties.msugar;
|
xp += LoadProperties.msugar;
|
||||||
@ -226,7 +230,7 @@ public class Herbalism {
|
|||||||
else {
|
else {
|
||||||
ItemStack is = new ItemStack(mat);
|
ItemStack is = new ItemStack(mat);
|
||||||
|
|
||||||
if (herbLevel > MAX_BONUS_LEVEL || (Math.random() * 1000 <= herbLevel)) {
|
if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
|
||||||
if (type.equals(Material.CACTUS)) {
|
if (type.equals(Material.CACTUS)) {
|
||||||
m.mcDropItems(loc, is, catciDrops);
|
m.mcDropItems(loc, is, catciDrops);
|
||||||
}
|
}
|
||||||
@ -268,7 +272,7 @@ public class Herbalism {
|
|||||||
boolean hasSeeds = inventory.contains(Material.SEEDS);
|
boolean hasSeeds = inventory.contains(Material.SEEDS);
|
||||||
Location loc = block.getLocation();
|
Location loc = block.getLocation();
|
||||||
|
|
||||||
if (hasSeeds && PP.getGreenTerraMode() || hasSeeds && (herbLevel > MAX_BONUS_LEVEL || (Math.random() * 1500 <= herbLevel))) {
|
if (hasSeeds && PP.getGreenTerraMode() || hasSeeds && (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1500) <= herbLevel)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
m.mcDropItem(loc, new ItemStack(Material.WHEAT));
|
m.mcDropItem(loc, new ItemStack(Material.WHEAT));
|
||||||
@ -297,7 +301,7 @@ public class Herbalism {
|
|||||||
|
|
||||||
player.setItemInHand(new ItemStack(Material.SEEDS, seeds - 1));
|
player.setItemInHand(new ItemStack(Material.SEEDS, seeds - 1));
|
||||||
|
|
||||||
if (skillLevel > MAX_BONUS_LEVEL || Math.random() * 1500 <= skillLevel) {
|
if (skillLevel > MAX_BONUS_LEVEL || random.nextInt(1500) <= skillLevel) {
|
||||||
greenTerra(player, block);
|
greenTerra(player, block);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.gmail.nossr50.skills;
|
package com.gmail.nossr50.skills;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.CoalType;
|
import org.bukkit.CoalType;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -19,9 +21,9 @@ import com.gmail.nossr50.spout.SpoutSounds;
|
|||||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||||
import com.gmail.nossr50.datatypes.SkillType;
|
import com.gmail.nossr50.datatypes.SkillType;
|
||||||
|
|
||||||
|
public class Mining {
|
||||||
|
|
||||||
public class Mining
|
private static Random random = new Random();
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Drop items from Mining & Blast Mining skills.
|
* Drop items from Mining & Blast Mining skills.
|
||||||
@ -165,7 +167,7 @@ public class Mining
|
|||||||
|
|
||||||
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
|
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
|
||||||
|
|
||||||
if ((skillLevel > MAX_BONUS_LEVEL || (Math.random() * 1000 <= skillLevel)) && mcPermissions.getInstance().miningDoubleDrops(player)) {
|
if ((skillLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= skillLevel) && mcPermissions.getInstance().miningDoubleDrops(player)) {
|
||||||
if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
||||||
m.mcDropItem(block.getLocation(), new ItemStack(block.getType()));
|
m.mcDropItem(block.getLocation(), new ItemStack(block.getType()));
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.skills;
|
package com.gmail.nossr50.skills;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -24,6 +25,8 @@ import com.gmail.nossr50.locale.mcLocale;
|
|||||||
|
|
||||||
public class Repair {
|
public class Repair {
|
||||||
|
|
||||||
|
private static Random random = new Random();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle all the item repair checks.
|
* Handle all the item repair checks.
|
||||||
*
|
*
|
||||||
@ -203,11 +206,11 @@ public class Repair {
|
|||||||
for (Entry<Enchantment, Integer> enchant : enchants.entrySet()) {
|
for (Entry<Enchantment, Integer> enchant : enchants.entrySet()) {
|
||||||
Enchantment enchantment = enchant.getKey();
|
Enchantment enchantment = enchant.getKey();
|
||||||
|
|
||||||
if (Math.random() * 100 <= getEnchantChance(rank)) {
|
if (random.nextInt(100) <= getEnchantChance(rank)) {
|
||||||
int enchantLevel = enchant.getValue();
|
int enchantLevel = enchant.getValue();
|
||||||
|
|
||||||
if (LoadProperties.mayDowngradeEnchants && enchantLevel > 1) {
|
if (LoadProperties.mayDowngradeEnchants && enchantLevel > 1) {
|
||||||
if (Math.random() * 100 <= getDowngradeChance(rank)) {
|
if (random.nextInt(100) <= getDowngradeChance(rank)) {
|
||||||
is.addEnchantment(enchantment, enchantLevel--);
|
is.addEnchantment(enchantment, enchantLevel--);
|
||||||
downgraded = true;
|
downgraded = true;
|
||||||
}
|
}
|
||||||
@ -412,7 +415,7 @@ public class Repair {
|
|||||||
|
|
||||||
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR);
|
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR);
|
||||||
|
|
||||||
if ((skillLevel > MAX_BONUS_LEVEL || (Math.random() * 1000 <= skillLevel)) && mcPermissions.getInstance().repairBonus(player)) {
|
if ((skillLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= skillLevel) && mcPermissions.getInstance().repairBonus(player)) {
|
||||||
player.sendMessage(mcLocale.getString("Skills.FeltEasy"));
|
player.sendMessage(mcLocale.getString("Skills.FeltEasy"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.gmail.nossr50.skills;
|
package com.gmail.nossr50.skills;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.entity.AnimalTamer;
|
import org.bukkit.entity.AnimalTamer;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
@ -21,6 +23,8 @@ import com.gmail.nossr50.runnables.mcBleedTimer;
|
|||||||
|
|
||||||
public class Swords {
|
public class Swords {
|
||||||
|
|
||||||
|
private static Random random = new Random();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for Bleed effect.
|
* Check for Bleed effect.
|
||||||
*
|
*
|
||||||
@ -52,7 +56,7 @@ public class Swords {
|
|||||||
int skillLevel = PPa.getSkillLevel(SkillType.SWORDS);
|
int skillLevel = PPa.getSkillLevel(SkillType.SWORDS);
|
||||||
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||||
|
|
||||||
if (Math.random() * 1000 <= skillCheck && !entity.isDead()) {
|
if (random.nextInt(1000) <= skillCheck && !entity.isDead()) {
|
||||||
if (entity instanceof Player) {
|
if (entity instanceof Player) {
|
||||||
Player target = (Player) entity;
|
Player target = (Player) entity;
|
||||||
int bleedTicks;
|
int bleedTicks;
|
||||||
@ -98,7 +102,7 @@ public class Swords {
|
|||||||
int skillLevel = PPd.getSkillLevel(SkillType.SWORDS);
|
int skillLevel = PPd.getSkillLevel(SkillType.SWORDS);
|
||||||
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||||
|
|
||||||
if (Math.random() * 2000 <= skillCheck) {
|
if (random.nextInt(2000) <= skillCheck) {
|
||||||
Combat.dealDamage((LivingEntity) attacker, event.getDamage() / COUNTER_ATTACK_MODIFIER);
|
Combat.dealDamage((LivingEntity) attacker, event.getDamage() / COUNTER_ATTACK_MODIFIER);
|
||||||
defender.sendMessage(mcLocale.getString("Swords.CounterAttacked"));
|
defender.sendMessage(mcLocale.getString("Swords.CounterAttacked"));
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.gmail.nossr50.skills;
|
package com.gmail.nossr50.skills;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.AnimalTamer;
|
import org.bukkit.entity.AnimalTamer;
|
||||||
@ -28,6 +30,8 @@ import com.gmail.nossr50.runnables.mcBleedTimer;
|
|||||||
|
|
||||||
public class Taming {
|
public class Taming {
|
||||||
|
|
||||||
|
private static Random random = new Random();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply the Fast Food Service ability.
|
* Apply the Fast Food Service ability.
|
||||||
*
|
*
|
||||||
@ -45,7 +49,7 @@ public class Taming {
|
|||||||
|
|
||||||
if (PPo.getSkillLevel(SkillType.TAMING) >= SKILL_ACTIVATION_LEVEL) {
|
if (PPo.getSkillLevel(SkillType.TAMING) >= SKILL_ACTIVATION_LEVEL) {
|
||||||
if (health < maxHealth) {
|
if (health < maxHealth) {
|
||||||
if (Math.random() * 100 < ACTIVATION_CHANCE) {
|
if (random.nextInt(100) < ACTIVATION_CHANCE) {
|
||||||
if (health + damage <= maxHealth) {
|
if (health + damage <= maxHealth) {
|
||||||
theWolf.setHealth(health + damage);
|
theWolf.setHealth(health + damage);
|
||||||
}
|
}
|
||||||
@ -83,7 +87,7 @@ public class Taming {
|
|||||||
public static void gore(PlayerProfile PPo, EntityDamageEvent event, Player master, mcMMO plugin) {
|
public static void gore(PlayerProfile PPo, EntityDamageEvent event, Player master, mcMMO plugin) {
|
||||||
final int GORE_MULTIPLIER = 2;
|
final int GORE_MULTIPLIER = 2;
|
||||||
|
|
||||||
if (Math.random() * 1000 <= PPo.getSkillLevel(SkillType.TAMING)) {
|
if (random.nextInt(1000) <= PPo.getSkillLevel(SkillType.TAMING)) {
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
event.setDamage(event.getDamage() * GORE_MULTIPLIER);
|
event.setDamage(event.getDamage() * GORE_MULTIPLIER);
|
||||||
|
|
||||||
@ -245,7 +249,7 @@ public class Taming {
|
|||||||
((Tameable) entity).setOwner(player);
|
((Tameable) entity).setOwner(player);
|
||||||
|
|
||||||
if (entity.getType().equals(EntityType.OCELOT)) {
|
if (entity.getType().equals(EntityType.OCELOT)) {
|
||||||
((Ocelot) entity).setCatType(Ocelot.Type.getType(1 + (int) (Math.random() * 3)));
|
((Ocelot) entity).setCatType(Ocelot.Type.getType(1 + random.nextInt(3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
player.setItemInHand(new ItemStack(summonItem, item.getAmount() - summonAmount));
|
player.setItemInHand(new ItemStack(summonItem, item.getAmount() - summonAmount));
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.gmail.nossr50.skills;
|
package com.gmail.nossr50.skills;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
@ -14,6 +16,8 @@ import com.gmail.nossr50.locale.mcLocale;
|
|||||||
|
|
||||||
public class Unarmed {
|
public class Unarmed {
|
||||||
|
|
||||||
|
private static Random random = new Random();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply bonus to Unarmed damage.
|
* Apply bonus to Unarmed damage.
|
||||||
*
|
*
|
||||||
@ -46,7 +50,7 @@ public class Unarmed {
|
|||||||
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||||
|
|
||||||
if (defender.getItemInHand().getType().equals(Material.AIR)) {
|
if (defender.getItemInHand().getType().equals(Material.AIR)) {
|
||||||
if (Math.random() * 3000 <= skillCheck) {
|
if (random.nextInt(3000) <= skillCheck) {
|
||||||
ItemStack item = defender.getItemInHand();
|
ItemStack item = defender.getItemInHand();
|
||||||
|
|
||||||
defender.sendMessage(mcLocale.getString("Skills.Disarmed"));
|
defender.sendMessage(mcLocale.getString("Skills.Disarmed"));
|
||||||
@ -69,7 +73,7 @@ public class Unarmed {
|
|||||||
int skillLevel = Users.getProfile(defender).getSkillLevel(SkillType.UNARMED);
|
int skillLevel = Users.getProfile(defender).getSkillLevel(SkillType.UNARMED);
|
||||||
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL);
|
||||||
|
|
||||||
if (Math.random() * 2000 <= skillCheck && mcPermissions.getInstance().deflect(defender)) {
|
if (random.nextInt(2000) <= skillCheck && mcPermissions.getInstance().deflect(defender)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
defender.sendMessage(mcLocale.getString("Combat.ArrowDeflect"));
|
defender.sendMessage(mcLocale.getString("Combat.ArrowDeflect"));
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.gmail.nossr50.skills;
|
package com.gmail.nossr50.skills;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.TreeSpecies;
|
import org.bukkit.TreeSpecies;
|
||||||
@ -26,6 +27,8 @@ import org.getspout.spoutapi.sound.SoundEffect;
|
|||||||
|
|
||||||
public class WoodCutting {
|
public class WoodCutting {
|
||||||
|
|
||||||
|
private static Random random = new Random();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle the Tree Feller ability.
|
* Handle the Tree Feller ability.
|
||||||
*
|
*
|
||||||
@ -69,7 +72,7 @@ public class WoodCutting {
|
|||||||
int health = player.getHealth();
|
int health = player.getHealth();
|
||||||
|
|
||||||
if (health >= 2) {
|
if (health >= 2) {
|
||||||
Combat.dealDamage(player, (int)(Math.random() * (health - 1)));
|
Combat.dealDamage(player, random.nextInt(health - 1));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -249,7 +252,7 @@ public class WoodCutting {
|
|||||||
byte type = block.getData();
|
byte type = block.getData();
|
||||||
Material mat = Material.getMaterial(block.getTypeId());
|
Material mat = Material.getMaterial(block.getTypeId());
|
||||||
|
|
||||||
if ((skillLevel > MAX_SKILL_LEVEL || Math.random() * 1000 <= skillLevel) && mcPermissions.getInstance().woodcuttingDoubleDrops(player)) {
|
if ((skillLevel > MAX_SKILL_LEVEL || random.nextInt(1000) <= skillLevel) && mcPermissions.getInstance().woodcuttingDoubleDrops(player)) {
|
||||||
ItemStack item = new ItemStack(mat, 1, (short) 0, type);
|
ItemStack item = new ItemStack(mat, 1, (short) 0, type);
|
||||||
m.mcDropItem(block.getLocation(), item);
|
m.mcDropItem(block.getLocation(), item);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user