Package org.getspout.spoutapi.player

Examples of org.getspout.spoutapi.player.SpoutPlayer


    War.war.getServer().getPluginManager().callEvent(event1);
   
    for (Team t : this.getTeams()) {
      if (War.war.isSpoutServer()) {
        for (Player p : t.getPlayers()) {
          SpoutPlayer sp = SpoutManager.getPlayer(p);
          if (sp.isSpoutCraftEnabled()) {
                    sp.sendNotification(
                        SpoutDisplayer.cleanForNotification("Match won! " + ChatColor.WHITE + "Winners:"),
                        SpoutDisplayer.cleanForNotification(SpoutDisplayer.addMissingColor(winnersStr, this)),
                        Material.CAKE,
                        (short)0,
                        10000);
View Full Code Here


  public void updateStats(Warzone zone) {
    List<Integer> statsOffset = new ArrayList<Integer>();
    List<GenericLabel> statsLines = getStatsLines(zone, statsOffset);
    for (Team t : zone.getTeams()) {
      for (Player p : t.getPlayers()) {
        SpoutPlayer sp = SpoutManager.getPlayer(p);
        if (sp.isSpoutCraftEnabled()) {
          drawMessages(sp.getName(), statsLines, statsOffset);
        }
      }
    }
  }
View Full Code Here

    }
  }
 

  public void updateStats(Player player) {
    SpoutPlayer sp = SpoutManager.getPlayer(player);
    if (sp.isSpoutCraftEnabled()) {
      List<Integer> statsOffset = new ArrayList<Integer>();
      Warzone zone = Warzone.getZoneByPlayerName(player.getName());
      List<GenericLabel> statsLines = getStatsLines(zone, statsOffset);
      drawMessages(sp.getName(), statsLines, statsOffset);
    }
  }
View Full Code Here

  }
 
  private void drawMessages(String playerName, List<GenericLabel> statsLines, List<Integer> statsOffset) {
    Player bukkitPlayer = War.war.getServer().getPlayer(playerName);
    if (bukkitPlayer != null) {
      SpoutPlayer player = SpoutManager.getPlayer(bukkitPlayer);
      List<PlayerMessage> messages = playerMessages.get(playerName);
           
      // remove old widgets
      clear(player);
     
      // add bg
      GenericGradient gradient = new GenericGradient();
      gradient.setAnchor(WidgetAnchor.TOP_LEFT);
      gradient.setTopColor(new Color(0.0F, 0.0F, 0.0F, 0.4F)); // (order is Red, Green, Blue, Alpha)
      gradient.setBottomColor(new Color(0.0F, 0.0F, 0.0F, 0.0F));
      gradient.setHeight(statsOffset.get(1) + 4).setWidth((int)(statsOffset.get(0)));
     
      player.getMainScreen().attachWidget(War.war, gradient);
     
      // border in color of team
      GenericGradient teamGradient = new GenericGradient();
      teamGradient.setAnchor(WidgetAnchor.TOP_LEFT);
     
      Team team = Team.getTeamByPlayerName(playerName);
     
      Color spoutColor = new Color(250.0F, 250.0F, 250.0F, 1.0F);
      if (team != null) {
        spoutColor = team.getKind().getSpoutColor();
      }
      spoutColor.setAlpha(0.5F);
     
      teamGradient.setY(2 + LINE_HEIGHT_WITH_MARGIN);
      teamGradient.setTopColor(spoutColor);
      teamGradient.setBottomColor(new Color(256, 256, 256, 1.0F));
      teamGradient.setHeight(2).setWidth((int)(statsOffset.get(0)));
     
      player.getMainScreen().attachWidget(War.war, teamGradient);
     
      // update stats panel
      drawStats(player, statsLines);
     
      // finally messages
      if (messages != null && messages.size() > 0) {
        Warzone zone = Warzone.getZoneByPlayerName(playerName);     
        int verticalOffset = statsOffset.get(1) + 4;
       
        for (PlayerMessage message : messages) {
          int horizontalOffset = 2;
         
          String messageStr = ChatColor.GRAY + ">" + ChatColor.WHITE + " " + message.getMessage();
          String[] words = messageStr.split(" ");
         
          for (String word : words) {
           
            if (horizontalOffset > 160) { 
              horizontalOffset = 2;
              verticalOffset += LINE_HEIGHT_WITH_MARGIN;
            }
 
            word = addMissingColor(word, zone);
           
            GenericLabel label = new GenericLabel(word);
            int width = GenericLabel.getStringWidth(word);
            label.setAnchor(WidgetAnchor.TOP_LEFT);
            label.setWidth(width);
            label.setHeight(LINE_HEIGHT);
            label.setX(horizontalOffset);
            label.setY(verticalOffset);
           
            player.getMainScreen().attachWidget(War.war, label);
 
            horizontalOffset += width + 2;
          }
         
          verticalOffset += LINE_HEIGHT_WITH_MARGIN + 1;
View Full Code Here

  }

  public void teamcast(String message, boolean isNotification) {
    for (Player player : this.players) {
      if (War.war.isSpoutServer()) {
        SpoutPlayer sp = SpoutManager.getPlayer(player);
        if (sp.isSpoutCraftEnabled() && isNotification) {
          // team notifications go to the top left for Spout players to lessen War spam in chat box
          War.war.getSpoutDisplayer().msg(sp, message);
        } else {
          War.war.msg(player, message);
        }
View Full Code Here

  }

  public void teamcast(String message, boolean isNotification, Object... args) {
    for (Player player : this.players) {
      if (War.war.isSpoutServer()) {
        SpoutPlayer sp = SpoutManager.getPlayer(player);
        if (sp.isSpoutCraftEnabled() && isNotification) {
          // team notifications go to the top left for Spout players to lessen War spam in chat box
          War.war.getSpoutDisplayer().msg(sp, MessageFormat.format(message, args));
        } else {
          War.war.msg(player, message, args);
        }
View Full Code Here

    if (!War.war.isSpoutServer())
      return;
    line1 = SpoutDisplayer.cleanForNotification(line1);
    line2 = SpoutDisplayer.cleanForNotification(line2);
    for (Player player : this.players) {
      SpoutPlayer spoutPlayer = SpoutManager.getPlayer(player);
      if (!spoutPlayer.isSpoutCraftEnabled())
        continue;
      spoutPlayer.sendNotification(line1, line2, icon, ticks);
    }
  }
View Full Code Here

           
            // Notify everyone
            for (Team t : playerWarzone.getTeams()) {
              if (War.war.isSpoutServer()) {
                for (Player p : t.getPlayers()) {
                  SpoutPlayer sp = SpoutManager.getPlayer(p);
                  if (sp.isSpoutCraftEnabled()) {
                            sp.sendNotification(
                                SpoutDisplayer.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " captured"),
                                SpoutDisplayer.cleanForNotification(victim.getKind().getColor() + victim.getName() + ChatColor.YELLOW + " flag!"),
                                victim.getKind().getMaterial(),
                                victim.getKind().getData(),
                                10000);
                  }
                }
              }
              t.teamcast("zone.flagcapture.broadcast", playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE,
                  victim.getName(), playerTeam.getName());
            }
           
            // Detect win conditions
            if (playerTeam.getPoints() >= playerTeam.getTeamConfig().resolveInt(TeamConfig.MAXSCORE)) {
              if (playerWarzone.hasPlayerState(player.getName())) {
                playerWarzone.restorePlayerState(player);
              }
              playerWarzone.handleScoreCapReached(playerTeam.getName());
              event.setTo(playerWarzone.getTeleport());
            } else {
              // just added a point
              victim.getFlagVolume().resetBlocks(); // bring back flag to team that lost it
              victim.initializeTeamFlag();
             
              playerWarzone.respawnPlayer(event, playerTeam, player);
              playerTeam.resetSign();
              playerWarzone.getLobby().resetTeamGateSign(playerTeam);
            }
          }
         
          playerWarzone.removeFlagThief(player.getName());
         
          return;
        }
      }
     
      // Bomb detonation
      if (playerWarzone.isBombThief(player.getName())) {
        // smoky
        playerWarzone.getWorld().playEffect(player.getLocation(), Effect.SMOKE, 0);
       
        // Make sure game ends can't occur simultaneously.
        // Not thread safe. See Warzone.handleDeath() for details.
        boolean inEnemySpawn = false;
        Team victim = null;
        for (Team team : playerWarzone.getTeams()) {
          if (team != playerTeam
              && team.isSpawnLocation(player.getLocation())
              && team.getPlayers().size() > 0) {
            inEnemySpawn = true;
            victim = team;
            break;
          }
        }
       
        if (inEnemySpawn && playerTeam.getPlayers().contains(player)) {
          // Made sure player is still part of team, game may have ended while waiting.
          // Ignored the scorers that happened immediately after the game end.
          Bomb bomb = playerWarzone.getBombForThief(player.getName());
         
          // Boom!
          if (!playerWarzone.getWarzoneConfig().getBoolean(WarzoneConfig.UNBREAKABLE)) {
            // Don't blow up if warzone is unbreakable
            playerWarzone.getWorld().createExplosion(player.getLocation(), 2F);
          }
         
          if (playerWarzone.isReinitializing()) {
            // Battle already ended or interrupted
            playerWarzone.respawnPlayer(event, playerTeam, player);
          } else {
            // All good - proceed with scoring
            playerTeam.addPoint();
           
            // Notify everyone
            for (Team t : playerWarzone.getTeams()) {
              if (War.war.isSpoutServer()) {
                for (Player p : t.getPlayers()) {
                  SpoutPlayer sp = SpoutManager.getPlayer(p);
                  if (sp.isSpoutCraftEnabled()) {
                            sp.sendNotification(
                                SpoutDisplayer.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " blew up "),
                                SpoutDisplayer.cleanForNotification(victim.getKind().getColor() + victim.getName() + ChatColor.YELLOW + "'s spawn!"),
                                victim.getKind().getMaterial(),
                                victim.getKind().getData(),
                                10000);
                  }
                }
              }
              t.teamcast("zone.bomb.broadcast", playerTeam.getKind().getColor() + player.getName() + ChatColor.WHITE,
                  victim.getName(), playerTeam.getName());
            }
           
            // Detect win conditions
            if (playerTeam.getPoints() >= playerTeam.getTeamConfig().resolveInt(TeamConfig.MAXSCORE)) {
              if (playerWarzone.hasPlayerState(player.getName())) {
                playerWarzone.restorePlayerState(player);
              }
              playerWarzone.handleScoreCapReached(playerTeam.getName());
              event.setTo(playerWarzone.getTeleport());
            } else {
              // just added a point
             
              // restore bombed team's spawn
              for (Volume spawnVolume : victim.getSpawnVolumes().values()) {
                spawnVolume.resetBlocks();
              }
              victim.initializeTeamSpawns();
             
              // bring back tnt
              bomb.getVolume().resetBlocks();
              bomb.addBombBlocks();
             
              playerWarzone.respawnPlayer(event, playerTeam, player);
              playerTeam.resetSign();
              playerWarzone.getLobby().resetTeamGateSign(playerTeam);
            }         
          }
         
          playerWarzone.removeBombThief(player.getName());
         
          return;
        }
      }
     
      // Cake retrieval
      if (playerWarzone.isCakeThief(player.getName())) {
        // smoky
        if (System.currentTimeMillis() % 13 == 0) {
          playerWarzone.getWorld().playEffect(player.getLocation(), Effect.POTION_BREAK, playerTeam.getKind().getPotionEffectColor());
        }
       
        // Make sure game ends can't occur simultaneously.
        // Not thread safe. See Warzone.handleDeath() for details.
        boolean inSpawn = playerTeam.isSpawnLocation(player.getLocation());
                             
        if (inSpawn && playerTeam.getPlayers().contains(player)) {
          // Made sure player is still part of team, game may have ended while waiting.
          // Ignored the scorers that happened immediately after the game end.
          boolean hasOpponent = false;
          for (Team t : playerWarzone.getTeams()) {
            if (t != playerTeam && t.getPlayers().size() > 0) {
              hasOpponent = true;
            }
          }
         
          // Don't let someone alone make points off cakes
          if (hasOpponent) {
            Cake cake = playerWarzone.getCakeForThief(player.getName());
           
            if (playerWarzone.isReinitializing()) {
              // Battle already ended or interrupted
              playerWarzone.respawnPlayer(event, playerTeam, player);
            } else {
              // All good - proceed with scoring
              // Woot! Cake effect: 1 pt + full lifepool
              playerTeam.addPoint();
              playerTeam.setRemainingLives(playerTeam.getTeamConfig().resolveInt(TeamConfig.LIFEPOOL));
             
              // Notify everyone
              for (Team t : playerWarzone.getTeams()) {
                if (War.war.isSpoutServer()) {
                  for (Player p : t.getPlayers()) {
                    SpoutPlayer sp = SpoutManager.getPlayer(p);
                    if (sp.isSpoutCraftEnabled()) {
                              sp.sendNotification(
                                  SpoutDisplayer.cleanForNotification(playerTeam.getKind().getColor() + player.getName() + ChatColor.YELLOW + " captured"),
                                  SpoutDisplayer.cleanForNotification(ChatColor.YELLOW + "cake " + ChatColor.GREEN + cake.getName() + ChatColor.YELLOW + "!"),
                                  playerTeam.getKind().getMaterial(),
                                  playerTeam.getKind().getData(),
                                  10000);
View Full Code Here

  @EventHandler
  public void onPluginDisable(final PluginDisableEvent event) {
    if (event.getPlugin().getDataFolder().getName().equals("Spout")) {
      if (War.war.isSpoutServer()) {
        for (Player player : War.war.getServer().getOnlinePlayers()) {
                SpoutPlayer sp = SpoutManager.getPlayer(player);
                if (sp.isSpoutCraftEnabled()) {
                    sp.getMainScreen().removeWidgets(War.war);
                }
            }
        War.war.getSpoutDisplayer().clearAll();
      }
    }
View Full Code Here

      Monument monument = zone.getMonumentFromCenterBlock(block);
      if (monument != null && !monument.hasOwner()) {
        monument.capture(team);
        if (War.war.isSpoutServer()) {
          for (Player p : team.getPlayers()) {
            SpoutPlayer sp = SpoutManager.getPlayer(p);
            if (sp.isSpoutCraftEnabled()) {
                      sp.sendNotification(
                          SpoutDisplayer.cleanForNotification("Monument " + ChatColor.WHITE + monument.getName()),
                          SpoutDisplayer.cleanForNotification(ChatColor.YELLOW + "capped by " + team.getKind().getColor() + player.getName() + ChatColor.YELLOW + "!"),
                          team.getKind().getMaterial(),
                          team.getKind().getData(),
                          10000);
View Full Code Here

TOP

Related Classes of org.getspout.spoutapi.player.SpoutPlayer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.