Ejemplo n.º 1
0
  static {
    try {
      Plugin wgp = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
      hasWG = wgp != null; // Short and sweet
      if (hasWG) wg = (WorldGuardPlugin) wgp;
      hasResidence = Bukkit.getServer().getPluginManager().getPlugin("Residence") != null;
      log = Storm.instance.getLogger();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Ejemplo n.º 2
0
  public void initUpdateChecker(
      String plugin_name, String project_id, String bukkit_dev_name, boolean enable) {
    this.project_id = project_id;
    this.project_curse_url =
        "https://api.curseforge.com/servermods/files?projectIds=" + this.project_id;
    this.project_name = plugin_name;
    this.project_current_version = des.getVersion();
    this.project_check_version = enable && (!this.project_id.isEmpty());
    this.project_bukkitdev = "http://dev.bukkit.org/bukkit-plugins/" + bukkit_dev_name + "/";

    if (this.project_check_version) {
      updateMsg();
      Bukkit.getScheduler()
          .runTaskTimerAsynchronously(
              plg,
              new Runnable() {
                @Override
                public void run() {
                  updateMsg();
                }
              },
              (40 + getRandomInt(20)) * 1200,
              60 * 1200);
    }
  }
Ejemplo n.º 3
0
  private Inventory getFuelInventory(Player player) {

    if (isValidFuelJacket(player.getInventory().getChestplate())) {

      FileConfiguration fuelConfig = getFuelConfig(player);
      Material jacket = player.getInventory().getChestplate().getType();

      int jacketSize = getFuelJacketSize(jacket);
      String jacketType = getFuelJacketConfigString(jacket);

      if (fuelConfig.get(jacketType) != null) {

        Inventory fuelInventory;
        ArrayList<ItemStack> itemStack = new ArrayList<>();

        itemStack.addAll(
            fuelConfig
                .getList(jacketType)
                .stream()
                .map(fuelCurrentItem -> (ItemStack) fuelCurrentItem)
                .collect(Collectors.toList()));

        fuelInventory =
            Bukkit.createInventory(
                player,
                jacketSize,
                "" + ChatColor.DARK_RED + ChatColor.BOLD + "Rocket Boot Fuel Jacket");
        fuelInventory.setContents(itemStack.toArray(new ItemStack[itemStack.size()]));

        return fuelInventory;
      }
    }

    return null;
  }
Ejemplo n.º 4
0
  /** Creates a new server. */
  public GlowServer(ServerConfig config) {
    this.config = config;
    // stuff based on selected config directory
    opsList = new UuidListFile(config.getFile("ops.json"));
    whitelist = new UuidListFile(config.getFile("whitelist.json"));
    nameBans = new GlowBanList(this, BanList.Type.NAME);
    ipBans = new GlowBanList(this, BanList.Type.IP);

    Bukkit.setServer(this);
    loadConfig();
  }
Ejemplo n.º 5
0
 public void removeItemInInventory(final Player p, final String itemstr) {
   Bukkit.getScheduler()
       .runTaskLater(
           plg,
           new Runnable() {
             @Override
             public void run() {
               removeItemInInventory(p.getInventory(), itemstr);
             }
           },
           1);
 }
Ejemplo n.º 6
0
  public void reloadFlyZones(boolean showMessage) {

    RocketInit.rocketZoneLocations.clear();
    List<String> zoneList = RocketInit.getPlugin().getConfig().getStringList("zones");

    if (zoneList.size() > 0) {

      for (String zone : zoneList) {

        String[] zoneSection = zone.split("\\|");

        final Location zoneLocationStart =
            new Location(
                Bukkit.getWorld(zoneSection[1]),
                Integer.parseInt(zoneSection[2]) - 25,
                Integer.parseInt(zoneSection[3]) - 5,
                Integer.parseInt(zoneSection[4]) - 25);

        final Location zoneLocationEnd =
            new Location(
                Bukkit.getWorld(zoneSection[1]),
                Integer.parseInt(zoneSection[2]) + 25,
                Integer.parseInt(zoneSection[3]) + 50,
                Integer.parseInt(zoneSection[4]) + 25);

        RocketInit.rocketZoneLocations.put(
            UUID.fromString(zoneSection[0]),
            new ConcurrentHashMap<Location, Location>() {
              {
                put(zoneLocationStart, zoneLocationEnd);
              }
            });
      }

      if (showMessage) RocketInit.registerMap.put("zone", zoneList.size());
    }
  }
Ejemplo n.º 7
0
  /**
   * Gets player within range.
   *
   * @param location the centre of the range
   * @param radius the radius of the range
   * @return a set of Bukkit player objects
   */
  public static Set<Player> getNearbyPlayers(Location location, double radius) {
    Set<Player> playerList = new HashSet<Player>();
    World locWorld = location.getWorld();
    radius *= radius;

    for (Player p : Bukkit.getServer().getOnlinePlayers()) {
      if (p.getWorld().equals(locWorld)) {
        if (p.getLocation().distanceSquared(location) <= radius) {
          playerList.add(p);
        }
      }
    }

    return playerList;
  }
Ejemplo n.º 8
0
 public FakeServer() {
   if (Bukkit.getServer() == null) {
     Bukkit.setServer(this);
   }
 }
Ejemplo n.º 9
0
 /**
  * Broadcasts a message to all players in a world.
  *
  * @param message message to send
  * @param world world name
  */
 public static void broadcast(String message, String world) {
   World bw;
   if ((bw = Bukkit.getWorld(world)) == null) return;
   log(message);
   broadcast(message, bw);
 }
Ejemplo n.º 10
0
 /**
  * Broadcasts a message to all players.
  *
  * @param message message to send
  */
 public static void broadcast(String message) {
   if (!message.isEmpty()) {
     Bukkit.getServer().broadcastMessage(parseColors(message));
   }
 }
Ejemplo n.º 11
0
 public void broadcastMsg(String perm, String msg) {
   for (Player p : Bukkit.getOnlinePlayers())
     if (p.hasPermission(permprefix + perm)) printMsg(p, msg);
 }
Ejemplo n.º 12
0
 public void broadcastMSG(String perm, Object... s) {
   for (Player p : Bukkit.getOnlinePlayers())
     if (p.hasPermission(permprefix + perm)) printMSG(p, s);
 }
Ejemplo n.º 13
0
  public void disableRocketBoots(
      Player player,
      Boolean keepUsage,
      Boolean keepPower,
      Boolean keepFlight,
      Boolean keepVariant,
      Boolean keepEnhancement) {

    UUID playerUUID = player.getUniqueId();

    if (!keepUsage && RocketInit.rocketUsage.contains(playerUUID))
      RocketInit.rocketUsage.remove(playerUUID);

    if (RocketInit.rocketSprint.containsKey(playerUUID)) RocketInit.rocketSprint.remove(playerUUID);

    if (!keepPower && RocketInit.rocketPower.containsKey(playerUUID))
      RocketInit.rocketPower.remove(playerUUID);

    if (!RocketInit.rocketFire.isEmpty()) RocketInit.rocketFire.clear();

    if (RocketInit.rocketWater.contains(playerUUID)) RocketInit.rocketWater.remove(playerUUID);

    if (RocketInit.rocketRepair.containsKey(playerUUID)) RocketInit.rocketRepair.remove(playerUUID);

    if (!keepEnhancement && RocketInit.rocketEnhancement.containsKey(playerUUID))
      RocketInit.rocketEnhancement.remove(playerUUID);

    if (!keepVariant && RocketInit.rocketVariant.containsKey(playerUUID)) {

      switch (RocketInit.rocketVariant.get(playerUUID)) {
        case ENDER:
          player.removePotionEffect(PotionEffectType.NIGHT_VISION);
          player.removePotionEffect(PotionEffectType.HEALTH_BOOST);
          break;

        case ZERO:
          player.removePotionEffect(PotionEffectType.CONFUSION);
          player.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
          player.removePotionEffect(PotionEffectType.INCREASE_DAMAGE);
          break;

        case STEALTH:
          for (Player onlinePlayer : Bukkit.getOnlinePlayers()) onlinePlayer.showPlayer(player);
          break;

        case DRUNK:
          player.removePotionEffect(PotionEffectType.CONFUSION);
          player.removePotionEffect(PotionEffectType.FAST_DIGGING);
          break;

        case BOOST:
          player.removePotionEffect(PotionEffectType.HEAL);
          break;

        case RUNNER:
          player.removePotionEffect(PotionEffectType.SPEED);
          break;
      }

      RocketInit.rocketVariant.remove(playerUUID);
    }

    if (player.isOnline() && gamemodeCheck.check(player, GameMode.SURVIVAL, GameMode.ADVENTURE)) {

      for (Player onlinePlayer : Bukkit.getOnlinePlayers()) onlinePlayer.showPlayer(player);

      player.setFlySpeed(0.1f);
      player.setFlying(false);
      if (!keepFlight) player.setAllowFlight(false);

      player.setNoDamageTicks(100);
      player.setFallDistance(0);
    }
  }