Пример #1
0
  public static void check(
      LivingEntity defender, RpgEssentials plugin, EntityDamageByEntityEvent event1) {
    String skilltype = "Defense";
    Player player = (Player) defender;
    DamageCause cause = event1.getCause();
    boolean god = false;
    if (Bukkit.getPluginManager()
        .isPluginEnabled(Bukkit.getPluginManager().getPlugin("WorldGuard"))) {
      WorldGuardPlugin worldguard =
          (WorldGuardPlugin) Bukkit.getPluginManager().getPlugin("WorldGuard");
      god = worldguard.getGlobalStateManager().hasGodMode(player);
    }

    if (Configuration.level.getBoolean("Survival Gamemode Required") == true) {
      if (player.getGameMode() == GameMode.SURVIVAL && god == false) {
        if (cause == DamageCause.ENTITY_ATTACK) {
          addexp = Configuration.level.getInt("Exp." + skilltype + ".Entity Attack");
        } else if (cause == DamageCause.BLOCK_EXPLOSION) {
          addexp = Configuration.level.getInt("Exp." + skilltype + ".Block Explosion");
        } else if (cause == DamageCause.ENTITY_EXPLOSION) {
          addexp = Configuration.level.getInt("Exp." + skilltype + ".Entity Explosion");
        } else if (cause == DamageCause.PROJECTILE) { // TODO DOESN'T WORK
          addexp = Configuration.level.getInt("Exp." + skilltype + ".Projectile");
        }
        LevelingSystem.addexp(player, skilltype, addexp, plugin);
      }
    } else {
      if (cause == DamageCause.ENTITY_ATTACK) {
        addexp = Configuration.level.getInt("Exp." + skilltype + ".Entity Attack");
      } else if (cause == DamageCause.BLOCK_EXPLOSION) {
        addexp = Configuration.level.getInt("Exp." + skilltype + ".Block Explosion");
      } else if (cause == DamageCause.ENTITY_EXPLOSION) {
        addexp = Configuration.level.getInt("Exp." + skilltype + ".Entity Explosion");
      } else if (cause == DamageCause.PROJECTILE) {
        addexp = Configuration.level.getInt("Exp." + skilltype + ".Projectile");
      }
      LevelingSystem.addexp(player, skilltype, addexp, plugin);
    }
  }
Пример #2
0
  public static void blockcheck(Block block, Player player, RpgEssentials plugin) {

    int addexp;
    String skilltype = "Woodcutting";
    if (block.getType() == Material.LOG) {
      // normal log
      if (block.getData() == (byte) 0) {
        addexp = Configuration.level.getInt("Exp." + skilltype + ".Oak Log");
        LevelingSystem.addexp(player, skilltype, addexp, plugin);
        // redwood
      } else if (block.getData() == (byte) 1) {
        addexp = Configuration.level.getInt("Exp." + skilltype + ".Redwood Log");
        LevelingSystem.addexp(player, skilltype, addexp, plugin);
        // birch
      } else if (block.getData() == (byte) 2) {
        addexp = Configuration.level.getInt("Exp." + skilltype + ".Birch Log");
        LevelingSystem.addexp(player, skilltype, addexp, plugin);
      }
    } else if (block.getType() == Material.WOOD) {
      addexp = Configuration.level.getInt("Exp." + skilltype + ".Wood");
      LevelingSystem.addexp(player, skilltype, addexp, plugin);
    } else if (block.getType() == Material.FENCE) {
      addexp = Configuration.level.getInt("Exp." + skilltype + ".Fence");
      LevelingSystem.addexp(player, skilltype, addexp, plugin);
    } else if (block.getType() == Material.STEP) {
      if (block.getData() == (byte) 2) {
        addexp = Configuration.level.getInt("Exp." + skilltype + ".Wood Slab");
        LevelingSystem.addexp(player, skilltype, addexp, plugin);
      }
    } else if (block.getType() == Material.DOUBLE_STEP) {
      if (block.getData() == (byte) 2) {
        addexp = Configuration.level.getInt("Exp." + skilltype + ".Wood Slab");
        LevelingSystem.addexp(player, skilltype, addexp + 5, plugin);
      }
    } else if (block.getType() == Material.WOOD_STAIRS) {
      addexp = Configuration.level.getInt("Exp." + skilltype + ".Wood Stairs");
      LevelingSystem.addexp(player, skilltype, addexp + 5, plugin);
    }
  }