Ejemplo n.º 1
0
 // Sets the next location in the list as active.
 public void cycle() {
   switch (mode) {
     case TELEPORT:
       ++currentLocation;
       if (currentLocation >= locations.size()) {
         currentLocation = 0;
       }
       break;
     case SPAWN:
       this.mob =
           CreatureType.values()[
               mobIndex >= CreatureType.values().length ? (mobIndex = 0) : ++mobIndex];
       break;
     case TIME:
       String time = this.time;
       String newTime = "";
       if (time.equals("morning")) {
         newTime = "day";
       } else if (time.equals("day")) {
         newTime = "afternoon";
       } else if (time.equals("afternoon")) {
         newTime = "night";
       } else if (time.equals("night")) {
         newTime = "morning";
       }
       this.time = newTime;
       break;
   }
 }
Ejemplo n.º 2
0
 @Override
 public void save(Storage profiles, int UID) {
   profiles.setBoolean(UID + ".wizard.unlimited-mana", unlimitedMana);
   profiles.setString(UID + ".wizard.time", time);
   profiles.setString(UID + ".wizard.mode", mode.name());
   profiles.setInt(UID + ".wizard.mana", mana);
   profiles.setString(UID + ".wizard.locations", Joiner.on(":").skipNulls().join(locations));
   profiles.setString(UID + ".wizard.mob", mob.name());
 }
Ejemplo n.º 3
0
 public Map<String, Boolean> getEpGuardSettings() {
   final Map<String, Boolean> epSettings = new HashMap<String, Boolean>();
   epSettings.put(
       "protect.prevent.lava-flow", config.getBoolean("protect.prevent.lava-flow", false));
   epSettings.put(
       "protect.prevent.water-flow", config.getBoolean("protect.prevent.water-flow", false));
   epSettings.put(
       "protect.prevent.water-bucket-flow",
       config.getBoolean("protect.prevent.water-bucket-flow", false));
   epSettings.put(
       "protect.prevent.fire-spread", config.getBoolean("protect.prevent.fire-spread", true));
   epSettings.put(
       "protect.prevent.flint-fire", config.getBoolean("protect.prevent.flint-fire", false));
   epSettings.put(
       "protect.prevent.portal-creation",
       config.getBoolean("protect.prevent.portal-creation", false));
   epSettings.put(
       "protect.prevent.lava-fire-spread",
       config.getBoolean("protect.prevent.lava-fire-spread", true));
   epSettings.put(
       "protect.prevent.tnt-explosion", config.getBoolean("protect.prevent.tnt-explosion", false));
   epSettings.put(
       "protect.prevent.creeper-explosion",
       config.getBoolean("protect.prevent.creeper-explosion", false));
   epSettings.put(
       "protect.prevent.creeper-playerdamage",
       config.getBoolean("protect.prevent.creeper-playerdamage", false));
   epSettings.put(
       "protect.prevent.creeper-blockdamage",
       config.getBoolean("protect.prevent.creeper-blockdamage", false));
   epSettings.put(
       "protect.prevent.entitytarget", config.getBoolean("protect.prevent.entitytarget", false));
   for (CreatureType ct : CreatureType.values()) {
     final String name = ct.toString().toLowerCase();
     epSettings.put(
         "protect.prevent.spawn." + name,
         config.getBoolean("protect.prevent.spawn." + name, false));
   }
   epSettings.put(
       "protect.prevent.lightning-fire-spread",
       config.getBoolean("protect.prevent.lightning-fire-spread", true));
   return epSettings;
 }
  @Override
  public void onCreatureSpawn(CreatureSpawnEvent event) {
    if (event.isCancelled()) {
      return;
    }

    GlobalConfiguration cfg = plugin.getGlobalConfiguration();
    WorldConfiguration wcfg = cfg.getWorldConfig(event.getEntity().getWorld().getName());

    // CreatureType creaType = (CreatureType) CreatureType.valueOf(event.getMobType().toString());
    CreatureType creaType = event.getCreatureType();
    String creaName = "";
    Boolean cancelEvent = false;

    if (wcfg.blockCreatureSpawn.contains(creaType)) {
      cancelEvent = true;
    }

    if (wcfg.useRegions) {
      Vector pt = toVector(event.getEntity().getLocation());
      RegionManager mgr =
          plugin.getGlobalRegionManager().getRegionManager(event.getEntity().getWorld().getName());

      Boolean flagValue =
          mgr.getApplicableRegions(pt)
              .getStringFlag(Flags.DENY_SPAWN, true)
              .getValue("")
              .contains(creaType.getName());
      if (flagValue != null) {
        if (flagValue) {
          cancelEvent = true;
        } else {
          cancelEvent = false;
        }
      }
    }

    if (cancelEvent) {
      event.setCancelled(true);
      return;
    }
  }
Ejemplo n.º 5
0
 @Override
 public void load(Storage profiles, int UID) {
   unlimitedMana = profiles.getBoolean(UID + ".wizard.unlimited-mana");
   time = profiles.getString(UID + ".wizard.time", "morning");
   mode =
       (profiles.keyExists(UID + ".wizard.mode")
               && WizardMode.parse(profiles.getString(UID + ".wizard.mode")) != null)
           ? WizardMode.parse(profiles.getString(UID + ".wizard.mode"))
           : WizardMode.TELEPORT;
   mana = profiles.getInt(UID + ".wizard.mana", 10);
   locations.clear();
   for (String location : splitter.split(profiles.getString(UID + ".wizard.locations"))) {
     locations.add(location.replace("(", "").replace(")", ""));
   }
   mob =
       (CreatureType.fromName(profiles.getString(UID + ".wizard.mob")) != null)
           ? CreatureType.fromName(profiles.getString(UID + ".wizard.mob"))
           : CreatureType.CREEPER;
   mobIndex = mob.ordinal();
 }
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onCreatureSpawn(final CreatureSpawnEvent event) {
   if (event.getEntity() instanceof Player) {
     return;
   }
   if (event.isCancelled()) {
     return;
   }
   final CreatureType creature = event.getCreatureType();
   if (creature == null) {
     return;
   }
   final String creatureName = creature.toString().toLowerCase(Locale.ENGLISH);
   if (creatureName == null || creatureName.isEmpty()) {
     return;
   }
   if (ess.getSettings().getProtectPreventSpawn(creatureName)) {
     event.setCancelled(true);
   }
 }
Ejemplo n.º 7
0
 @Deprecated
 public void setCreatureType(CreatureType creatureType) {
   spawner.setMobID(creatureType.getName());
 }
Ejemplo n.º 8
0
 @Deprecated
 public CreatureType getCreatureType() {
   return CreatureType.fromName(spawner.getMobEntity().getEntityName());
 }