Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.72 KB | None | 0 0
  1. public void onEnable(){
  2.  
  3. /* Clear les mobs / Animaux */
  4.         for (Iterator iterator = getServer().getWorld("world").getEntities().iterator(); iterator.hasNext(); ) {
  5.           Entity entity = (Entity)iterator.next();
  6.           EntityType mob = entity.getType();
  7.           if (mob != EntityType.PLAYER && mob != EntityType.ARMOR_STAND && mob != EntityType.ITEM_FRAME && mob != EntityType.PAINTING)          entity.remove();
  8.         }      
  9.        
  10.         /* Init l'heure et le weather */
  11.         Bukkit.getWorld("world").setThundering(false);
  12.         Bukkit.getWorld("world").setStorm(false);
  13.         Bukkit.getWorld("world").setPVP(false);
  14.         Bukkit.getWorld("world").setTime(10000);
  15.        
  16.         /* Gamerules onLoad */
  17.         Bukkit.getWorld("world").setGameRuleValue("doDaylightCycle", "false");
  18.         Bukkit.getWorld("world").setGameRuleValue("doMobSpawning", "false");
  19.         Bukkit.getWorld("world").setGameRuleValue("doWeatherCycle", "false");
  20.         Bukkit.getWorld("world").setGameRuleValue("showDeathMessages", "false");
  21.         Bukkit.getWorld("world").setGameRuleValue("announceAdvancements", "false");
  22.         Bukkit.getWorld("world").setGameRuleValue("mobGriefing", "false");
  23.            
  24.  
  25. }
  26.  
  27.  
  28. /* DANS LE LISTENERS : */
  29.  
  30.  
  31. /* Désactiver le spawn des mobs / animaux */
  32.     @EventHandler
  33.     public void onCreatureSpawn(CreatureSpawnEvent event) {
  34.        
  35.         if(event.getLocation().getWorld().getName().equalsIgnoreCase("world")) {
  36.            
  37.             if(event.getSpawnReason() != CreatureSpawnEvent.SpawnReason.DEFAULT) {
  38.                 event.setCancelled(true);
  39.                
  40.             }
  41.            
  42.         }
  43.        
  44.         return;
  45.        
  46.     }
  47.    
  48.     /* Désactiver les explosions de tnt */
  49.     @EventHandler
  50.     public void onExplosion(EntityExplodeEvent event){
  51.         if(event.getEntity().getType() == EntityType.PRIMED_TNT){
  52.             event.setCancelled(true);
  53.         }
  54.         return;
  55.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement