public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel, String args[]) {

    if (sender instanceof Player) {
      Player Spieler = (Player) sender;

      if (cmd.getName().equalsIgnoreCase("xA-EasyQuest")) {
        Block TargetBlock = Spieler.getPlayer().getTargetBlock(null, 10);

        if (TargetBlock.getType().toString().equalsIgnoreCase("SIGN_POST")
            || Spieler.getPlayer()
                .getTargetBlock(null, 10)
                .getType()
                .toString()
                .equalsIgnoreCase("WALL_SIGN")) {
          Spieler.sendMessage("WELL DONE!" + TargetBlock.getType().SIGN_POST.toString());
          // Sign TeleSign = ;^

        }
        return true;
      }

    } else {
      sender.sendMessage("You are no Player");
    }

    return false;
  }
Example #2
0
  public void addChair(Player player, Block block) {

    if (disabled) return;
    try {
      PacketContainer entitymeta = ProtocolLibrary.getProtocolManager().createPacket(40);
      entitymeta.getSpecificModifier(int.class).write(0, player.getEntityId());
      WrappedDataWatcher watcher = new WrappedDataWatcher();
      watcher.setObject(0, (byte) 4);
      entitymeta.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects());
      for (Player play : plugin.getServer().getOnlinePlayers()) {
        if (play.getWorld().equals(player.getPlayer().getWorld())) {
          try {
            ProtocolLibrary.getProtocolManager().sendServerPacket(play, entitymeta);
          } catch (InvocationTargetException e) {
            BukkitUtil.printStacktrace(e);
          }
        }
      }
    } catch (Error e) {
      Bukkit.getLogger().severe("Chairs do not work without ProtocolLib!");
      disabled = true;
      return;
    }
    if (chairs.containsKey(player.getName())) return;
    plugin.wrapPlayer(player).print(ChatColor.YELLOW + "You are now sitting.");
    chairs.put(player.getName(), block);
  }
Example #3
0
  public static void openShopGui(UUID playerUUID) {
    Player player = Bukkit.getPlayer(playerUUID);

    if (player == null) {
      Splegg.getInstance()
          .getLogger()
          .info("Tried to open shop inventory for offline player: " + playerUUID.toString());
      return;
    }

    Inventory i = Bukkit.createInventory(null, 9, ChatColor.GOLD + "Splegg Shop");

    ItemStack diamond = Utils.getDiamondSplegg();

    ItemMeta diamondMeta = diamond.getItemMeta();

    // this won't work
    // diamondMeta.getLore().add("shopItem");
    List<String> lore = diamondMeta.getLore();
    lore.add("shopItem");
    diamondMeta.setLore(lore);
    diamond.setItemMeta(diamondMeta);

    i.setItem(5, diamond);
    i.setItem(4, Utils.getGoldSplegg());
    i.setItem(3, Utils.getStoneSplegg());

    player.getPlayer().openInventory(i);
  }
Example #4
0
 public void updateTab(Player p) {
   p.setScoreboard(this.scoreboard);
   for (String configstring : assignedTeams.keySet()) {
     if (p.hasPermission("rank.assign." + configstring)) {
       String toStringTeam = assignedTeams.get(configstring);
       Team team =
           scoreboard.getTeam("player" + getConfig().getString("rank." + toStringTeam + ".order"));
       team.addPlayer(p.getPlayer());
       break;
     }
   }
 }
Example #5
0
 @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
 public void onBlockBreak(BlockBreakEvent e) {
   Player p = e.getPlayer();
   Block b = e.getBlock();
   if (p.getGameMode() == GameMode.CREATIVE) {
     if (b.getType() == Material.SKULL) {
       Skull skull = (Skull) e.getBlock().getState();
       String name = this.hasOwner(skull) ? skull.getOwner() : this.def;
       if (!this.hasTool(p)) {
         if (p.isSneaking()) {
           if (SkullWalls.getWallHandler().getWallFromBlock(b) != null) {
             if (p.hasPermission(perm) || p.isOp()) {
               p.sendMessage(this.des.replace("#", name));
               // Disable skull?
             } else {
               e.setCancelled(true);
               p.sendMessage(this.noperm);
             }
           }
         } else if (SkullWalls.getWallHandler().getWallFromBlock(b) != null) {
           this.sw.getActionWorker().executeQuery(p, name);
           if (p.hasPermission(perm)) {
             e.setCancelled(true);
             p.sendMessage(RED + "To destroy skull you must sneak and break");
           } else {
             e.setCancelled(true);
             p.sendMessage(this.noperm);
           }
         }
       } else if (p.isSneaking()) {
         e.setCancelled(true);
         this.sw.getActionWorker().executeQuery(p.getPlayer(), name);
       } else {
         e.setCancelled(true);
         ItemStack s = p.getItemInHand();
         this.onBlockDamage(new BlockDamageEvent(p, b, s, false));
         if (SkullWalls.getWallHandler().getWallFromBlock(b) != null) {
           p.sendMessage(RED + "Block selected is already a part of a skull wall");
           p.sendMessage(RED + "Overlapping walls will not perform as expected!");
         }
       }
     }
   } else if (this.sw.getConfiguration().isProtecting()
       && e.getBlock().getType() == Material.SKULL
       && !p.hasPermission(perm))
     e.setCancelled(SkullWalls.getWallHandler().hasPermission(b, p, this.noperm));
 }
Example #6
0
  public void removeChair(Player player) {

    if (disabled) return;
    PacketContainer entitymeta = ProtocolLibrary.getProtocolManager().createPacket(40);
    entitymeta.getSpecificModifier(int.class).write(0, player.getEntityId());
    WrappedDataWatcher watcher = new WrappedDataWatcher();
    watcher.setObject(0, (byte) 0);
    entitymeta.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects());

    for (Player play : plugin.getServer().getOnlinePlayers()) {
      if (play.getWorld().equals(player.getPlayer().getWorld())) {
        try {
          ProtocolLibrary.getProtocolManager().sendServerPacket(play, entitymeta);
        } catch (InvocationTargetException e) {
          BukkitUtil.printStacktrace(e);
        }
      }
    }
    plugin.wrapPlayer(player).print(ChatColor.YELLOW + "You are no longer sitting.");
    chairs.remove(player.getName());
  }
Example #7
0
  public static void spectateOn(final Player player, final Player target) {

    if (getPlugin().CommandExecutor.isSpectating.get(player.getName()) != null) {

      if (getPlugin().CommandExecutor.isSpectating.get(player.getName())) {

        spectateOff(player);
      }
    }

    player.sendMessage("ยง7You are now spectating " + target.getName() + ".");
    getPlugin().CommandExecutor.origLocation.put(player.getName(), player.getLocation());
    getPlugin().CommandExecutor.isSpectating.put(player.getName(), true);
    getPlugin().CommandExecutor.isBeingSpectated.put(target.getName(), true);

    if (getPlugin().CommandExecutor.spectator.get(target.getName()) == null) {

      getPlugin().CommandExecutor.spectator.put(target.getName(), player.getName());

    } else {

      getPlugin()
          .CommandExecutor
          .spectator
          .put(
              target.getName(),
              getPlugin().CommandExecutor.spectator.get(target.getName()) + "," + player.getName());
    }

    getPlugin().CommandExecutor.target.put(player.getName(), target.getName());
    player
        .getPlayer()
        .teleport(
            getPlugin()
                .getServer()
                .getPlayer(getPlugin().CommandExecutor.target.get(player.getName())));
    getPlugin().CommandExecutor.senderHunger.put(player.getName(), player.getFoodLevel());
    getPlugin().CommandExecutor.senderHealth.put(player.getName(), player.getHealth());

    if (getPlugin().CommandExecutor.isInv.get(player.getName()) == null
        || getPlugin().CommandExecutor.isInv.get(player.getName())) {

      getPlugin()
          .CommandExecutor
          .senderInv
          .put(player.getName(), player.getInventory().getContents());
      getPlugin()
          .CommandExecutor
          .senderArm
          .put(player.getName(), player.getInventory().getArmorContents());

      player.getInventory().clear();
      player.getInventory().setContents(target.getInventory().getContents());
      player.getInventory().setArmorContents(target.getInventory().getArmorContents());
    }

    ArrayList<Player> spectateablePlayers = getSpectateablePlayers();

    spectateablePlayers.remove(player);

    int tempPlayerNumber = 0;

    for (Player p : spectateablePlayers) {

      if (getPlugin().CommandExecutor.target.get(player.getName()).equals(p.getName())) {

        break;
      }

      tempPlayerNumber++;
    }

    getPlugin().CommandExecutor.playerNumber.put(player.getName(), tempPlayerNumber);

    for (Player player1 : getPlugin().getServer().getOnlinePlayers()) {

      player1.hidePlayer(player);
    }

    target.hidePlayer(player);
    player.hidePlayer(target);
  }
 public boolean toggle(Player player, String arg, QueryFactory qf) {
     UUID uuid = player.getUniqueId();
     String ustr = uuid.toString();
     // get TARDIS
     HashMap<String, Object> where = new HashMap<String, Object>();
     where.put("uuid", ustr);
     ResultSetTardis rs = new ResultSetTardis(plugin, where, "", false, 0);
     if (rs.resultSet()) {
         Tardis tardis = rs.getTardis();
         int id = tardis.getTardis_id();
         // get current preset
         String current = tardis.getPreset().toString();
         String chameleon = tardis.getChameleon();
         // must be outside of the TARDIS
         HashMap<String, Object> wheret = new HashMap<String, Object>();
         wheret.put("uuid", ustr);
         ResultSetTravellers rst = new ResultSetTravellers(plugin, wheret, false);
         if (rst.resultSet()) {
             TARDISMessage.send(player, "JUNK_PRESET_OUTSIDE");
             return true;
         }
         if (plugin.getTrackerKeeper().getRebuildCooldown().containsKey(uuid)) {
             long now = System.currentTimeMillis();
             long cooldown = plugin.getConfig().getLong("police_box.rebuild_cooldown");
             long then = plugin.getTrackerKeeper().getRebuildCooldown().get(uuid) + cooldown;
             if (now < then) {
                 TARDISMessage.send(player.getPlayer(), "COOLDOWN", String.format("%d", cooldown / 1000));
                 return true;
             }
         }
         // make sure is opposite
         if (current.equals("JUNK_MODE") && arg.equalsIgnoreCase("on")) {
             TARDISMessage.send(player, "JUNK_ALREADY_ON");
             return true;
         }
         if (!current.equals("JUNK_MODE") && arg.equalsIgnoreCase("off")) {
             TARDISMessage.send(player, "JUNK_ALREADY_OFF");
             return true;
         }
         // check if they have a junk record
         HashMap<String, Object> wherej = new HashMap<String, Object>();
         wherej.put("uuid", ustr);
         ResultSetJunk rsj = new ResultSetJunk(plugin, wherej);
         boolean has = rsj.resultSet();
         HashMap<String, Object> sett = new HashMap<String, Object>();
         String cham_set = "";
         if (arg.equalsIgnoreCase("on")) {
             HashMap<String, Object> set = new HashMap<String, Object>();
             if (has) {
                 // update record
                 HashMap<String, Object> whereu = new HashMap<String, Object>();
                 whereu.put("uuid", ustr);
                 set.put("preset", current);
                 qf.doSyncUpdate("junk", set, whereu);
             } else {
                 // insert record
                 set.put("uuid", ustr);
                 set.put("tardis_id", id);
                 set.put("preset", current);
                 qf.doSyncInsert("junk", set);
             }
             // save JUNK_MODE preset
             sett.put("chameleon_preset", "JUNK_MODE");
             sett.put("chameleon_demat", current);
             TARDISMessage.send(player, "JUNK_PRESET_ON");
             cham_set = "JUNK_MODE";
         }
         if (arg.equalsIgnoreCase("off")) {
             // restore saved preset
             String preset = (has) ? rsj.getPreset().toString() : current;
             sett.put("chameleon_preset", preset);
             sett.put("chameleon_demat", "JUNK_MODE");
             TARDISMessage.send(player, "JUNK_PRESET_OFF");
             cham_set = preset;
         }
         // update tardis table
         HashMap<String, Object> whereu = new HashMap<String, Object>();
         whereu.put("uuid", ustr);
         qf.doSyncUpdate("tardis", sett, whereu);
         // set the Chameleon Circuit sign
         TARDISStaticUtils.setSign(chameleon, 3, cham_set, player);
         // rebuild
         player.performCommand("tardis rebuild");
         return true;
     }
     return true;
 }
  @SuppressWarnings("deprecation")
  public static String getSafeZone(Player p) {
    if (tekkitrestrict.config.getBoolean("UseSafeZones")) {
      if (!TRPermHandler.hasPermission(p, "safezone", "bypass", "")) {
        if (tekkitrestrict.getInstance().getServer().getPluginManager().isPluginEnabled("Towny")
            && depends.contains("towny")) {
          /*
           * com.palmergames.bukkit.towny.Towny tapp =
           * (com.palmergames.bukkit
           * .towny.Towny)tekkitrestrict.getInstance
           * ().getServer().getPluginManager().getPlugin("Towny");
           * com.palmergames.bukkit.towny.object.PlayerCache c =
           * tapp.getCache(p);
           * if(!tapp.getTownyUniverse().isWilderness(p.getWorld
           * ().getHighestBlockAt(p.getLocation()))){ return "towny";
           * }
           */
          Block cb = p.getWorld().getHighestBlockAt(p.getLocation());
          boolean hasperm =
              com.palmergames.bukkit.towny.utils.PlayerCacheUtil.getCachePermission(
                  p,
                  p.getLocation(),
                  cb.getTypeId(),
                  com.palmergames.bukkit.towny.object.TownyPermission.ActionType.DESTROY);
          TownBlockStatus tbs =
              com.palmergames.bukkit.towny.utils.PlayerCacheUtil.getTownBlockStatus(
                  p, WorldCoord.parseWorldCoord(p.getLocation()));
          // boolean ls = tbs != TownBlockStatus.UNCLAIMED_ZONE && tbs != TownBlockStatus.WARZONE &&
          // tbs != TownBlockStatus.UNKOWN;
          if (!hasperm) {
            // tekkitrestrict.log.info("towny");
            return "towny+";
          }
        }
        // tekkitrestrict.log.info("deb");
        if (tekkitrestrict.getInstance().getServer().getPluginManager().isPluginEnabled("Factions")
            && depends.contains("factions")) {
          // if(!com.massivecraft.factions.listeners.FactionsPlayerListener.canPlayerUseBlock(p,
          // p.getWorld().getHighestBlockAt(p.getLocation()), true)){
          // Location cccc =
          // p.getWorld().getHighestBlockAt(p.getLocation()).getLocation();

          com.massivecraft.factions.FLocation ccc =
              new com.massivecraft.factions.FLocation(p.getPlayer());
          com.massivecraft.factions.Faction f = com.massivecraft.factions.Board.getFactionAt(ccc);
          String name = p.getPlayer().getName();

          com.massivecraft.factions.FPlayer me = com.massivecraft.factions.FPlayers.i.get(name);
          if (!com.massivecraft.factions.Conf.playersWhoBypassAllProtection.contains(name)) {
            /*if (me.getFaction() != null && f != null && !me.hasAdminMode()) {
            	if ((me.getFaction().getTag() != f.getTag())
            			&& !f.isNone()) {
            		// tekkitrestrict.log.info("factions");

            	}
            }*/
            if (!FPerm.BUILD.has(me, ccc)) {
              return "factions+" + f.getTag();
            }
          }
        }

        if (tekkitrestrict
                .getInstance()
                .getServer()
                .getPluginManager()
                .isPluginEnabled("PreciousStones")
            && depends.contains("preciousstones")) {
          net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones ps =
              (net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones)
                  tekkitrestrict
                      .getInstance()
                      .getServer()
                      .getPluginManager()
                      .getPlugin("PreciousStones");
          Block fblock = p.getWorld().getBlockAt(p.getLocation());

          Field field =
              ps.getForceFieldManager()
                  .getEnabledSourceField(fblock.getLocation(), FieldFlag.CUBOID);
          // tekkitrestrict.log.info("a");
          if (field != null) {
            // tekkitrestrict.log.info("b");
            boolean allowed = ps.getForceFieldManager().isApplyToAllowed(field, p.getName());
            if (!allowed || field.hasFlag(FieldFlag.APPLY_TO_ALL)) {
              // if (field.getSettings().canGrief(fblock.getTypeId()))
              // return;
              // tekkitrestrict.log.info("c");
              return "preciousstones";
            }
          }
        }

        if (tekkitrestrict
                .getInstance()
                .getServer()
                .getPluginManager()
                .isPluginEnabled("GriefPrevention")
            && depends.contains("griefprevention")) {
          me.ryanhamshire.GriefPrevention.GriefPrevention pl =
              (me.ryanhamshire.GriefPrevention.GriefPrevention)
                  tekkitrestrict
                      .getInstance()
                      .getServer()
                      .getPluginManager()
                      .getPlugin("GriefPrevention");
          Claim claim = pl.dataStore.getClaimAt(p.getLocation(), false, null);
          if (claim != null) {
            String noAccessReason = claim.allowAccess(p);
            if (noAccessReason != null) {
              return "griefprevention";
            }
          }
        }

        return getXYZSafeZone(p.getLocation(), p.getWorld().getName());
      } else {
        return "";
      }
    }
    return "";
  }
Example #10
0
 @Override
 public Player getPlayer() {
   return caller.getPlayer();
 }
Example #11
0
 public BukkitPlayer(Player p) {
   super(p);
   player = p;
   offplayer = p.getPlayer();
 }