Advertisement
Guest User

Untitled

a guest
Jun 29th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 KB | None | 0 0
  1. package hu.Scaarry.Mindenes;
  2.  
  3. import org.bukkit.configuration.file.FileConfiguration;
  4. import org.bukkit.configuration.file.YamlConfiguration;
  5. import org.bukkit.event.Listener;
  6. import org.bukkit.event.entity.PlayerDeathEvent;
  7.  
  8. import java.io.File;
  9. import java.util.ArrayList;
  10. import java.util.List;
  11. import java.util.Random;
  12.  
  13. public class halaluzenetek implements Listener {
  14.  
  15.     private static List<String> _messages = new ArrayList<>();
  16.    
  17.     private static final File FILE = new File("plugins/Mindenes", "halaluzenetek.yml");
  18.     private static FileConfiguration cfg = YamlConfiguration.loadConfiguration(FILE);
  19.  
  20.     public static void init()
  21.     {
  22.        
  23.         for(String message : cfg.getStringList("Messages"))
  24.         {
  25.             _messages.add(message);
  26.         }
  27.     }
  28.  
  29.     public void onPlayerDeath(PlayerDeathEvent e)
  30.     {
  31.         String message = _messages.get(randInt(0, _messages.size()));
  32.         message = message.replaceAll("%p", e.getEntity().getName());
  33.        
  34.         e.setDeathMessage(message);
  35.     }
  36.  
  37.     private int randInt(int min, int max)
  38.     {
  39.         Random random = new Random();
  40.         int    randomNum = random.nextInt((max - min) + 1) + min;
  41.         return randomNum;
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement