Beispiel #1
0
 public static boolean isOnSnitch(Snitch snitch, String playerName) {
   Faction faction = snitch.getGroup();
   if (faction == null) return false;
   return faction.isMember(playerName)
       || faction.isModerator(playerName)
       || faction.isFounder(playerName);
 }
Beispiel #2
0
 public boolean execute(CommandSender sender, String[] args) {
   String groupName = args[0];
   GroupManager groupManager = Citadel.getGroupManager();
   Faction group = groupManager.getGroup(groupName);
   if (group == null) {
     sendMessage(sender, ChatColor.RED, "Group doesn't exist");
     return true;
   }
   if (group.isDisciplined()) {
     sendMessage(sender, ChatColor.RED, Faction.kDisciplineMsg);
     return true;
   }
   String senderName = sender.getName();
   if (!group.isFounder(senderName) && !group.isModerator(senderName)) {
     sendMessage(sender, ChatColor.RED, "Invalid access to modify this group");
     return true;
   }
   if (group.isPersonalGroup()) {
     sendMessage(sender, ChatColor.RED, "You cannot allow players to your default group");
     return true;
   }
   String playerName = args[1];
   if (!group.isMember(playerName)) {
     sendMessage(sender, ChatColor.RED, "%s is not a member of this group", playerName);
     return true;
   }
   groupManager.removeMemberFromGroup(groupName, playerName);
   sendMessage(
       sender,
       ChatColor.GREEN,
       "Disallowed %s from access to %s blocks",
       playerName,
       group.getName());
   return true;
 }
  public void setSuperEffects(Location loc, int tier) {
    int one = config_.getInt("beacon_super.range");
    int dist[] = {0, one};

    Faction group = groupname(loc);
    if (group == null) {
      return;
    }
    for (Player name : Bukkit.getOnlinePlayers()) {
      int level = 1;
      if (!group.isMember(name.getUniqueId())
          && !group.isModerator(name.getUniqueId())
          && !group.isFounder(name.getUniqueId())) {
        level = 3;
        PotionEffectType Types1[] = {PotionEffectType.WEAKNESS};
        for (PotionEffectType type : Types1) {
          if (type == PotionEffectType.WEAKNESS) level = 1;
          negativeeffecttype(name, loc, 50, level, type);
        }
        continue;
      }
      if (group.isPersonalGroup()) {
        if (group.equals(
            Citadel.getPersonalGroupManager()
                .getPersonalGroup(name.getUniqueId())
                .getGroupName())) {
          PotionEffectType Types[] = {
            PotionEffectType.FAST_DIGGING,
            PotionEffectType.REGENERATION,
            PotionEffectType.INCREASE_DAMAGE,
            PotionEffectType.SPEED
          };
          for (PotionEffectType type : Types) {
            effecttype(name, loc, dist, tier, level, type);
          }
        }
      } else {
        PotionEffectType Types[] = {
          PotionEffectType.FAST_DIGGING,
          PotionEffectType.REGENERATION,
          PotionEffectType.INCREASE_DAMAGE,
          PotionEffectType.SPEED
        };
        for (PotionEffectType type : Types) {
          effecttype(name, loc, dist, tier, level, type);
        }
      }
    }
  }
  public void setSpeedEffects(Location loc, int tier) {
    int level = 0;
    int one = config_.getInt("beacon_speed.tier_1.range");
    int two = config_.getInt("beacon_speed.tier_2.range");
    int three = config_.getInt("beacon_speed.tier_3.range");
    int four = config_.getInt("beacon_speed.tier_4.range");
    int five = config_.getInt("beacon_speed.tier_5.range");
    int dist[] = {0, one, two, three, four, five}; // Distances for this
    // beacon; In Array
    // form because if
    // someone wants a
    // 6th lvl, it can
    // be done without
    // changing alot of
    // code.
    switch (tier) { // if tier == 4 || 5, level = 1;
      case 4:
      case 5:
        level = 1;
        break;
    }

    Faction group = groupname(loc);
    if (group == null) {
      return;
    }
    for (Player name : Bukkit.getOnlinePlayers()) {

      if (!group.isMember(name.getUniqueId())
          && !group.isModerator(name.getUniqueId())
          && !group.isFounder(name.getUniqueId())) {
        continue;
      } else if (group.isPersonalGroup()) {
        if (group.equals(
            Citadel.getPersonalGroupManager()
                .getPersonalGroup(name.getUniqueId())
                .getGroupName())) {
          effecttype(name, loc, dist, tier, level, PotionEffectType.SPEED);
        }
      } else {
        effecttype(name, loc, dist, tier, level, PotionEffectType.SPEED);
      }
    }
  }
  public void setStrengthEffects(Location loc, int tier) {
    int level = 0;
    int one = config_.getInt("beacon_strength.tier_1.range");
    int two = config_.getInt("beacon_strength.tier_1.range");
    int three = config_.getInt("beacon_strength.tier_1.range");
    int four = config_.getInt("beacon_strength.tier_1.range");
    int five = config_.getInt("beacon_strength.tier_1.range");
    int dist[] = {0, one, two, three, four, five};

    switch (tier) {
      case 4:
      case 5:
        level = 1;
        break;
    }

    Faction group = groupname(loc);
    if (group == null) {
      return;
    }
    for (Player name : Bukkit.getOnlinePlayers()) {
      if (!group.isMember(name.getUniqueId())
          && !group.isModerator(name.getUniqueId())
          && !group.isFounder(name.getUniqueId())) {
        continue;
      } else if (group.isPersonalGroup()) {
        if (group.equals(
            Citadel.getPersonalGroupManager()
                .getPersonalGroup(name.getUniqueId())
                .getGroupName())) {
          effecttype(name, loc, dist, tier, level, PotionEffectType.INCREASE_DAMAGE);
        }
      } else {
        effecttype(name, loc, dist, tier, level, PotionEffectType.INCREASE_DAMAGE);
      }
    }
  }
  @EventHandler(priority = EventPriority.HIGHEST)
  public void reinforceSnitchBlock(CreateReinforcementEvent event) {
    if (event.isCancelled()) {
      return;
    }
    Block block = event.getBlock();
    if (block.getType().equals(Material.JUKEBOX)) {

      Player player = event.getPlayer();
      Location loc = block.getLocation();
      AccessDelegate access = AccessDelegate.getDelegate(block);
      IReinforcement rei = event.getReinforcement();
      if (rei instanceof PlayerReinforcement) {
        PlayerReinforcement reinforcement = (PlayerReinforcement) rei;
        Faction owner = reinforcement.getOwner();
        if (reinforcement.getSecurityLevel().equals(SecurityLevel.GROUP)) {
          Snitch snitch;
          if (snitchManager.getSnitch(loc.getWorld(), loc) != null) {
            snitch = snitchManager.getSnitch(loc.getWorld(), loc);
            plugin
                .getJaLogger()
                .updateSnitchGroup(snitchManager.getSnitch(loc.getWorld(), loc), owner.getName());
            snitchManager.removeSnitch(snitch);
            snitch.setGroup(owner);
          } else {
            snitch = new Snitch(loc, owner, true);
            plugin
                .getJaLogger()
                .logSnitchPlace(
                    player.getWorld().getName(),
                    owner.getName(),
                    "",
                    loc.getBlockX(),
                    loc.getBlockY(),
                    loc.getBlockZ(),
                    true);
            snitch.setId(plugin.getJaLogger().getLastSnitchID());
            plugin.getJaLogger().increaseLastSnitchID();
          }
          snitchManager.addSnitch(snitch);

          player.sendMessage(
              ChatColor.AQUA
                  + "You've created a snitch block registered to the group "
                  + owner.getName()
                  + ".  To name your snitch, type /janame.");
        } else {
          Snitch snitch;
          if (snitchManager.getSnitch(loc.getWorld(), loc) != null) {
            snitch = snitchManager.getSnitch(loc.getWorld(), loc);
            plugin
                .getJaLogger()
                .updateSnitchGroup(
                    snitchManager.getSnitch(loc.getWorld(), loc), owner.getFounder());
            snitchManager.removeSnitch(snitch);
            snitch.setGroup(owner);
          } else {
            snitch = new Snitch(loc, owner, true);
            plugin
                .getJaLogger()
                .logSnitchPlace(
                    player.getWorld().getName(),
                    owner.getFounder(),
                    "",
                    loc.getBlockX(),
                    loc.getBlockY(),
                    loc.getBlockZ(),
                    true);
            snitch.setId(plugin.getJaLogger().getLastSnitchID());
            plugin.getJaLogger().increaseLastSnitchID();
          }
          snitchManager.addSnitch(snitch);

          player.sendMessage(
              ChatColor.AQUA
                  + "You've created a private snitch block; reinforce it with a group to register members.  To name your snitch, type /janame.");
        }
      }
    } else if (block.getType().equals(Material.NOTE_BLOCK)) {
      Player player = event.getPlayer();
      Location loc = block.getLocation();
      AccessDelegate access = AccessDelegate.getDelegate(block);
      IReinforcement rei = event.getReinforcement();
      if (rei instanceof PlayerReinforcement) {
        PlayerReinforcement reinforcement = (PlayerReinforcement) rei;
        Faction owner = reinforcement.getOwner();
        if (reinforcement.getSecurityLevel().equals(SecurityLevel.GROUP)) {
          Snitch snitch;
          if (snitchManager.getSnitch(loc.getWorld(), loc) != null) {
            snitch = snitchManager.getSnitch(loc.getWorld(), loc);
            plugin
                .getJaLogger()
                .updateSnitchGroup(snitchManager.getSnitch(loc.getWorld(), loc), owner.getName());
            snitchManager.removeSnitch(snitch);
            snitch.setGroup(owner);
          } else {
            snitch = new Snitch(loc, owner, false);
            plugin
                .getJaLogger()
                .logSnitchPlace(
                    player.getWorld().getName(),
                    owner.getName(),
                    "",
                    loc.getBlockX(),
                    loc.getBlockY(),
                    loc.getBlockZ(),
                    false);
            snitch.setId(plugin.getJaLogger().getLastSnitchID());
            plugin.getJaLogger().increaseLastSnitchID();
          }
          snitchManager.addSnitch(snitch);

          player.sendMessage(
              ChatColor.AQUA
                  + "You've created an entry snitch registered to the group "
                  + owner.getName()
                  + ".  To name your entry snitch, type /janame.");
        } else {
          Snitch snitch;
          if (snitchManager.getSnitch(loc.getWorld(), loc) != null) {
            snitch = snitchManager.getSnitch(loc.getWorld(), loc);
            plugin
                .getJaLogger()
                .updateSnitchGroup(
                    snitchManager.getSnitch(loc.getWorld(), loc), owner.getFounder());
            snitchManager.removeSnitch(snitch);
            snitch.setGroup(owner);
          } else {
            snitch = new Snitch(loc, owner, false);
            plugin
                .getJaLogger()
                .logSnitchPlace(
                    player.getWorld().getName(),
                    owner.getFounder(),
                    "",
                    loc.getBlockX(),
                    loc.getBlockY(),
                    loc.getBlockZ(),
                    false);
            snitch.setId(plugin.getJaLogger().getLastSnitchID());
            plugin.getJaLogger().increaseLastSnitchID();
          }
          snitchManager.addSnitch(snitch);

          player.sendMessage(
              ChatColor.AQUA
                  + "You've created a private entry snitch; reinforce it with a group to register members.  To name your entry snitch, type /janame.");
        }
      }
    }
  }