コード例 #1
0
 public boolean addResidence(String name, String owner, Location loc1, Location loc2) {
   if (!Residence.validName(name)) return false;
   if (loc1 == null
       || loc2 == null
       || !loc1.getWorld().getName().equals(loc2.getWorld().getName())) {
     return false;
   }
   PermissionGroup group =
       Residence.getPermissionManager().getGroup(owner, loc1.getWorld().getName());
   CuboidArea newArea = new CuboidArea(loc1, loc2);
   ClaimedResidence newRes = new ClaimedResidence(owner, loc1.getWorld().getName());
   newRes.getPermissions().applyDefaultFlags();
   newRes.setEnterMessage(group.getDefaultEnterMessage());
   newRes.setLeaveMessage(group.getDefaultLeaveMessage());
   ResidenceCreationEvent resevent = new ResidenceCreationEvent(null, name, newRes, newArea);
   Residence.getServ().getPluginManager().callEvent(resevent);
   if (resevent.isCancelled()) {
     return false;
   }
   newArea = resevent.getPhysicalArea();
   name = resevent.getResidenceName();
   if (residences.containsKey(name)) {
     return false;
   }
   newRes.addArea(newArea, "main");
   if (newRes.getAreaCount() != 0) {
     residences.put(name, newRes);
   }
   return true;
 }
コード例 #2
0
 public void giveResidence(
     Player reqPlayer, String targPlayer, String residence, boolean resadmin) {
   ClaimedResidence res = getByName(residence);
   if (res == null) {
     reqPlayer.sendMessage("§c" + Residence.getLanguage().getPhrase("InvalidResidence"));
     return;
   }
   if (!res.getPermissions().hasResidencePermission(reqPlayer, true) && !resadmin) {
     reqPlayer.sendMessage("§c" + Residence.getLanguage().getPhrase("NoPermission"));
     return;
   }
   Player giveplayer = Residence.getServ().getPlayer(targPlayer);
   if (giveplayer == null || !giveplayer.isOnline()) {
     reqPlayer.sendMessage("§c" + Residence.getLanguage().getPhrase("NotOnline"));
     return;
   }
   CuboidArea[] areas = res.getAreaArray();
   PermissionGroup g = Residence.getPermissionManager().getGroup(giveplayer);
   if (areas.length > g.getMaxPhysicalPerResidence() && !resadmin) {
     reqPlayer.sendMessage("§c" + Residence.getLanguage().getPhrase("ResidenceGiveLimits"));
     return;
   }
   if (getOwnedZoneCount(giveplayer.getName()) >= g.getMaxZones() && !resadmin) {
     reqPlayer.sendMessage("§c" + Residence.getLanguage().getPhrase("ResidenceGiveLimits"));
     return;
   }
   if (!resadmin) {
     for (CuboidArea area : areas) {
       if (!g.inLimits(area)) {
         reqPlayer.sendMessage("§c" + Residence.getLanguage().getPhrase("ResidenceGiveLimits"));
         return;
       }
     }
   }
   res.getPermissions().setOwner(giveplayer.getName(), true);
   reqPlayer.sendMessage(
       "§a"
           + Residence.getLanguage()
               .getPhrase(
                   "ResidenceGive", "§e" + residence + "§a.§e" + giveplayer.getName() + "§a"));
   giveplayer.sendMessage(
       Residence.getLanguage()
           .getPhrase(
               "ResidenceRecieve", "§a" + reqPlayer.getName() + "§e.§a" + residence + "§e"));
 }
コード例 #3
0
 public void applyDefaultFlags() {
   PermissionManager gm = Residence.getPermissionManager();
   PermissionGroup group = gm.getGroup(this.getOwner(), world);
   Set<Entry<String, Boolean>> dflags = group.getDefaultResidenceFlags();
   Set<Entry<String, Boolean>> dcflags = group.getDefaultCreatorFlags();
   Set<Entry<String, Map<String, Boolean>>> dgflags = group.getDefaultGroupFlags();
   this.applyGlobalDefaults();
   for (Entry<String, Boolean> next : dflags) {
     if (this.checkValidFlag(next.getKey(), true)) {
       if (next.getValue()) {
         this.setFlag(next.getKey(), FlagState.TRUE);
       } else {
         this.setFlag(next.getKey(), FlagState.FALSE);
       }
     }
   }
   for (Entry<String, Boolean> next : dcflags) {
     if (this.checkValidFlag(next.getKey(), false)) {
       if (next.getValue()) {
         this.setPlayerFlag(this.getOwner(), next.getKey(), FlagState.TRUE);
       } else {
         this.setPlayerFlag(this.getOwner(), next.getKey(), FlagState.FALSE);
       }
     }
   }
   for (Entry<String, Map<String, Boolean>> entry : dgflags) {
     Map<String, Boolean> value = entry.getValue();
     for (Entry<String, Boolean> flag : value.entrySet()) {
       if (flag.getValue()) {
         this.setGroupFlag(entry.getKey(), flag.getKey(), FlagState.TRUE);
       } else {
         this.setGroupFlag(entry.getKey(), flag.getKey(), FlagState.FALSE);
       }
     }
   }
 }
コード例 #4
0
  public void addResidence(
      Player player, String name, Location loc1, Location loc2, boolean resadmin) {
    if (!Residence.validName(name)) {
      player.sendMessage("§c" + Residence.getLanguage().getPhrase("InvalidNameCharacters"));
      return;
    }
    if (player == null) return;
    if (loc1 == null
        || loc2 == null
        || !loc1.getWorld().getName().equals(loc2.getWorld().getName())) {
      player.sendMessage("§c" + Residence.getLanguage().getPhrase("SelectPoints"));
      return;
    }
    PermissionGroup group = Residence.getPermissionManager().getGroup(player);
    boolean createpermission =
        group.canCreateResidences()
            || Residence.getPermissionManager().hasAuthority(player, "residence.create", false);
    if (!createpermission && !resadmin) {
      player.sendMessage("§c" + Residence.getLanguage().getPhrase("NoPermission"));
      return;
    }
    if (getOwnedZoneCount(player.getName()) >= group.getMaxZones() && !resadmin) {
      player.sendMessage("§c" + Residence.getLanguage().getPhrase("ResidenceTooMany"));
      return;
    }
    CuboidArea newArea = new CuboidArea(loc1, loc2);
    ClaimedResidence newRes = new ClaimedResidence(player.getName(), loc1.getWorld().getName());
    newRes.getPermissions().applyDefaultFlags();
    newRes.setEnterMessage(group.getDefaultEnterMessage());
    newRes.setLeaveMessage(group.getDefaultLeaveMessage());

    ResidenceCreationEvent resevent = new ResidenceCreationEvent(player, name, newRes, newArea);
    Residence.getServ().getPluginManager().callEvent(resevent);
    if (resevent.isCancelled()) return;
    newArea = resevent.getPhysicalArea();
    name = resevent.getResidenceName();
    if (residences.containsKey(name)) {
      player.sendMessage(
          "§c" + Residence.getLanguage().getPhrase("ResidenceAlreadyExists", "§e" + name + "§c"));
      return;
    }
    newRes.addArea(player, newArea, "main", resadmin);
    if (newRes.getAreaCount() != 0) {
      residences.put(name, newRes);
      Residence.getLeaseManager().removeExpireTime(name);
      player.sendMessage(
          "§a" + Residence.getLanguage().getPhrase("ResidenceCreate", "§e" + name + "§a"));
      if (Residence.getConfigManager().useLeases())
        Residence.getLeaseManager().setExpireTime(player, name, group.getLeaseGiveTime());
    }
  }
コード例 #5
0
 public void applyTemplate(Player player, FlagPermissions list, boolean resadmin) {
   if (player != null) {
     if (!resadmin) {
       if (!Residence.getConfigManager().isOfflineMode()
           && !player.getUniqueId().toString().equals(ownerUUID.toString())) {
         player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("NoPermission"));
         return;
       } else if (!player.getName().equals(ownerLastKnownName)) {
         player.sendMessage(ChatColor.RED + Residence.getLanguage().getPhrase("NoPermission"));
         return;
       }
     }
   } else {
     resadmin = true;
   }
   PermissionGroup group = Residence.getPermissionManager().getGroup(this.getOwner(), world);
   for (Entry<String, Boolean> flag : list.cuboidFlags.entrySet()) {
     if (group.hasFlagAccess(flag.getKey()) || resadmin) {
       this.cuboidFlags.put(flag.getKey(), flag.getValue());
     } else {
       if (player != null)
         player.sendMessage(
             ChatColor.RED
                 + Residence.getLanguage()
                     .getPhrase("FlagSetDeny", ChatColor.YELLOW + flag.getKey() + ChatColor.RED));
     }
   }
   for (Entry<String, Map<String, Boolean>> plists : list.playerFlags.entrySet()) {
     Map<String, Boolean> map = this.getPlayerFlags(plists.getKey(), true);
     for (Entry<String, Boolean> flag : plists.getValue().entrySet()) {
       if (group.hasFlagAccess(flag.getKey()) || resadmin) {
         map.put(flag.getKey(), flag.getValue());
       } else {
         if (player != null)
           player.sendMessage(
               ChatColor.RED
                   + Residence.getLanguage()
                       .getPhrase(
                           "FlagSetDeny", ChatColor.YELLOW + flag.getKey() + ChatColor.RED));
       }
     }
   }
   for (Entry<String, Map<String, Boolean>> glists : list.groupFlags.entrySet()) {
     for (Entry<String, Boolean> flag : glists.getValue().entrySet()) {
       if (group.hasFlagAccess(flag.getKey()) || resadmin) {
         if (!this.groupFlags.containsKey(glists.getKey()))
           this.groupFlags.put(
               glists.getKey(), Collections.synchronizedMap(new HashMap<String, Boolean>()));
         this.groupFlags.get(glists.getKey()).put(flag.getKey(), flag.getValue());
       } else {
         if (player != null)
           player.sendMessage(
               ChatColor.RED
                   + Residence.getLanguage()
                       .getPhrase(
                           "FlagSetDeny", ChatColor.YELLOW + flag.getKey() + ChatColor.RED));
       }
     }
   }
   if (player != null)
     player.sendMessage(ChatColor.GREEN + Residence.getLanguage().getPhrase("PermissionsApply"));
 }
コード例 #6
0
 private boolean hasFlagAccess(String player, String flag) {
   PermissionGroup group = Residence.getPermissionManager().getGroup(player, world);
   return group.hasFlagAccess(flag);
 }