示例#1
0
 @EventHandler
 public void onCustomEvent(ToTwoSecondEvent event) {
   RegionManager rm = effect.rm;
   for (SuperRegion sr : unfedRegions) {
     for (String s : sr.getOwners()) {
       Player p = Bukkit.getPlayer(s);
       if (p == null
           || Math.random() > EFFECT_CHANCE
           || !rm.getContainingSuperRegions(p.getLocation()).contains(sr)) {
         continue;
       }
       forceHunger(p);
     }
     for (String s : sr.getMembers().keySet()) {
       Player p = Bukkit.getPlayer(s);
       if (Math.random() > EFFECT_CHANCE
           || p == null
           || !sr.getMember(s).contains("member")
           || !rm.getContainingSuperRegions(p.getLocation()).contains(sr)) {
         continue;
       }
       forceHunger(p);
     }
   }
 }
示例#2
0
  @Override
  public void run() {

    String message = this.getMessage();

    if (this.scope.equals(ZRScope.REGION)) {

      List<String> players = Zones.getZone(this.tag).getPlayers();
      for (String x : players) {
        if (Bukkit.getPlayer(x).isOnline()) Bukkit.getPlayer(x).sendMessage(message);
      }
    } else if (this.scope.equals(ZRScope.WORLD)) {

      List<Player> players = Bukkit.getWorld(Zones.getZone(this.tag).getWorldName()).getPlayers();
      for (Player p : players) {
        if (p.isOnline()) p.sendMessage(message);
      }

    } else if (this.scope.equals(ZRScope.SERVER)) {
      Player[] players = Bukkit.getServer().getOnlinePlayers();
      for (Player player : players) {
        player.sendMessage(message);
      }
    }
  }
 public String getWhoDestroyed(String locale) {
   String whoDestroyed = "";
   List<String> toCombine = new ArrayList<>();
   for (UUID player : MiscUtils.getSortedHashMapKeyset(playersCompleted)) {
     if (getPercentFromAmount(playersCompleted.get(player)) > (100 / 3)) {
       toCombine.add(
           TeamUtils.getTeamColorByPlayer(Bukkit.getPlayer(player))
               + Bukkit.getPlayer(player).getName()
               + ChatColor.GRAY
               + " ("
               + getPercentFromAmount(playersCompleted.get(player))
               + "%)");
     }
   }
   if (toCombine.size() == 0) {
     toCombine.add(
         ChatColor.DARK_AQUA
             + new LocalizedChatMessage(ChatConstant.MISC_ENEMY).getMessage(locale));
   }
   if (toCombine.size() < playersCompleted.keySet().size()) {
     toCombine.add(
         ChatColor.DARK_AQUA
             + new LocalizedChatMessage(ChatConstant.MISC_OTHERS).getMessage(locale));
   }
   whoDestroyed = toCombine.get(0);
   for (int i = 1; i < toCombine.size(); i++) {
     whoDestroyed +=
         ChatColor.GRAY
             + (i == toCombine.size() - 1
                 ? " " + new LocalizedChatMessage(ChatConstant.MISC_AND).getMessage(locale) + " "
                 : ", ")
             + toCombine.get(i);
   }
   return whoDestroyed;
 }
示例#4
0
 @EventHandler
 public void onExpire(TimerExpireEvent e) {
   if ((e.getUserUUID().isPresent()) && (e.getTimer().equals(this))) {
     UUID userUUID = (UUID) e.getUserUUID().get();
     Player player = Bukkit.getPlayer(userUUID);
     if (player == null) {
       return;
     }
     Bukkit.getPlayer((UUID) ArcherClass.tagged.get(userUUID))
         .sendMessage(
             ChatColor.YELLOW
                 + "Your archer mark on "
                 + ChatColor.AQUA
                 + player.getName()
                 + ChatColor.YELLOW
                 + " has expired.");
     player.sendMessage(ChatColor.YELLOW + "You're no longer archer marked.");
     ArcherClass.tagged.remove(player.getUniqueId());
     for (Player players : Bukkit.getOnlinePlayers()) {
       this.plugin
           .getScoreboardHandler()
           .getPlayerBoard(players.getUniqueId())
           .addUpdates(Bukkit.getOnlinePlayers());
     }
   }
 }
示例#5
0
 public void updateScoreboard() {
   List<String> second = Arrays.asList(toStringArray(getPartyMembers().toArray()));
   Iterator<String> players = getPartyMembers().iterator();
   while (players.hasNext()) {
     String pn = players.next();
     if (Bukkit.getPlayer(pn) == null) continue;
     Player p = Bukkit.getPlayer(pn);
     Objective o = ScoreboardMechanics.getBoard(p).getObjective(DisplaySlot.SIDEBAR);
     if (o == null) {
       o = ScoreboardMechanics.getBoard(p).registerNewObjective("player_data", "dummy");
       o.setDisplayName(ChatColor.RED.toString() + ChatColor.BOLD.toString() + "Party");
       o.setDisplaySlot(DisplaySlot.SIDEBAR);
     }
     for (String tn : second) {
       if (Bukkit.getPlayer(tn) == null) {
         ScoreboardMechanics.getBoard(p).resetScores(Bukkit.getOfflinePlayer(tn));
         continue;
       }
       Player t = Bukkit.getPlayer(tn);
       String name = getPlayerName(t);
       if (name.length() > 16) name = name.substring(0, 16);
       o.getScore(Bukkit.getOfflinePlayer(name))
           .setScore(HealthMechanics.getPlayerHP(t.getName()));
     }
   }
 }
示例#6
0
 public static void startGame() {
   for (int i = 1; i <= 8; i++) {
     if (i > inqueue.size()) {
       break;
     }
     Player p = Bukkit.getPlayer(inqueue.get(i - 1));
     p.setAllowFlight(false);
     p.setFlying(false);
     if (p.getGameMode() != GameMode.SURVIVAL) {
       p.setGameMode(GameMode.SURVIVAL);
     }
     Location loc = Game.getLocation("Spawn" + i).add(0.5, 1, 0.5);
     p.teleport(loc);
     p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 10, 2));
     invs.put(p.getName(), p.getInventory().getContents());
     armors.put(p.getName(), p.getInventory().getArmorContents());
     p.getInventory().clear();
     p.getInventory().setBoots(null);
     p.getInventory().setLeggings(null);
     p.getInventory().setChestplate(null);
     p.getInventory().setHelmet(null);
     p.updateInventory();
     p.setWalkSpeed(0.2f);
     ParticleEffect.FIREWORKS_SPARK.display(0.5f, 1f, 0.5f, 0.05f, 20, loc, 100);
     ingame.add(p.getName());
   }
   inqueue.removeAll(ingame);
   sendToAll(Game.tag + "§eGame starting.");
   for (int i = 1; i <= inqueue.size(); i++) {
     int util = i - 1;
     Player p = Bukkit.getPlayer(inqueue.get(util));
     p.sendMessage(
         Game.tag + "§eA game has started, you have been moved to §b" + i + "§e in queue.");
   }
 }
示例#7
0
 public static void playSound(Sound s, Location loc, float pitch, float level) {
   for (String s1 : Game.ingame) {
     Player p = Bukkit.getPlayer(s1);
     p.playSound(loc, s, level, pitch);
   }
   for (String s2 : Game.watching) {
     Player p = Bukkit.getPlayer(s2);
     p.playSound(loc, s, level, pitch);
   }
 }
示例#8
0
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String cmdName, String[] args) {
    if (sender.hasPermission("T3.kk")) {
      String kickMsg = "";
      if (args.length < 1) {
        sender.sendMessage(ChatColor.RED + "Usage: /" + cmd.getName() + " <player> (Message)");
        return true;
      }
      if (args.length == 0) {
        Player t = Bukkit.getPlayer(args[0]);

        for (int i = 0; i < args.length - 1; i++) {
          kickMsg = kickMsg + args[(i + 1)] + " ";
        }
        t.kickPlayer(
            ChatColor.RED
                + "You Were Kicked To Neputne, Saturn Or Possably Even Pluto!\n"
                + ChatColor.RESET
                + kickMsg
                + ChatColor.DARK_BLUE
                + "\nRepeated Rule Violations Result In A Ban!");
        Bukkit.broadcastMessage(
            ChatColor.DARK_AQUA
                + t.getName()
                + ChatColor.GRAY
                + " Was Kicked To Saturn, Neptune Or Possably Even Pluto!");
        plugin.log.info(sender.getName() + " Has Kicked " + t.getName() + "From The Server!");
        return true;
      }
      if (args.length == 1) {
        Player t = Bukkit.getPlayer(args[0]);
        t.kickPlayer(
            ChatColor.RED
                + "You Have Been Kicked To Saturn, Neptune Or Pluto!\n"
                + ChatColor.DARK_PURPLE
                + "Next Time Follow The Rules,\n"
                + ChatColor.DARK_BLUE
                + "Repeated Violations Will Reslult In A Ban!");
        Bukkit.broadcastMessage(
            ChatColor.DARK_AQUA
                + t.getName()
                + ChatColor.GRAY
                + " Was Kicked To Saturn, Neptune Or Possably Even Pluto!");
        plugin.log.info(sender.getName() + " Kicked " + t.getName() + " From The Server!");
        return true;
      } else {
        sender.sendMessage(ChatColor.DARK_AQUA + "Please Kick Only One Person At A Time...");
        return true;
      }
    } else {
      sender.sendMessage(ChatColor.RED + "Sorry, You Do Not Have Permission To Do That...");
      plugin.log.info(sender.getName() + " Was DENIED Access To /kk");
      return true;
    }
  }
示例#9
0
 public void closeTabScreen() {
   if (tabHeader == null) return;
   ((SpoutPlayer) Bukkit.getPlayer(player)).getMainScreen().removeWidget(tabHeader);
   for (GenericTexture part : tabMain) {
     ((SpoutPlayer) Bukkit.getPlayer(player)).getMainScreen().removeWidget(part);
   }
   for (GenericLabel text : tabText) {
     ((SpoutPlayer) Bukkit.getPlayer(player)).getMainScreen().removeWidget(text);
   }
   tabMain.clear();
   tabText.clear();
 }
示例#10
0
 public E createNewZoneUser(String playerName, boolean addToUserList) {
   Player player = Bukkit.getPlayer(playerName);
   E newUser;
   if (player != null) {
     newUser = loadUser(Bukkit.getPlayer(playerName), getUsersConfig().createSection(playerName));
   } else {
     newUser = loadUser(playerName, getUsersConfig().createSection(playerName));
   }
   if (addToUserList) {
     addUserToUserList(newUser, true);
   }
   return newUser;
 }
示例#11
0
 @Override
 public void run() {
   if (Bukkit.getPlayer(uuid) == null) Bukkit.getScheduler().cancelTask(id);
   else if (Bukkit.getPlayer(uuid).isDead()) Bukkit.getScheduler().cancelTask(id);
   else if (!Bukkit.getPlayer(uuid).isSneaking()) Bukkit.getScheduler().cancelTask(id);
   else {
     Player p = Bukkit.getPlayer(uuid);
     Vector vector = new Vector(0, 1, 0);
     vector.multiply(-0.1);
     p.setVelocity(vector);
     p.setFallDistance(0.0f);
     if (!p.isSneaking()) Bukkit.getScheduler().cancelTask(id);
   }
 }
示例#12
0
 @EventHandler
 public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
   if (Sandbox.check(sender)) return true;
   if (args.length < 2) {
     ht.show(sender);
     return true;
   }
   // start
   String msg = concat(args);
   if (args[0].equalsIgnoreCase("console")) {
     // Send to console.
     sender.sendMessage(
         ChatColor.GOLD.toString() + ChatColor.BOLD + sender.getName() + " > CONSOLE: " + msg);
     beep(sender);
     Bukkit.getConsoleSender()
         .sendMessage(
             ChatColor.GOLD.toString() + ChatColor.BOLD + sender.getName() + " > CONSOLE: " + msg);
     last.delete(sender);
     last.put(sender, Bukkit.getConsoleSender());
   } else if (Bukkit.getPlayer(args[0]) == null) {
     // NullPointer, no player
     sender.sendMessage(
         ChatColor.RED + "Problem: Where is " + args[0] + "? I cannot find this player online.");
     return true;
   } else {
     // Normal
     Player target = Bukkit.getPlayer(args[0]);
     sender.sendMessage(
         ChatColor.GOLD.toString()
             + ChatColor.BOLD
             + sender.getName()
             + " > "
             + target.getName()
             + ": "
             + msg);
     beep(sender);
     target.sendMessage(
         ChatColor.GOLD.toString()
             + ChatColor.BOLD
             + sender.getName()
             + " > "
             + target.getName()
             + ": "
             + msg);
     beep(target);
     last.delete(sender);
     last.put(sender, target);
   }
   return true;
 }
示例#13
0
  public void addPlayer(Player pl) {
    if (players.contains(pl)) return;
    players.add(pl.getName());
    PartyMechanics.party_map.put(pl.getName(), this);
    updateScoreboard();
    if (getPartyMembers().size() == 1) {
      return;
    }

    int party_count = getPartyMembers().size();

    for (String s : getPartyMembers()) {
      if (s.equalsIgnoreCase(pl.getName())) {
        continue;
      }
      if (Bukkit.getPlayer(s) == null) {
        continue;
      }
      final Player p_mem = Bukkit.getPlayer(s);
      if (party_count == 4) {
        p_mem.sendMessage(
            ChatColor.GRAY
                + "You now have "
                + ChatColor.BOLD
                + "4/8"
                + ChatColor.GRAY
                + " party members. You will now recieve increased drop rates when fighting together.");
      }
      if (party_count == 8) {
        p_mem.sendMessage(
            ChatColor.GRAY
                + "You now have "
                + ChatColor.BOLD
                + "8/8"
                + ChatColor.GRAY
                + " party members. You will now recieve +5% DMG/ARMOR AND "
                + ChatColor.UNDERLINE
                + "GREATLY"
                + ChatColor.GRAY
                + " increased drop rates when fighting together.");
      }

      /*
       * this.getServer().getScheduler().scheduleSyncDelayedTask(this, new
       * Runnable() { public void run() { sendPartyColor(pl, p_mem, true);
       * } }, 20L);
       */
    }
  }
示例#14
0
 public static void sendToAllPlus(String message) {
   List<String> sent = new ArrayList<>();
   for (String s : ingame) {
     if (!sent.contains(s)) {
       Bukkit.getPlayer(s).sendMessage(message);
       sent.add(s);
     }
   }
   for (String s : watching) {
     if (!sent.contains(s)) {
       sent.add(s);
       Bukkit.getPlayer(s).sendMessage(message);
     }
   }
 }
示例#15
0
 /**
  * Handle the '/nocheatplus info' command.
  *
  * @param sender the sender
  * @param playerName the player name
  * @return true, if successful
  */
 private void handleInfoCommand(final CommandSender sender, final String playerName) {
   final Player player = Bukkit.getPlayer(playerName);
   if (player != null) {
     final DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
     final TreeMap<Long, ViolationLevel> violations =
         ViolationHistory.getHistory(player).getViolationLevels();
     if (violations.size() > 0) {
       sender.sendMessage(TAG + "Displaying " + playerName + "'s violations...");
       for (final long time : violations.descendingKeySet()) {
         final ViolationLevel violationLevel = violations.get(time);
         final String[] parts = violationLevel.check.split("\\.");
         final String check = parts[parts.length - 1];
         final String parent = parts[parts.length - 2];
         final double VL = Math.round(violationLevel.VL);
         sender.sendMessage(
             TAG
                 + "["
                 + dateFormat.format(new Date(time))
                 + "] ("
                 + parent
                 + ".)"
                 + check
                 + " VL "
                 + VL);
       }
     } else
       sender.sendMessage(
           TAG + "Displaying " + playerName + "'s violations... nothing to display.");
   } else {
     sender.sendMessage(TAG + "404 Not Found");
     sender.sendMessage(TAG + "The requested player was not found on this server.");
   }
 }
示例#16
0
 public void remove(UUID uuid) {
   Cardinal.getCardinalDatabase().remove(this, uuid);
   Bukkit.getPluginManager()
       .callEvent(
           new RankChangeEvent(
               Bukkit.getPlayer(uuid), this, false, Bukkit.getOfflinePlayer(uuid).isOnline()));
 }
示例#17
0
  public void FlairUpdate() {

    // Flairs from Command Block The Button - Teams
    // PluginMain.Instance.getServer().getScoreboardManager().getMainScoreboard().getTeams().add()
    Player p = Bukkit.getPlayer(getUuid());
    if (p != null) p.setPlayerListName(String.format("%s%s", p.getName(), GetFormattedFlair()));
  }
 public void send() {
   Player player = Bukkit.getPlayer(user.getName());
   if (player == null) return;
   update();
   split();
   PlayerListManager.send(player);
 }
示例#19
0
 public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
   Gamer gamer = pm.getGamer(sender.getName());
   if (!gamer.isAlive()) {
     if (args.length > 0) {
       if (Bukkit.getPlayer(args[0]) != null) {
         gamer.getPlayer().eject();
         gamer
             .getPlayer()
             .teleport(sender.getServer().getPlayer(args[0]).getLocation().add(0, 0.1, 0));
         return true;
       } else if (args[0].equalsIgnoreCase(cm.getCommandGotoNameOfFeast())) {
         Location feastLoc = LibsFeastManager.getFeastManager().getFeastLocation();
         if (feastLoc.getBlockY() > 0) {
           gamer.getPlayer().eject();
           gamer
               .getPlayer()
               .teleport(
                   feastLoc
                       .getWorld()
                       .getHighestBlockAt(feastLoc)
                       .getLocation()
                       .clone()
                       .add(0.5, 1, 0.5));
         } else sender.sendMessage(cm.getCommandGotoFeastFailed());
         return true;
       } else sender.sendMessage(cm.getCommandGotoPlayerDoesntExist());
     } else sender.sendMessage(cm.getCommandGotoNotEnoughArgs());
   } else sender.sendMessage(cm.getCommandGotoNotSpectator());
   return true;
 }
示例#20
0
 public static void loadAltars() {
   ResultSet r = null;
   try {
     r =
         (new SQLQuery(
                 new String(
                     "select a.god,a.type,l.x,l.y,l.z,l.world,a.id,a.owner from £.altar a, £.locations l where a.location=l.id;"),
                 msqlc))
             .excecuteQuery();
   } catch (MySQLSyntaxErrorException e1) {
     e1.printStackTrace();
   }
   try {
     if (r != null) {
       while (r.next()) {
         AltarManager.loadAltar(
             GodManager.getGod(Utility.getGodTypeFromDBNumber(r.getInt(1))),
             AltarType.valueOf(r.getString(2)),
             new Location(
                 Bukkit.getServer().getWorld(r.getString(6)),
                 r.getInt(3),
                 r.getInt(4),
                 r.getInt(5)),
             r.getInt(7),
             Bukkit.getPlayer(r.getString(8)));
       }
     }
   } catch (SQLException e) {
     return;
   }
 }
示例#21
0
  public Player getBukkitPlayer() {

    if (bukkitPlayer == null) {
      bukkitPlayer = Bukkit.getPlayer(this.getName());
    }
    return bukkitPlayer;
  }
 public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
   Player player = null;
   if (sender instanceof Player) {
     player = (Player) sender;
   }
   if (player == null) {
     sender.sendMessage("Sorry, only Players can use such commands!");
     return true;
   } else if (cmd.getName().equalsIgnoreCase("tk")) {
     if (args.length < 2 || !hasAdminAccess(sender)) {
       return false;
     }
     Player target = Bukkit.getPlayer(args[0]);
     String message = args[1];
     for (Player players : getServer().getOnlinePlayers()) {
       if (target.isOnline()) {
         String s;
         if (target.isOp()) {
           String pname = ChatColor.DARK_RED + target.getDisplayName();
           s = "[" + target.getWorld().getName() + "]<" + pname + ChatColor.WHITE + "> " + message;
           players.sendMessage(s);
         } else {
           s = "[" + target.getWorld().getName() + "]<" + target.getDisplayName() + "> " + message;
           players.sendMessage(s);
         }
         return true;
       } else {
         players.sendMessage("[world]<" + args[0] + "> " + message);
         return true;
       }
     }
   }
   return false;
 }
示例#23
0
  @EventHandler
  public void onNPJE(PlayerJoinEvent event) {
    Player player = event.getPlayer();
    FileConfiguration playerc = MGPlayers.getPlayers();

    if (!playerc.isSet(player.getUniqueId().toString())) {
      for (Player players : Bukkit.getOnlinePlayers()) {
        players.sendMessage(
            ChatColor.DARK_GRAY
                + "["
                + ChatColor.LIGHT_PURPLE
                + "MG"
                + ChatColor.DARK_GRAY
                + "]"
                + ChatColor.GRAY
                + "Welcome "
                + ChatColor.GREEN
                + player.getName()
                + ChatColor.GRAY
                + " to  Minegusta!");
      }
      Player nate = Bukkit.getPlayer(UUID.fromString("1310f910-9480-49bb-9955-c122154cfe1d"));
      if (Bukkit.getOnlinePlayers().contains(nate)) {
        nate.chat(ChatColor.BLUE + "Welcome to Minegusta " + ChatColor.GREEN + player.getName());
      }
      playerc.set(player.getUniqueId().toString() + ".name", player.getName());
      MGPlayers.savePlayers();
    }
  }
示例#24
0
 private boolean cmdHeal(final CommandSender sender, final String[] args) {
   if (args.length == 0) {
     if (!(sender instanceof Player)) {
       this.plugin.sendMessage(sender, MessageId.cmdOnlyAvailableForPlayers);
     } else {
       final Player player = (Player) sender;
       player.setHealth(player.getMaxHealth());
       this.plugin.sendMessage(player, MessageId.general_heal_autoHeal);
     }
   } else {
     for (final String arg : args) {
       for (final String playerName : arg.split(",")) {
         final Player player = Bukkit.getPlayer(playerName);
         if (player == null) {
           this.plugin.sendMessage(sender, MessageId.noPlayerFoundForGivenName, playerName);
         } else {
           player.setHealth(player.getMaxHealth());
           this.plugin.sendMessage(player, MessageId.general_heal_healedBy, sender.getName());
           this.plugin.sendMessage(sender, MessageId.general_heal_healed, player.getName());
         }
       }
     }
   }
   return true;
 }
示例#25
0
 public PlantTimer(EodArena arena) {
   this.plugin = (BombPlugin) Bukkit.getPluginManager().getPlugin("BombArena");
   this.duration = this.plugin.getPlantTime() + 1;
   this.arena = arena;
   this.player = Bukkit.getPlayer(arena.getBombCarrier());
   this.BOMB_LOCATION = plugin.getExactLocation(player.getLocation());
 }
示例#26
0
 private boolean cmdFeed(final CommandSender sender, final String[] args) {
   if (args.length == 0) {
     if (!(sender instanceof Player)) {
       this.plugin.sendMessage(sender, MessageId.cmdOnlyAvailableForPlayers);
     } else {
       final Player player = (Player) sender;
       player.setFoodLevel(20);
       player.setSaturation(20f);
       this.plugin.sendMessage(player, MessageId.general_feed_autoFeed);
     }
   } else {
     for (final String arg : args) {
       for (final String playerName : arg.split(",")) {
         final Player player = Bukkit.getPlayer(playerName);
         if (player == null) {
           this.plugin.sendMessage(sender, MessageId.noPlayerFoundForGivenName, playerName);
         } else {
           player.setFoodLevel(20);
           player.setSaturation(20f);
           this.plugin.sendMessage(player, MessageId.general_feed_fedBy, sender.getName());
           this.plugin.sendMessage(sender, MessageId.general_feed_fed, player.getName());
         }
       }
     }
   }
   return true;
 }
示例#27
0
 public Hearthstone(String p_name) {
   this.p_name = p_name;
   this.timer_seconds = 0;
   p = Bukkit.getPlayer(p_name);
   loadData(p_name);
   HearthstoneMechanics.hearthstone_map.put(p_name, this);
 }
示例#28
0
 public static OfflinePlayer getChamp(GodType type) {
   OfflinePlayer p = null;
   ResultSet r = null;
   try {
     r =
         (new SQLQuery(
                 (new String(
                     "select champ from £.gods where idGod="
                         + String.valueOf(Utility.getDBNumberFromGodType(type)))),
                 ConfigManager.getMySQLConfig())
             .excecuteQuery());
   } catch (MySQLSyntaxErrorException e1) {
     e1.printStackTrace();
   }
   try {
     while (r.next()) {
       String s = r.getString(1);
       if (s != null) {
         p = Bukkit.getPlayer(r.getString(1));
       }
     }
   } catch (SQLException e) {
     return null;
   }
   return p;
 }
示例#29
0
 public void onCommand(CommandSender sender, String[] args) {
   if (!(sender instanceof Player)) {
     sender.sendMessage("You need to be a player to do this.");
     return;
   }
   if (args.length != 1) {
     MessageManager.getInstance().msg(sender, MessageManager.MessageType.WARN, super.getUsage());
   }
   Player p = Bukkit.getPlayer(((Player) sender).getUniqueId());
   if (args[0] == "s") {
     cm.set("ht", HubType.SINGLE);
     String world = p.getWorld().getName();
     Double x = p.getLocation().getX();
     Double y = p.getLocation().getY();
     Double z = p.getLocation().getZ();
     Float yaw = p.getLocation().getYaw();
     Float pitch = p.getLocation().getPitch();
     cm.set("hw", world);
     cm.set("hx", x);
     cm.set("hy", y);
     cm.set("hz", z);
     cm.set("hyw", yaw);
     cm.set("hph", pitch);
     MessageManager.getInstance()
         .msg(sender, MessageManager.MessageType.INFO, "Hub location set.");
   } else if (args[0] == "m") {
     MessageManager.getInstance()
         .msg(sender, MessageManager.MessageType.WARN, "We dont support multiple mode yet.");
     // TODO: Add multiple mode.
   } else {
     MessageManager.getInstance().msg(sender, MessageManager.MessageType.WARN, super.getUsage());
   }
 }
  private void addLightlevelEffects(Game game) {
    for (Map.Entry<UUID, String> e : game.playerstate.entrySet()) {
      UUID playern = e.getKey();

      if (game.playerteam.get(playern).equals(team.getName())) {
        Player player = Bukkit.getPlayer(playern);
        if (player != null) {
          int light = player.getLocation().getBlock().getLightLevel();

          // above
          for (int i = light - 1; i >= 0; i--) {
            PotionEffectType effect = PotionEffectType.getById(effectAbove[i][0]);
            int level = effectAbove[i][1];
            if (effect != null)
              if (!PlayerHandler.hasHigherPotionEffect(player, effect, level)) {
                player.addPotionEffect(new PotionEffect(effect, 3 * 20, level), true);
              }
          }
          // below
          for (int i = light + 1; i < 16; i++) {
            PotionEffectType effect = PotionEffectType.getById(effectBelow[i][0]);
            int level = effectBelow[i][1];
            if (effect != null)
              if (!PlayerHandler.hasHigherPotionEffect(player, effect, level)) {
                player.addPotionEffect(new PotionEffect(effect, 3 * 20, level), true);
              }
          }
        }
      }
    }
  }