Advertisement
chumanista

Untitled

Jun 29th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. package com.chumanista.youtube;
  2.  
  3. import java.util.Random;
  4.  
  5. import org.apache.commons.lang.Validate;
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.ChatColor;
  8.  
  9. public class Utils {
  10.    
  11.     private static final Random rand = new Random();
  12.    
  13.     public static int getRandInt (int min, int max) throws IllegalArgumentException {
  14.        
  15.         Validate.isTrue(max > min, "Max can't be smaller than min");
  16.        
  17.         return rand.nextInt(max - min + 1) + min;
  18.     }
  19.    
  20.     public static double getRandDouble (double min, double max) throws IllegalArgumentException {
  21.        
  22.         Validate.isTrue(max > min, "Max can't be smaller than min");
  23.        
  24.         return rand.nextDouble() * (max - min) + min;
  25.     }  
  26.    
  27.     public static boolean getChance (double chance) {
  28.         return (chance >= 100) || (chance >= getRandDouble(0, 100));
  29.     }
  30.    
  31.     public static void error (String msg) {
  32.         Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "[PremiumCase] [ERROR] " + msg);
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement