Advertisement
Guest User

Untitled

a guest
Aug 28th, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.57 KB | None | 0 0
  1. import java.io.ByteArrayOutputStream;
  2. import java.io.DataOutputStream;
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.util.List;
  6.  
  7. import org.bukkit.Bukkit;
  8. import org.bukkit.ChatColor;
  9. import org.bukkit.Difficulty;
  10. import org.bukkit.Material;
  11. import org.bukkit.Sound;
  12. import org.bukkit.World;
  13. import org.bukkit.WorldCreator;
  14. import org.bukkit.entity.Entity;
  15. import org.bukkit.entity.EntityType;
  16. import org.bukkit.entity.Item;
  17. import org.bukkit.entity.Player;
  18. import org.bukkit.inventory.ItemStack;
  19.  
  20. public class Functions {
  21.      
  22.  
  23.     public static void clearItem(){
  24.         World world = Main.plugin.getServer().getWorld("world");
  25.         List<Entity> entList = world.getEntities();
  26.  
  27.         for(Entity current : entList){
  28.             if (current instanceof Item) current.remove();
  29.         }
  30.     }
  31.      
  32.     public static void clearInv(Player p){
  33.         p.getInventory().clear();
  34.         p.getInventory().setHelmet(new ItemStack (Material.AIR));
  35.         p.getInventory().setChestplate(new ItemStack (Material.AIR));
  36.         p.getInventory().setLeggings(new ItemStack (Material.AIR));
  37.         p.getInventory().setBoots(new ItemStack (Material.AIR));
  38.     }
  39.  
  40.     static void xpLevel(int level) {
  41.         for(Player p : Bukkit.getOnlinePlayers()){
  42.             p.setLevel(level);
  43.         }
  44.     }
  45.  
  46.     static void xpSound() {
  47.         for(Player p : Bukkit.getOnlinePlayers()){
  48.             p.playSound(p.getLocation(), Sound.ORB_PICKUP, 1, 0);
  49.         }
  50.     }
  51.      
  52.     static void witherSound(){
  53.         for(Player p : Bukkit.getOnlinePlayers()){
  54.             p.playSound(p.getLocation(), Sound.WITHER_SPAWN, 1, 1);
  55.         }
  56.     }
  57.      
  58.     static void noteboxSound(){
  59.         for(Player p : Bukkit.getOnlinePlayers()){
  60.             p.playSound(p.getLocation(), Sound.NOTE_PLING, 1, 0);
  61.         }
  62.     }
  63.      
  64.     static void CountDown(){        
  65.         if(Main.CountDown == 0) {
  66.             Bukkit.broadcastMessage(Main.prefix + ChatColor.RED + "Le jeux commence");
  67.         }
  68.         else if(Main.CountDown > 60){
  69.             Bukkit.broadcastMessage(Main.prefix + ChatColor.GOLD + ""+ Main.CountDown + " seconde(s) avant que le jeu commence");
  70.         }
  71.         else if (Main.CountDown > 5 && Main.CountDown < 60){
  72.             Bukkit.broadcastMessage(Main.prefix + ChatColor.GOLD + "" + Main.CountDown + " seconde(s) avant que le jeu commence");
  73.             xpSound();
  74.         }
  75.         else{
  76.             Bukkit.broadcastMessage(Main.prefix + ChatColor.GOLD + "" + Main.CountDown + " seconde(s) avant que le jeu commence");
  77.             noteboxSound();
  78.         }
  79.     }
  80.      
  81.     public static void gotohub(Player p){
  82.         Bukkit.getMessenger().registerOutgoingPluginChannel(Main.plugin, "BungeeCord");
  83.          
  84.         ByteArrayOutputStream b = new ByteArrayOutputStream();
  85.         DataOutputStream out = new DataOutputStream(b);
  86.                          
  87.         try {
  88.             out.writeUTF("Connect");
  89.             out.writeUTF("lobby");
  90.          } catch (IOException ex) {}
  91.          
  92.         p.sendPluginMessage(Main.plugin, "BungeeCord", b.toByteArray());    
  93.     }
  94.      
  95.     public static void ClearDrops(){
  96.         World w = Bukkit.getServer().getWorld("world");
  97.         if (w == null) return;
  98.         for (Entity e : w.getEntities()){
  99.             if (e.getType() == EntityType.DROPPED_ITEM) e.remove();
  100.         }
  101.     }
  102.      
  103.     public static void resetMap() {
  104.         // On désactive la map
  105.         Bukkit.unloadWorld("map", false);
  106.  
  107.         File src = new File("plugins/MgCore/map");
  108.         File dest = new File("map/");
  109.  
  110.         FilesFunctions.deleteDirectory(dest);
  111.         try {
  112.             FilesFunctions.copyFolder(src, dest);      
  113.              
  114.         } catch (IOException e) { e.printStackTrace(); Bukkit.shutdown(); }
  115.          
  116.         Bukkit.getServer().createWorld(new WorldCreator("map"));
  117.  
  118.         Bukkit.getWorld("map").setKeepSpawnInMemory(false);
  119.         Bukkit.getWorld("map").setDifficulty(Difficulty.EASY);
  120.          
  121.         Bukkit.getWorld("map").setAnimalSpawnLimit(0);
  122.         Bukkit.getWorld("map").setMonsterSpawnLimit(0);
  123.          
  124.         Bukkit.getServer().getWorld("map").setGameRuleValue("doDaylightCycle", "false");
  125.         Bukkit.getServer().getWorld("map").setTime(Main.doDaylightCycleStart);
  126.          
  127.         if(Main.hardcore) Bukkit.getServer().getWorld("map").setGameRuleValue("naturalRegeneration", "false");
  128.         else Bukkit.getServer().getWorld("map").setGameRuleValue("naturalRegeneration", "true");
  129.          
  130.         Bukkit.getWorld("map").setPVP(true);
  131.          
  132.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement