예제 #1
1
  @EventHandler
  public void onPlayerJoin(PlayerJoinEvent event) {
    Player p = event.getPlayer();

    getLogger()
        .info(
            "Creating player account for "
                + p.getName()
                + " ("
                + p.getUniqueId().toString()
                + ").");
    Account pa =
        Currencies.getInstance()
            .getDatabase()
            .find(Account.class)
            .where()
            .eq("uuid", p.getUniqueId().toString())
            .findUnique();
    if (pa == null) {
      Account nameAccount =
          Currencies.getInstance()
              .getDatabase()
              .find(Account.class)
              .where()
              .eq("name", p.getName())
              .findUnique();
      if (nameAccount != null) {
        nameAccount.setName(nameAccount.getName() + "CurrenciesAccount" + nameAccount.getId());
        Currencies.getInstance().getDatabase().save(nameAccount);
      }

      pa = new Account();
      pa.setName(p.getName());
      pa.setUuid(p.getUniqueId().toString());
      pa.setDefaultCurrency(null);
      pa.setDateCreated(new Timestamp(Calendar.getInstance().getTimeInMillis()));
      pa.setDateModified(new Timestamp(Calendar.getInstance().getTimeInMillis()));
      Currencies.getInstance().getDatabase().save(pa);

      Holder h = new Holder();
      HolderPK hpk = new HolderPK();
      hpk.setParentAccountId(pa.getId());
      hpk.setChildAccountId(pa.getId());
      h.setId(hpk);
      h.setLength((short) 0);
      Currencies.getInstance().getDatabase().save(h);
    } else if (!p.getName().equals(pa.getName())) {
      pa.setName(p.getName());
      pa.setDateModified(new Timestamp(Calendar.getInstance().getTimeInMillis()));
      Currencies.getInstance().getDatabase().save(pa);
    }
  }
예제 #2
0
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onPlayerDamageByPlayer(final EntityDamageByEntityEvent e) {
    if (e.getEntity() instanceof Player == false || e.getDamager() instanceof Player == false)
      return;

    Player player = (Player) e.getEntity();
    Player target = (Player) e.getDamager();
    SCPlayer scp = getSCPlayer(player.getUniqueId());
    SCPlayer sct = getSCPlayer(target.getUniqueId());
    Faction faction = BoardColl.get().getFactionAt(PS.valueOf(target.getLocation().getChunk()));

    if (faction.getName().equalsIgnoreCase("Safezone")) {
      return;
    }

    final Faction pFaction = MPlayerColl.get().get(player).getFaction();
    final Faction tFaction = MPlayerColl.get().get(target).getFaction();

    if (pFaction.getRelationTo(tFaction) == Rel.MEMBER && !pFaction.isNone()) {
      return;
    }

    if (pFaction.getRelationTo(tFaction) == Rel.ALLY) {
      return;
    }

    scp.combatTag();
    sct.combatTag();
  }
예제 #3
0
  public static void setOwner(Player p, String clanName) {
    saveClans();
    if (clanExists(clanName)) {
      if (!(MySQL.mySQLenabled())) {
        ClansFile.getData().set("Clans." + getClanNumber(clanName) + ".Owner", p.getUniqueId());
        ClansFile.saveData();
        ClansFile.reloadData();
        loadClans();
      } else {
        try {
          Connection conn = MySQL.getConnection();
          String INSERT =
              "INSERT INTO CODClans (clan, owner) VALUES(?, ?) ON DUPLICATE KEY UPDATE owner=?";
          PreparedStatement ps = conn.prepareStatement(INSERT);

          ps.setString(1, clanName);
          ps.setString(2, p.getUniqueId().toString());
          ps.setString(3, p.getUniqueId().toString());

          ps.executeUpdate();

          ps.close();
          conn.close();
          loadClans();
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }
  }
  @Override
  public boolean onCommand(CommandSender cs, Command cmnd, String string, String[] args) {
    if (!(cs instanceof Player)) {
      cs.sendMessage(ChatColor.RED + "Sry. Not yet implemented.");
    } else {
      Player p = (Player) cs;
      if (!receivers.containsKey(p.getUniqueId())) {
        long ticks = 20;
        if (args.length > 0) {
          try {
            ticks = Long.parseLong(args[0]);
          } catch (NumberFormatException e) {
            cs.sendMessage(ChatColor.RED + "Not a valid number. [" + args[0] + "]");
          }
        }
        receivers.put(p.getUniqueId(), ticks);

        cs.sendMessage(ChatColor.GREEN + PREFIX + "Telemetry enabled.");
      } else {
        receivers.remove(p.getUniqueId());
        cs.sendMessage(ChatColor.YELLOW + PREFIX + "Telemetry disabled.");
      }
    }

    return true;
  }
예제 #5
0
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onPlayerQuit(final PlayerQuitEvent e) {
    Player player = e.getPlayer();
    SCPlayer scPlayer = getSCPlayer(player.getUniqueId());

    e.setQuitMessage(null);

    if (scPlayer.isCombatTagged()) {
      player.setHealth(0);
      scPlayer.removeCombatTag();
      broadcast(
          new FancyMessage(scPlayer.getTag())
              .tooltip(scPlayer.getHoverText())
              .then(" §5has logged off while in combat!"));
    }

    if (rankManager.getRank(player.getUniqueId()).getId() >= Rank.MOD.getId())
      staff(
          new FancyMessage("§9[STAFF] ")
              .then(scPlayer.getTag())
              .tooltip(scPlayer.getHoverText())
              .then(" §edisconnected."));

    removeSCPlayer(player.getUniqueId());
  }
예제 #6
0
  public void bOOM() {
    Vector v = p.getVelocity();
    v.setY(2.3);
    p.teleport(p.getLocation().add(0, 0.5, 0));
    p.setVelocity(v);
    p.setFallDistance(0F);
    TempData.sonicRainBoomMap.put(p.getUniqueId(), System.currentTimeMillis());
    p.sendMessage(ChatColor.LIGHT_PURPLE + "SONIC RAINBOOM!");
    TempData.fallMap.add(p.getUniqueId());

    // Particles
    final World world = p.getWorld();

    for (int i = 0; i < 20 * 4; i++) {
      Bukkit.getScheduler()
          .scheduleSyncDelayedTask(
              Main.PLUGIN,
              new Runnable() {

                @Override
                public void run() {

                  world
                      .spigot()
                      .playEffect(p.getLocation(), Effect.COLOURED_DUST, 1, 1, 1, 1, 1, 1, 48, 30);
                }
              },
              i);
    }
  }
예제 #7
0
파일: User.java 프로젝트: Syndek/Root
  public void saveData() {
    JSONObject attributes = new JSONObject();
    attributes.put("fill", fill);
    attributes.put("muted", muted);
    attributes.put("frozen", frozen);
    attributes.put("undercover", undercover);

    JSONObject user = new JSONObject();
    user.put("name", base.getName());
    user.put("uuid", base.getUniqueId());
    user.put("attributes", attributes);

    JSONObject stat = new JSONObject();
    // Stat and ting

    JSONObject data = new JSONObject();
    data.put("user", user);
    data.put("stat", stat);

    try {
      FileWriter writer = new FileWriter("plugins/Root/users/" + base.getUniqueId() + "/data.json");
      writer.write(data.toJSONString());
      writer.flush();
      writer.close();
    } catch (IOException e) {
      Bukkit.getLogger()
          .warning("Error while saving data for " + getName() + ": " + e.getMessage());
    }
  }
예제 #8
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();
    }
  }
예제 #9
0
파일: Test.java 프로젝트: Co0sh/BetonTest
 /**
  * Starts the test for the player.
  *
  * @param player
  */
 public void startTest(Player player) {
   if (plugin.getTest(player) != null) return;
   plugin.getData().set(player.getUniqueId() + ".current.name", name);
   plugin.getData().set(player.getUniqueId() + ".current.chances", maxMistakes);
   plugin
       .getData()
       .set(
           player.getUniqueId() + ".location",
           player.getLocation().getX()
               + ";"
               + player.getLocation().getY()
               + ";"
               + player.getLocation().getZ()
               + ";"
               + player.getLocation().getWorld().getName()
               + ";"
               + player.getLocation().getYaw()
               + ";"
               + player.getLocation().getPitch());
   Category first = categories.get(0);
   players.put(player.getUniqueId(), first);
   chances.put(player.getUniqueId(), maxMistakes);
   if (messageStart != null) player.sendMessage(messageStart.replace('&', '§'));
   first.addPlayer(player);
   new Saver(plugin);
 }
예제 #10
0
파일: Files.java 프로젝트: robbo5899/smash
  /**
   * @param player Player to create a file on
   * @throws IOException
   */
  public static void createPlayerFile(Player player) throws IOException {
    createFiles();

    File playerFile =
        new File(
            Smash.instance.getDataFolder() + File.separator + "players",
            player.getUniqueId() + ".yml");

    if (!playerFile.exists()) {
      try {
        playerFile.createNewFile();
      } catch (IOException e) {
        e.printStackTrace();
      }

      FileConfiguration config;
      config = new YamlConfiguration();

      config.set("uuid", player.getUniqueId());
      config.set("usernameOnFirstJoin", player.getName());
      config.set("kills", 0);
      config.set("deaths", 0);
      config.set("gamesPlayed", 0);
      config.set("wins", 0);

      config.save(playerFile);
    }
  }
 public boolean eject(Player player) {
   if (!player.hasPermission("tardis.eject")) {
     TARDISMessage.send(player, "NO_PERMS");
     return true;
   }
   // check they are still in the TARDIS world
   if (!plugin.getUtils().inTARDISWorld(player)) {
     TARDISMessage.send(player, "CMD_IN_WORLD");
     return true;
   }
   // must have a TARDIS
   ResultSetTardisID rs = new ResultSetTardisID(plugin);
   if (!rs.fromUUID(player.getUniqueId().toString())) {
     TARDISMessage.send(player, "NOT_A_TIMELORD");
     return false;
   }
   int ownerid = rs.getTardis_id();
   HashMap<String, Object> wheret = new HashMap<String, Object>();
   wheret.put("uuid", player.getUniqueId().toString());
   ResultSetTravellers rst = new ResultSetTravellers(plugin, wheret, false);
   if (!rst.resultSet()) {
     TARDISMessage.send(player, "NOT_IN_TARDIS");
     return false;
   }
   int thisid = rst.getTardis_id();
   // must be timelord of the TARDIS
   if (thisid != ownerid) {
     TARDISMessage.send(player, "CMD_ONLY_TL");
     return false;
   }
   // track the player
   plugin.getTrackerKeeper().getEjecting().put(player.getUniqueId(), thisid);
   return true;
 }
예제 #12
0
  @EventHandler(priority = EventPriority.MONITOR)
  public void stackPlayer(PlayerInteractEntityEvent event) {
    // Do nothing if clicked entity is not a player.
    if (!(event.getRightClicked() instanceof Player)) return;

    // Do nothing if player does not have permission.
    Player player = event.getPlayer();
    if (!Perm.PLAYERSTACKER.has(player)) return;

    // Do nothing if clicking player is not stacking.
    User user = plugin.getUser(player.getUniqueId());
    if (user != null && !user.isStacking()) return;

    // Do nothing if clicked player is not stacking.
    Player clicked = (Player) event.getRightClicked();
    user = plugin.getUser(clicked.getUniqueId());
    if (user != null && !user.isStacking()) return;

    // Do nothing if player or clicked player are inside a vehicle.
    if (clicked.isInsideVehicle() || player.isInsideVehicle()) return;

    // Stack the player.
    Entity topPassenger = getTopPassenger(player);
    topPassenger.setPassenger(clicked);
  }
 @Override
 public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
   if (args.length != 1) {
     return false;
   }
   Player player = FOPMR_Rank.getPlayer(args[0]);
   if (player == null) {
     sender.sendMessage("Player is not online.");
     return true;
   }
   if (FOPMR_Rank.isEqualOrHigher(FOPMR_Rank.getRank(player), FOPMR_Rank.getRank(sender))) {
     sender.sendMessage(
         "You can only block the commands of a player with lower clearance than yourself.");
     return true;
   }
   Bukkit.broadcastMessage(
       ChatColor.AQUA
           + sender.getName()
           + " - toggling command blockage for "
           + player.getName()
           + ".");
   try {
     FOPMR_DatabaseInterface.updateInTable(
         "UUID",
         player.getUniqueId().toString(),
         !(FOPMR_DatabaseInterface.getBooleanFromTable(
             "UUID", player.getUniqueId().toString(), "CMDBLOCK", "PLAYERS")),
         "CMDBLOCK",
         "PLAYERS");
   } catch (Exception ex) {
     FreedomOpModRemastered.plugin.handleException(ex);
   }
   return true;
 }
  public static boolean unrankedSidebarDisplay(Player p, String[] elements) {
    elements = cutUnranked(elements);

    try {
      if (p.getScoreboard() == null
          || p.getScoreboard() == Bukkit.getScoreboardManager().getMainScoreboard()
          || p.getScoreboard().getObjectives().size() != 1) {
        p.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
      }

      if (p.getScoreboard().getObjective(p.getUniqueId().toString().substring(0, 16)) == null) {
        p.getScoreboard()
            .registerNewObjective(p.getUniqueId().toString().substring(0, 16), "dummy");
        p.getScoreboard()
            .getObjective(p.getUniqueId().toString().substring(0, 16))
            .setDisplaySlot(DisplaySlot.SIDEBAR);
      }

      p.getScoreboard().getObjective(DisplaySlot.SIDEBAR).setDisplayName(elements[0]);

      for (int i = 1; i < elements.length; i++)
        if (elements[i] != null)
          if (p.getScoreboard().getObjective(DisplaySlot.SIDEBAR).getScore(elements[i]).getScore()
              != 16 - i) {
            p.getScoreboard()
                .getObjective(DisplaySlot.SIDEBAR)
                .getScore(elements[i])
                .setScore(16 - i);
            for (String string : p.getScoreboard().getEntries())
              if (p.getScoreboard()
                      .getObjective(p.getUniqueId().toString().substring(0, 16))
                      .getScore(string)
                      .getScore()
                  == 16 - i) if (!string.equals(elements[i])) p.getScoreboard().resetScores(string);
          }

      for (String entry : p.getScoreboard().getEntries()) {
        boolean toErase = true;
        for (String element : elements) {
          if (element != null
              && element.equals(entry)
              && p.getScoreboard()
                      .getObjective(p.getUniqueId().toString().substring(0, 16))
                      .getScore(entry)
                      .getScore()
                  == 16 - Arrays.asList(elements).indexOf(element)) {
            toErase = false;
            break;
          }
        }

        if (toErase) p.getScoreboard().resetScores(entry);
      }

      return true;
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }
  }
예제 #15
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());
     }
   }
 }
예제 #16
0
 public static RewardInventory getInventory(Player p) {
   if (inventoryMap.containsKey(p.getUniqueId())) {
     return inventoryMap.get(p.getUniqueId());
   }
   RewardInventory inventory = new RewardInventory(BukkitBubblePlayer.getObject(p.getUniqueId()));
   inventoryMap.put(p.getUniqueId(), inventory);
   return inventory;
 }
예제 #17
0
  @EventHandler
  public void throwSnowball(PlayerInteractEvent e) {
    final Player p = e.getPlayer();
    if (UtilBlock.usable(e.getClickedBlock())) {
      return;
    }
    if (e.getPlayer().getItemInHand() == null) {
      return;
    }
    if (e.getPlayer().getItemInHand().getType() != Material.FIREWORK_CHARGE) {
      return;
    }
    if (_coolDown.contains(p.getUniqueId())) {
      return;
    }
    if (((e.getAction() == Action.RIGHT_CLICK_AIR) || (e.getAction() == Action.RIGHT_CLICK_BLOCK))
        && (disName(p.getItemInHand()) != null)
        && (disName(p.getItemInHand())
            .equalsIgnoreCase(
                ChatColor.DARK_AQUA
                    + "EnderDoge "
                    + ChatColor.DARK_RED
                    + EnderDogeAmmoManager.balaceEnderDogeAmmo(p)))) {
      Player player = e.getPlayer();
      e.setCancelled(true);

      _coolDown.add(p.getUniqueId());
      Bukkit.getScheduler()
          .runTaskLater(
              Main.getInstance(),
              new Runnable() {
                public void run() {
                  _coolDown.remove(p.getUniqueId());
                }
              },
              5L);
      Projectile proj = player.launchProjectile(Snowball.class);
      proj.setVelocity(proj.getVelocity().multiply(2));
      _balls.add(proj);
      player.getWorld().playSound(player.getLocation(), Sound.CHICKEN_EGG_POP, 1.5F, 1.5F);
      EnderDogeAmmoManager.takeEnderDogeAmmo(p, 1);
      if (EnderDogeAmmoManager.balaceEnderDogeAmmo(p) < 1) {
        player.getInventory().setItemInHand(null);
        player.sendMessage(
            StringManager.getPrefix(MessageType.ERROR) + ChatColor.AQUA + "You ran out of ammo!");
        return;
      }
      ItemStack snow = new ItemStack(Material.FIREWORK_CHARGE, 1);
      ItemMeta sno = snow.getItemMeta();
      sno.setDisplayName(
          ChatColor.DARK_AQUA
              + "EnderDoge "
              + ChatColor.DARK_RED
              + EnderDogeAmmoManager.balaceEnderDogeAmmo(p));
      snow.setItemMeta(sno);
      player.getInventory().setItemInHand(snow);
    }
  }
예제 #18
0
 public static void removePlayer(Player p, String clanName) {
   if (clanExists(clanName)) {
     ArrayList<String> newPlayers = new ArrayList<String>();
     newPlayers.addAll(getClanMembers(clanName));
     if (newPlayers.contains("" + p.getUniqueId())) newPlayers.remove("" + p.getUniqueId());
     clan.put(clanName, newPlayers);
     saveClans();
   }
 }
 public boolean build(Player p, int tips, int id) {
   if (!plugin.getConfig().getBoolean("allow.zero_room")) {
     TARDISMessage.send(p, "ZERO_DISABLED");
     return true;
   }
   TARDISInteriorPostioning tintpos = new TARDISInteriorPostioning(plugin);
   int slot = tips;
   if (tips == -1) {
     slot = tintpos.getFreeSlot();
     // uodate TARDIS table with new slot number
     QueryFactory qf = new QueryFactory(plugin);
     HashMap<String, Object> set = new HashMap<String, Object>();
     set.put("tips", slot);
     HashMap<String, Object> where = new HashMap<String, Object>();
     where.put("tardis_id", id);
     qf.doUpdate("tardis", set, where);
   }
   TARDISTIPSData pos = tintpos.getTIPSData(slot);
   int x = pos.getCentreX();
   int y = 64;
   int z = pos.getCentreZ();
   World w = plugin.getServer().getWorld("TARDIS_Zero_room");
   if (w == null) {
     TARDISMessage.send(p, "ZERO_NOT_FOUND");
     return true;
   }
   Location l = new Location(w, x, y, z);
   TARDISRoomBuilder builder = new TARDISRoomBuilder(plugin, "ZERO", l, COMPASS.SOUTH, p);
   if (builder.build()) {
     UUID uuid = p.getUniqueId();
     // ok, room growing was successful, so take their energy!
     int amount = plugin.getRoomsConfig().getInt("rooms.ZERO.cost");
     QueryFactory qf = new QueryFactory(plugin);
     HashMap<String, Object> set = new HashMap<String, Object>();
     set.put("uuid", p.getUniqueId().toString());
     qf.alterEnergyLevel("tardis", -amount, set, p);
     // remove blocks from condenser table if rooms_require_blocks is true
     if (plugin.getConfig().getBoolean("growth.rooms_require_blocks")) {
       TARDISCondenserData c_data = plugin.getGeneralKeeper().getRoomCondenserData().get(uuid);
       for (Map.Entry<String, Integer> entry : c_data.getBlockIDCount().entrySet()) {
         HashMap<String, Object> wherec = new HashMap<String, Object>();
         wherec.put("tardis_id", c_data.getTardis_id());
         wherec.put("block_data", entry.getKey());
         qf.alterCondenserBlockCount(entry.getValue(), wherec);
       }
       plugin.getGeneralKeeper().getRoomCondenserData().remove(uuid);
     }
     // are we doing an achievement?
     if (plugin.getAchievementConfig().getBoolean("rooms.enabled")) {
       TARDISAchievementFactory taf =
           new TARDISAchievementFactory(
               plugin, p, "rooms", plugin.getBuildKeeper().getSeeds().size());
       taf.doAchievement("ZERO");
     }
   }
   return true;
 }
  public boolean doExterminate(Player player) {

    if (!plugin.getTrackerKeeper().getExterminate().containsKey(player.getUniqueId())) {
      TARDISMessage.send(player, "TARDIS_BREAK_SIGN");
      return false;
    }
    TARDISExterminator del = new TARDISExterminator(plugin);
    return del.exterminate(
        player, plugin.getTrackerKeeper().getExterminate().get(player.getUniqueId()));
  }
예제 #21
0
  @EventHandler
  public void onPlayerQuit(PlayerQuitEvent e) {
    Player p = e.getPlayer();
    if (PBMethods.allowedZone.containsKey(p.getName())) {
      if (PBMethods.matchStarted
          && PBMethods.getWorldGuard() != null
          && PBMethods.AutomateMatches) {
        String teamSide = null;
        if (PBMethods.getPlayerTeam(p.getUniqueId()) != null) {
          if (PBMethods.getPlayerTeam(p.getUniqueId()).equalsIgnoreCase(PBMethods.TeamOne))
            teamSide = PBMethods.TeamOne;
          if (PBMethods.getPlayerTeam(p.getUniqueId()).equalsIgnoreCase(PBMethods.TeamTwo))
            teamSide = PBMethods.TeamTwo;
        }

        if (teamSide.equalsIgnoreCase(PBMethods.TeamOne)) {
          PBMethods.sendPBChat(Strings.PlayerEliminated.replace("%player", p.getName()));
          PBMethods.allowedZone.remove(p.getName());
          p.getInventory().setArmorContents(null);
          p.getInventory().setArmorContents(Commands.tmpArmor.get(p));
          Commands.tmpArmor.remove(p);
          if (PBMethods.teamOnePlayers.isEmpty()) {
            PBMethods.sendPBChat(Strings.RoundStopped);
            PBMethods.sendPBChat(Strings.TeamWon.replace("%team", PBMethods.TeamTwo));
            Bukkit.getServer().getScheduler().cancelTask(Commands.clockTask);
            PBMethods.matchStarted = false;
            PBMethods.playingTeams.clear();
            PBMethods.TeamOne = null;
            PBMethods.TeamTwo = null;
            PBMethods.allowedZone.clear();
            PBMethods.restoreArmor();
          }
        }
        if (teamSide.equalsIgnoreCase(PBMethods.TeamTwo)) {
          PBMethods.sendPBChat(Strings.PlayerEliminated.replace("%player", p.getName()));
          PBMethods.allowedZone.remove(p.getName());
          p.getInventory().setArmorContents(null);
          p.getInventory().setArmorContents(Commands.tmpArmor.get(p));
          Commands.tmpArmor.remove(p);
          if (PBMethods.teamTwoPlayers.isEmpty()) {
            PBMethods.sendPBChat(Strings.RoundStopped);
            PBMethods.sendPBChat(Strings.TeamWon.replace("%team", PBMethods.TeamOne));
            Bukkit.getServer().getScheduler().cancelTask(Commands.clockTask);
            PBMethods.matchStarted = false;
            PBMethods.playingTeams.clear();
            PBMethods.TeamOne = null;
            PBMethods.TeamTwo = null;
            PBMethods.allowedZone.clear();
            PBMethods.restoreArmor();
          }
        }
      }
    }
  }
예제 #22
0
 public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
   try {
     if (!(sender instanceof Player)) {
       sender.sendMessage(ChatColor.RED + "You must be ingame to use this command.");
       return true;
     }
     if (args.length == 0 || args.length > 2) {
       return false;
     }
     if (args.length == 1) {
       if (args[0].equalsIgnoreCase("list")) {
         sender.sendMessage(ChatColor.GREEN + "The following users are Master Builders.");
         Connection c = FOPMR_DatabaseInterface.getConnection();
         PreparedStatement statement =
             c.prepareStatement("SELECT * FROM PLAYERS WHERE BUILDER = 1");
         ResultSet set = statement.executeQuery();
         while (set.next()) {
           sender.sendMessage(ChatColor.GREEN + " - " + set.getString("NAME"));
         }
         return true;
       }
     }
     if (args.length == 2) {
       if (!FOPMR_Rank.isSpecialist(sender)) {
         sender.sendMessage("You do not have permission to use this command.");
         return true;
       }
       Player player = FOPMR_Rank.getPlayer(args[1]);
       if (player == null) {
         sender.sendMessage(ChatColor.RED + "The player could not be found.");
         return true;
       }
       if (args[0].equalsIgnoreCase("add")) {
         FOPMR_Commons.adminAction(
             sender.getName(), "Adding " + player.getName() + " to Master Builder.", false);
         FOPMR_DatabaseInterface.updateInTable(
             "UUID", player.getUniqueId().toString(), true, "BUILDER", "PLAYERS");
         FOPMR_BoardManager.updateStats(player);
         return true;
       }
       if (args[0].equalsIgnoreCase("remove")) {
         FOPMR_Commons.adminAction(
             sender.getName(), "Removing " + player.getName() + " from Master Builder.", true);
         FOPMR_DatabaseInterface.updateInTable(
             "UUID", player.getUniqueId().toString(), false, "BUILDER", "PLAYERS");
         FOPMR_BoardManager.updateStats(player);
         return true;
       }
     }
   } catch (Exception ex) {
     FreedomOpModRemastered.plugin.handleException(ex);
   }
   return false;
 }
예제 #23
0
  @Override
  public void run() {
    DuelManager dm = plugin.getDuelManager();
    FileManager fm = plugin.getFileManager();
    MessageManager mm = plugin.getMessageManager();
    int duelTime = fm.getDuelTime();
    String senderName = sender.getName();
    String targetName = target.getName();
    UUID senderUUID = sender.getUniqueId();
    UUID targetUUID = target.getUniqueId();
    int duelSize = duelArena.getPlayers().size();

    if (plugin.isDebugEnabled()) {
      SendConsoleMessage.debug("Duel size: " + duelSize);
    }

    if (duelSize == 0) {
      dm.endDuel(duelArena);
      this.cancel();
    }

    if (this.countDown > 0 && duelSize == 2) {
      String duelStartActionBar = mm.getDuelStartingActionBarMessage();
      duelStartActionBar =
          duelStartActionBar.replaceAll("%seconds%", String.valueOf(this.countDown));
      Util.sendActionBarMessage(sender, target, duelStartActionBar);
      this.countDown--;
    } else {
      if (duelSize == 2) {
        Util.setTime(sender, target, this.countDown);
        Util.sendMsg(sender, target, ChatColor.YELLOW + "Duel!");
        duelArena.setDuelState(DuelState.STARTED);
        dm.surroundLocation(duelArena.getSpawnpoint1(), Material.AIR);
        dm.surroundLocation(duelArena.getSpawnpoint2(), Material.AIR);
        dm.updateDuelStatusSign(duelArena);
      }

      // dm.removeFrozenPlayer(senderUUID);
      // dm.removeFrozenPlayer(targetUUID);

      if (plugin.isDebugEnabled()) {
        SendConsoleMessage.debug("Stopping duel start thread.");
      }
      this.cancel();

      if (duelTime != 0 && duelSize == 2) {
        if (plugin.isDebugEnabled()) {
          SendConsoleMessage.debug("Duel time limit is set, starting countdown task.");
        }
        new DuelTimeThread(plugin, sender, target, duelArena, duelTime)
            .runTaskTimer(plugin, 20L, 20L);
      }
    }
  }
예제 #24
0
파일: Test.java 프로젝트: Co0sh/BetonTest
 /** @return the location at which the player was when he started the test */
 public Location getLocation(Player player) {
   String[] parts = plugin.getData().getString(player.getUniqueId() + ".location").split(";");
   plugin.getData().set(player.getUniqueId() + ".location", null);
   return new Location(
       Bukkit.getWorld(parts[3]),
       Double.parseDouble(parts[0]),
       Double.parseDouble(parts[1]),
       Double.parseDouble(parts[2]),
       Float.parseFloat(parts[4]),
       Float.parseFloat(parts[5]));
 }
예제 #25
0
파일: Test.java 프로젝트: Co0sh/BetonTest
 /** Pauses the test for the player. */
 private void pause(Player player) {
   if (messagePause != null) player.sendMessage(messagePause.replace('&', '§'));
   if (commandPause != null)
     Bukkit.dispatchCommand(
         Bukkit.getConsoleSender(), commandPause.replace("%player%", player.getName()));
   plugin.getData().set(player.getUniqueId() + ".current", null);
   plugin.getData().set(player.getUniqueId() + ".paused.name", name);
   plugin
       .getData()
       .set(player.getUniqueId() + ".paused.chances", chances.get(player.getUniqueId()));
 }
예제 #26
0
  public void ban(Player p, ArrayList<String> reason) {

    String s = reason + "";

    settings.getConfig().set("Banned." + p.getUniqueId() + ".reason", s);
    settings.getConfig().set("Banned." + p.getUniqueId() + ".isbanned", 1);
    settings.getConfig().set("Banned." + p.getUniqueId() + ".time", -10);
    players.add(p);
    settings.saveConfig();
    p.kickPlayer("Banned");
  }
예제 #27
0
파일: Test.java 프로젝트: Co0sh/BetonTest
 /** Fails the test for the player. */
 private void fail(Player player) {
   if (messageFail != null) player.sendMessage(messageFail.replace('&', '§'));
   if (commandFail != null)
     Bukkit.dispatchCommand(
         Bukkit.getConsoleSender(), commandFail.replace("%player%", player.getName()));
   plugin.getData().set(player.getUniqueId() + ".current", null);
   List<String> newList = plugin.getData().getStringList(player.getUniqueId() + ".failed");
   newList.add(name);
   plugin.getData().set(player.getUniqueId() + ".failed", newList);
   plugin.logTest(player, this, false);
   if (teleportBack) player.teleport(getLocation(player));
 }
  @Test
  public void shouldReturnIfHasData() {
    // given
    Player player1 = mock(Player.class);
    given(player1.getUniqueId()).willReturn(SAMPLE_UUID);
    Player player2 = mock(Player.class);
    given(player2.getUniqueId()).willReturn(UUID.nameUUIDFromBytes("not-stored".getBytes()));

    // when / then
    assertThat(limboPlayerStorage.hasData(player1), equalTo(true));
    assertThat(limboPlayerStorage.hasData(player2), equalTo(false));
  }
예제 #29
0
 public boolean cooledDown() {
   if (TempData.sonicRainBoomMap.containsKey(p.getUniqueId())) {
     if (!(TimeUnit.MILLISECONDS.toSeconds(
             System.currentTimeMillis() - TempData.sonicRainBoomMap.get(p.getUniqueId()))
         > 15)) {
       sendTimeRemaining(
           TimeUnit.MILLISECONDS.toSeconds(
               System.currentTimeMillis() - TempData.sonicRainBoomMap.get(p.getUniqueId())));
       return false;
     }
   }
   return true;
 }
  @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
  public void onPlayerSwing(PlayerAnimationEvent event) {
    Player player = event.getPlayer();
    if (this.interact.contains(player.getUniqueId())) {
      this.interact.remove(player.getUniqueId());
      return;
    }
    if (Bloodbending.isBloodbended(player) || Concussion.getTarget(player) != null) {
      event.setCancelled(true);
      return;
    }

    String ability = EntityTools.getBendingAbility(player);
    RegisteredAbility registered = AbilityManager.getManager().getRegisteredAbility(ability);
    if (registered == null) {
      return;
    }

    if (EntityTools.canBend(player, registered)
        && (registered.canBeUsedWithTools()
            || !EntityTools.isTool(player.getInventory().getItemInMainHand().getType()))) {
      Map<Object, BendingAbility> abilities = AbilityManager.getManager().getInstances(ability);
      boolean shouldCreateNew = true;
      for (BendingAbility a : abilities.values()) {
        if (player.equals(a.getPlayer()) && !((BendingActiveAbility) a).swing()) {
          shouldCreateNew = false;
        }
      }
      if (shouldCreateNew) {
        BendingActiveAbility ab = AbilityManager.getManager().buildAbility(ability, player);
        if (ab == null) {
          Bending.getInstance()
              .getLogger()
              .log(
                  Level.SEVERE,
                  "Ability "
                      + ability
                      + " failed to construct with buildAbility for player "
                      + player.getName());
          return;
        }
        if (ab.canBeInitialized()) {
          ab.swing();
          if (ab.getState() != BendingAbilityState.START
              && ab.getState() != BendingAbilityState.ENDED) {
            AbilityManager.getManager().addInstance(ab);
          }
        }
      }
    }
  }