Example #1
0
  public void cacheItemUse(Player player, WorldCoord worldCoord, boolean itemUseRight) {
    PlayerCache cache = TownyUniverse.getPlugin().getCache(player);
    cache.updateCoord(worldCoord);
    cache.setItemUsePermission(itemUseRight);

    TownyMessaging.sendDebugMsg(
        player.getName() + " (" + worldCoord.toString() + ") Cached Item Use: " + itemUseRight);
  }
Example #2
0
  public void cacheSwitch(Player player, WorldCoord worldCoord, boolean switchRight) {
    PlayerCache cache = TownyUniverse.getPlugin().getCache(player);
    cache.updateCoord(worldCoord);
    cache.setSwitchPermission(switchRight);

    TownyMessaging.sendDebugMsg(
        player.getName() + " (" + worldCoord.toString() + ") Cached Switch: " + switchRight);
  }
Example #3
0
  public void cacheDestroy(Player player, WorldCoord worldCoord, boolean destroyRight) {
    PlayerCache cache = TownyUniverse.getPlugin().getCache(player);
    cache.updateCoord(worldCoord);
    cache.setDestroyPermission(destroyRight);

    TownyMessaging.sendDebugMsg(
        player.getName() + " (" + worldCoord.toString() + ") Cached Destroy: " + destroyRight);
  }
Example #4
0
  public void cacheBuild(Player player, WorldCoord worldCoord, boolean buildRight) {
    PlayerCache cache = TownyUniverse.getPlugin().getCache(player);
    cache.updateCoord(worldCoord);
    cache.setBuildPermission(buildRight);

    TownyMessaging.sendDebugMsg(
        player.getName() + " (" + worldCoord.toString() + ") Cached Build: " + buildRight);
  }
Example #5
0
  public TownBlockStatus cacheStatus(
      Player player, WorldCoord worldCoord, TownBlockStatus townBlockStatus) {
    PlayerCache cache = TownyUniverse.getPlugin().getCache(player);
    cache.updateCoord(worldCoord);
    cache.setStatus(townBlockStatus);

    TownyMessaging.sendDebugMsg(
        player.getName() + " (" + worldCoord.toString() + ") Cached Status: " + townBlockStatus);
    return townBlockStatus;
  }
Example #6
0
  /**
   * getCachePermission
   *
   * <p>returns player cached permission for BUILD, DESTROY, SWITCH or ITEM_USE
   *
   * @param player
   * @param location
   * @param action
   * @return true if the player has permission.
   */
  public boolean getCachePermission(Player player, Location location, ActionType action) {

    WorldCoord worldCoord;

    try {
      worldCoord =
          new WorldCoord(
              TownyUniverse.getDataSource().getWorld(player.getWorld().getName()),
              Coord.parseCoord(location));
      PlayerCache cache = TownyUniverse.getPlugin().getCache(player);
      cache.updateCoord(worldCoord);

      TownyMessaging.sendDebugMsg(
          "Cache permissions for " + action.toString() + " : " + cache.getCachePermission(action));
      return cache.getCachePermission(
          action); // || plugin.isTownyAdmin(player); // Throws NullPointerException if the cache is
                   // empty

    } catch (NotRegisteredException e) {
      // World not known
      e.printStackTrace();
    } catch (NullPointerException e) {
      // New or old cache permission was null, update it

      try {
        worldCoord =
            new WorldCoord(
                TownyUniverse.getDataSource().getWorld(player.getWorld().getName()),
                Coord.parseCoord(location));

        TownBlockStatus status =
            cacheStatus(player, worldCoord, getStatusCache(player, worldCoord));
        // plugin.cacheBuild(player, worldCoord, plugin.getPermission(player, status, worldCoord,
        // action));
        triggerCacheCreate(player, location, worldCoord, status, action);

        PlayerCache cache = TownyUniverse.getPlugin().getCache(player);
        cache.updateCoord(worldCoord);

        TownyMessaging.sendDebugMsg(
            "New Cache permissions for "
                + action.toString()
                + " : "
                + cache.getCachePermission(action));
        return cache.getCachePermission(action); // || plugin.isTownyAdmin(player);

      } catch (NotRegisteredException e1) {
        // Will never get here.
      }
    }
    return false;
  }
Example #7
0
 public void cacheBlockErrMsg(Player player, String msg) {
   PlayerCache cache = TownyUniverse.getPlugin().getCache(player);
   cache.setBlockErrMsg(msg);
 }