Exemplo n.º 1
0
 private void summon(ProxiedPlayer player, ServerInfo target, CommandSender sender) {
   if ((player.getServer() != null) && (!player.getServer().getInfo().equals(target))) {
     player.connect(target);
     player.sendMessage(
         ChatColor.GOLD + "Summoned to " + target.getName() + " by " + sender.getName());
   }
 }
Exemplo n.º 2
0
 public static boolean removeFriend(ProxiedPlayer p, String who) {
   if (who == null || who == "") {
     Messages.FRIEND_FAIL_REMOVED.msg(p, "%player%", who);
     return false;
   } // Parameter fehlt bzw. ungültig
   ProxiedPlayer whoPlayer = Util.getPlayer(who);
   PlayerData pd = PlayerData.get(p.getUniqueId());
   if (whoPlayer == null) {
     for (UUID uuid : pd.getFriends().keySet()) {
       Friend friend = pd.getFriends().get(uuid);
       if (friend.getFriendName().equalsIgnoreCase(who)) {
         friend.remove(true);
         pd.getFriends().remove(uuid);
         Messages.FRIEND_REMOVED.msg(p, "%player%", who);
         PluginMessenger.sendMessage(p, "Friend", "Update");
         return true;
       }
     }
     Messages.FRIEND_NOT_IN_FRIENDLIST.msg(p, "%player%", who);
     return false;
   } else {
     if (pd.getFriends().containsKey(whoPlayer.getUniqueId())) {
       pd.getFriends().remove(whoPlayer.getUniqueId());
       Messages.FRIEND_REMOVED.msg(p, "%player%", whoPlayer.getName());
       PluginMessenger.sendMessage(p, "Friend", "Update");
       return true;
     }
     Messages.FRIEND_NOT_IN_FRIENDLIST.msg(p, "%player%", who);
     return false;
   }
 }
Exemplo n.º 3
0
 private Set<String> getLocalPlayersAsUuidStrings() {
   ImmutableSet.Builder<String> builder = ImmutableSet.builder();
   for (ProxiedPlayer player : getProxy().getPlayers()) {
     builder.add(player.getUniqueId().toString());
   }
   return builder.build();
 }
Exemplo n.º 4
0
 public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
   if ((args.length > 2) || (args.length == 0)) {
     return ImmutableSet.of();
   }
   Set<String> matches = new HashSet<>();
   String search;
   if (args.length == 1) {
     search = args[0].toLowerCase();
     for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) {
       if (player.getName().toLowerCase().startsWith(search)) {
         matches.add(player.getName());
       }
     }
     if ("all".startsWith(search)) {
       matches.add("all");
     }
     if ("current".startsWith(search)) {
       matches.add("current");
     }
   } else {
     search = args[1].toLowerCase();
     for (String server : ProxyServer.getInstance().getServers().keySet()) {
       if (server.toLowerCase().startsWith(search)) {
         matches.add(server);
       }
     }
   }
   return matches;
 }
Exemplo n.º 5
0
		@Override
		public void onCommand(CommandSender sender, String[] args, boolean confirmedCmd)
				throws IllegalArgumentException {
			final ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]);
			final String reason = Utils.getFinalArg(args, 1);
			if(target == null){
				if(!confirmedCmd && Core.getPlayerIP(args[0]).equals("0.0.0.0")){
					mustConfirmCommand(sender, getName() + " " + Joiner.on(' ').join(args),
							_("operationUnknownPlayer", new String[] {args[0]}));
					return;
				}
			}
			
			if(sender instanceof ProxiedPlayer){
				checkArgument(PermissionManager.canExecuteAction(Action.WARN , sender, ((ProxiedPlayer)sender).getServer().getInfo().getName()),
						_("noPerm"));
			}
	          checkArgument(comment.hasLastcommentCooledDown(args[0]), _("cooldownUnfinished"));
			comment.insertComment(args[0], reason, Type.WARNING, sender.getName());
			if(target != null){
			  target.sendMessage(__("wasWarnedNotif", new String[] {reason}));
			}
			  
			BAT.broadcast(_("warnBroadcast", new String[]{args[0], sender.getName(), reason}), Action.WARN_BROADCAST.getPermission());
			return;
		}
Exemplo n.º 6
0
 /**
  * Kick a player from the proxy for a specified reason
  *
  * @param player
  * @param reason
  */
 public static void kick(final ProxiedPlayer player, final String reason) {
   if (reason == null || reason.equals("")) {
     player.disconnect(TextComponent.fromLegacyText("You have been disconnected of the server."));
   } else {
     player.disconnect(
         TextComponent.fromLegacyText(ChatColor.translateAlternateColorCodes('&', reason)));
   }
 }
 @Override
 public String getServer(ProxiedPlayer player) {
   ListenerInfo listener = player.getPendingConnection().getListener();
   if (listener.isForceDefault()) {
     return listener.getDefaultServer();
   }
   String forced =
       listener.getForcedHosts().get(player.getPendingConnection().getVirtualHost().getHostName());
   String server = (forced == null) ? data.get(key(player)) : forced;
   return (server != null) ? server : listener.getDefaultServer();
 }
Exemplo n.º 8
0
  @EventHandler(priority = EventPriority.HIGHEST, canVeto = true)
  public boolean onPM(PMEvent event) {
    IRC config = plugin.getConfigManager().getConfig("irc");

    if (FontFormat.stripColor(event.getFrom()).contains(FontFormat.stripColor(config.IngameName))) {
      Messages messages = plugin.getConfigManager().getConfig("messages");

      // Check if there is a " " in the name
      String ircNick;
      if (event.getFrom().contains(config.IngameName)) {
        ircNick = FontFormat.stripColor(event.getFrom().replace(config.IngameName, ""));
      } else {
        ircNick =
            FontFormat.stripColor(event.getMessage().replace(config.IngameName, "").split(" ")[0]);
      }

      ProxiedPlayer sen = plugin.getProxy().getPlayer(event.getTo());

      if (sen == null) {
        ircModule.getIrcBot().sendToChannel("Player " + event.getTo() + " is offline", ircNick);
        return true;
      }

      if (ircModule.getIrcBot().getIrcManager().hasPmSession(ircNick)) {
        PMSession pmSession = ircModule.getIrcBot().getIrcManager().getPmSession(ircNick);
        pmSession.setTo(sen.getName());
      } else {
        ircModule.getIrcBot().getIrcManager().newPMSession(ircNick);
        PMSession pmSession = ircModule.getIrcBot().getIrcManager().getPmSession(ircNick);
        pmSession.setTo(sen.getName());
      }

      playerManager.get(sen.getName()).Reply = FontFormat.stripColor(config.IngameName) + ircNick;
      MessageBuilder messageBuilder = new MessageBuilder();
      messageBuilder.setText(
          FontFormat.translateString(
              messages.Message_Receiver.replace("%sender", config.IngameName + ircNick)
                  .replace("%message", event.getMessage().replace(ircNick + " ", ""))));
      messageBuilder.send(sen);

      plugin
          .getPluginLogger()
          .info(
              event.getFrom()
                  + " -> "
                  + event.getTo()
                  + ": "
                  + event.getMessage().replace(ircNick + " ", ""));

      return true;
    }

    return false;
  }
Exemplo n.º 9
0
  private static Iterator<String> getRandomPlayers(Collection<ProxiedPlayer> players) {
    if (Helper.isNullOrEmpty(players)) return null;

    List<String> result = new ArrayList<>(players.size());

    for (ProxiedPlayer player : players) {
      result.add(player.getName());
    }

    return Randoms.shuffle(result).iterator();
  }
Exemplo n.º 10
0
 @Override
 public void onConnect() {
   for (ProxiedPlayer p : ProxyServer.getInstance().getPlayers()) {
     getPlayer()
         .unsafe()
         .sendPacket(new PacketC9PlayerListItem(p.getDisplayName(), true, (short) p.getPing()));
   }
   BungeeCord.getInstance()
       .broadcast(
           new PacketC9PlayerListItem(
               getPlayer().getDisplayName(), true, (short) getPlayer().getPing()));
 }
 @Override
 public void setServer(ProxiedPlayer player) {
   lock.writeLock().lock();
   try {
     data.put(
         key(player),
         (player.getReconnectServer() != null)
             ? player.getReconnectServer().getName()
             : player.getServer().getInfo().getName());
   } finally {
     lock.writeLock().unlock();
   }
 }
Exemplo n.º 12
0
 public static boolean acceptLastFriend(ProxiedPlayer p) { // p = der user
   PlayerData pd = PlayerData.get(p.getUniqueId());
   FriendRequest fr = pd.getFriendRequests().poll();
   if (fr == null) {
     Messages.FRIENDREQUEST_LAST_NOT_EXISTS.msg(p);
     return false;
   }
   Messages.FRIENDREQUEST_ACCEPTED.msg(p, "%player%", fr.getFriend().getFriendName());
   Messages.FRIENDREQUEST_ACCEPTED_FORSENDER.msg(fr.getSender(), "%player%", p.getName());
   PluginMessenger.sendMessage(p, "Friend", "Update");
   PluginMessenger.sendMessage(fr.getSender(), "Friend", "Update");
   fr.setAccepted(true);
   fr.setAnswered(true);
   return true;
 }
 @SuppressWarnings("deprecation")
 public void run() {
   Collection<ProxiedPlayer> players = ProxyServer.getInstance().getPlayers();
   if (players.isEmpty()) {
     return;
   }
   for (ProxiedPlayer player : players) {
     for (String line : list.get(count).split("\n")) {
       player.sendMessage(line.replace("%p%", player.getName()));
     }
   }
   count++;
   if ((count + 1) > list.size()) {
     count = 0;
   }
 }
 public void run() {
   if (list.isEmpty()) {
     return;
   }
   if (server.getPlayers().isEmpty()) {
     return;
   }
   for (ProxiedPlayer player : server.getPlayers()) {
     for (String line : list.get(count).split("\n")) {
       ActionBarUtil.sendActionBar(player, line.replace("%p%", player.getName()));
     }
   }
   count++;
   if ((count + 1) > list.size()) {
     count = 0;
   }
 }
Exemplo n.º 15
0
  @Override
  public void execute(CommandSender sender, String[] args) {
    if (Tickets.getTickets(sender.getName(), "open").length != 0) {
      sender.sendMessage(ChatColor.RED + "Je hebt al een open ticket.");
      return;
    }

    if (Tickets.inTicket(sender.getName())) {
      sender.sendMessage(ChatColor.RED + "Je wordt al geholpen.");
      return;
    }

    boolean adminsOnline = false;
    for (ProxiedPlayer player : Main.instance.getProxy().getPlayers())
      if (Permissions.hasPermission(player.getName(), "bs.bungee.tickets.receive_broadcast"))
        adminsOnline = true;

    if (!adminsOnline) {
      sender.sendMessage(
          ChatColor.RED
              + "Er zijn op dit moment geen admins online om je te helpen. Probeer het later nog eens.");
      return;
    }

    String question = "";
    for (int i = 0; i < args.length; i++) {
      if (!args[i].equals("create")) question += ((question.equals("")) ? "" : " ") + args[i];
    }

    Ticket ticket = new Ticket();

    ticket.username = sender.getName();
    ticket.server =
        Main.instance.getProxy().getPlayer(sender.getName()).getServer().getInfo().getName();
    ticket.question = question;

    Tickets.createTicket(ticket);

    for (ProxiedPlayer player : Main.instance.getProxy().getPlayers())
      if (Permissions.hasPermission(player.getName(), "bs.bungee.tickets.receive_broadcast"))
        player.sendMessage(
            ChatColor.AQUA + ticket.username + " heeft een ticket aangemaakt: " + ticket.question);

    sender.sendMessage(
        ChatColor.GREEN + "Je ticket is aangemaakt. Je wordt zo snel mogelijk geholpen!");
  }
Exemplo n.º 16
0
 @Override
 public void execute(CommandSender commandSender, String[] args) {
   ProxiedPlayer p = (ProxiedPlayer) commandSender;
   User user = UserManager.getUser(p.getUniqueId());
   if (commandSender instanceof ProxiedPlayer) {
     if (!user.can(type)) {
       p.sendMessage(Settings.NO_PERM);
       return;
     } // OTEK LUBI W DUPE
   }
   Ranking rank = null;
   if (args.length > 1) {
     p.sendMessage(Settings.BAD_USAGE + "/ranking [NICK]");
     return;
   } else if (args.length == 0) {
     rank = UserManager.getUser(p.getUniqueId()).getRanking();
   } else if (args.length == 1) {
     String name = args[0];
     if (!UserManager.isUser(name)) {
       p.sendMessage(Settings.USER_NO_EXIST.replace("%nick%", name));
       return;
     }
     rank = UserManager.getUserByName(name).getRanking();
   }
   for (String s : Settings.INFO_RANKINGS) {
     p.sendMessage(
         s.replace("%nick%", rank.getUser().getName())
             .replace("%points%", "" + rank.getPoints())
             .replace("%kills%", "" + rank.getKills())
             .replace("%deaths%", "" + rank.getDeaths())
             .replace("%positon%", "" + rank.getPlace()));
   }
 }
Exemplo n.º 17
0
  @Override
  public void execute(CommandSender sender, String[] args) {
    if (sender instanceof ProxiedPlayer) {
      if (args == null || args.length < 1) {
        sender.sendMessage(Dictionary.format(Dictionary.ERROR_INVALID_ARGUMENTS));
        return;
      }

      ProxiedPlayer player = (ProxiedPlayer) sender;
      ProxiedPlayer join = ProxyServer.getInstance().getPlayer(args[0]);
      if (join == null || Messenger.isHidden(join)) {
        sender.sendMessage(Dictionary.format(Dictionary.ERROR_PLAYER_OFFLINE));
        return;
      }

      if (player.getUniqueId() == join.getUniqueId()) {
        sender.sendMessage(ChatColor.RED + "You cannot join yourself!");
        return;
      }

      ServerInfo info = join.getServer().getInfo();
      if (info.canAccess(player)) {
        sender.sendMessage(
            ChatColor.LIGHT_PURPLE + "Attempting to join " + join.getName() + "'s server..");
        player.connect(info);
      } else {
        sender.sendMessage(ProxyServer.getInstance().getTranslation("no_server_permission"));
      }
    } else {
      sender.sendMessage(ChatColor.RED + "Console cannot join servers");
    }
  }
Exemplo n.º 18
0
 public static void noRedisBroadcast(final String message, final String perm) {
   final BaseComponent[] bsMsg = __(message);
   for (final ProxiedPlayer p : ProxyServer.getInstance().getPlayers()) {
     if (p.hasPermission(perm) || p.hasPermission("bat.admin")) {
       p.sendMessage(bsMsg);
     }
     // If he has a grantall permission, he will have the broadcast on all the servers
     else {
       for (final String playerPerm : Core.getCommandSenderPermission(p)) {
         if (playerPerm.startsWith("bat.grantall.")) {
           p.sendMessage(bsMsg);
           break;
         }
       }
     }
   }
   getInstance().getLogger().info(ChatColor.translateAlternateColorCodes('&', message));
 }
Exemplo n.º 19
0
  private static void sendUpdateRequest(ProxiedPlayer p, Property textures) {
    if (p.getServer() == null) return;

    ByteArrayOutputStream b = new ByteArrayOutputStream();
    DataOutputStream out = new DataOutputStream(b);
    try {
      out.writeUTF("SkinUpdate");

      if (textures != null) {
        out.writeUTF(textures.getName());
        out.writeUTF(textures.getValue());
        out.writeUTF(textures.getSignature());
      }

      p.getServer().sendData("SkinsRestorer", b.toByteArray());
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
 @Override
 public void handle(AbstractPacketHandler handler) throws Exception {
   if (handler instanceof DownstreamBridge) {
     getPlayerField(DownstreamBridge.class);
     if (playerField != null) {
       ProxiedPlayer player;
       try {
         playerField.setAccessible(true);
         player = (ProxiedPlayer) playerField.get(handler);
       } catch (IllegalAccessException ex) {
         BungeeTabListPlus.getInstance()
             .getLogger()
             .warning("Failed to access player object in TeamPacketHandler for " + handler);
         return;
       }
       if (BungeeTabListPlus.getTabList(player) instanceof TabList18v3) {
         Server server = player.getServer();
         if (server != null) {
           BungeeTabListPlus.getInstance()
               .getLogger()
               .warning(
                   "Server "
                       + server.getInfo().getName()
                       + " uses Scoreboard teams. This feature is not compatible with BungeeTabListPlus.");
         } else {
           BungeeTabListPlus.getInstance()
               .getLogger()
               .warning(
                   "Player "
                       + player.getName()
                       + " received a Scoreboard team packet. This feature is not compatible with BungeeTabListPlus.");
         }
         throw CancelSendSignal.INSTANCE;
       }
     } else {
       BungeeTabListPlus.getInstance().getLogger().severe("Could not get player for " + handler);
     }
   }
   super.handle(handler);
 }
Exemplo n.º 21
0
  public static void loadPlayer(ProxiedPlayer player) {
    if (playerExists(player, FeatureDetector.canUseUUID())) {
      boolean tps;

      if (FeatureDetector.canUseUUID()) {
        tps = DatabaseManager.players.getPlayerTPS(player.getUUID());
      } else {
        tps = DatabaseManager.players.getPlayerTPS(player.getName());
      }

      GSPlayer gsPlayer =
          new GSPlayer(
              player.getName(),
              (FeatureDetector.canUseUUID()) ? player.getUUID() : null,
              tps,
              player.getAddress().getHostString());
      onlinePlayers.put(player.getName(), gsPlayer);

      DatabaseManager.players.updatePlayer(gsPlayer);

      LoggingManager.log(
          ConfigManager.messages.PLAYER_LOAD.replace("{player}", gsPlayer.getName()));

      HomesManager.loadPlayersHomes(gsPlayer);
    } else {
      createNewPlayer(player);
    }
  }
Exemplo n.º 22
0
  @EventHandler
  public void onJoin(final PostLoginEvent e) {
    final ProxiedPlayer p = e.getPlayer();
    ProxyServer.getInstance()
        .getScheduler()
        .runAsync(
            plugin,
            () -> {
              TextComponent welcome = new TextComponent("Bienvenue, " + p.getName() + " !");
              welcome.setColor(ChatColor.GOLD);

              String key = "rejoinlist:" + e.getPlayer().getUniqueId().toString();
              Jedis cache = plugin.getConnector().getBungeeResource();
              String srv = cache.get(key);
              cache.close();
              if (srv != null) {
                final ServerInfo server = ProxyServer.getInstance().getServerInfo(srv);
                if (server != null)
                  ProxyServer.getInstance()
                      .getScheduler()
                      .schedule(
                          plugin,
                          () ->
                              e.getPlayer()
                                  .connect(
                                      server,
                                      (aBoolean, throwable) -> {
                                        if (aBoolean) {
                                          p.sendMessage(
                                              new ComponentBuilder("")
                                                  .color(ChatColor.GREEN)
                                                  .append("Vous avez été remis en jeu.")
                                                  .create());
                                        }
                                      }),
                          200L,
                          TimeUnit.MILLISECONDS);
              }
            });
  }
Exemplo n.º 23
0
 public static void addReport(
     int number, ProxiedPlayer reporter, ProxiedPlayer reported, String reason) {
   try {
     Statement st = dbmanager.getConnection().createStatement();
     st.executeUpdate(
         "INSERT INTO Reports(Number, Reporter, Player, Reason) VALUES ('"
             + number
             + "', '"
             + reporter.getName()
             + "', '"
             + reported.getName()
             + "', '"
             + reason
             + "')");
   } catch (SQLException e) {
     System.out.println(
         "[BungeeUtilisals]: Can't add Report from: "
             + reporter.getName()
             + ", "
             + e.getMessage());
   }
 }
Exemplo n.º 24
0
 @Command(
     aliases = {"hub", "lobby", "main"},
     desc = "Teleport to the lobby",
     min = 0,
     max = 0)
 public static void hub(final CommandContext args, CommandSender sender) throws CommandException {
   if (sender instanceof ProxiedPlayer) {
     ((ProxiedPlayer) sender).connect(ProxyServer.getInstance().getServers().get("default"));
     sender.sendMessage(ChatColor.GREEN + "Teleporting you to the lobby...");
   } else {
     sender.sendMessage(ChatColor.RED + "Only players may use this command");
   }
 }
  public void run() {
    Collection<ProxiedPlayer> players = ProxyServer.getInstance().getPlayers();
    if (players.isEmpty()) {
      return;
    }

    int fadeIn = TitleAnnouncements.titleannouncements.getInt("Announcements.Global.FadeIn", 30);
    int stay = TitleAnnouncements.titleannouncements.getInt("Announcements.Global.Stay", 60);
    int fadeOut = TitleAnnouncements.titleannouncements.getInt("Announcements.Global.FadeOut", 30);

    for (ProxiedPlayer player : players) {
      for (String line : list.get(count).split("\n")) {
        if (line.contains("%n")) {
          String[] titles = line.split("%n");
          String stitle = titles[0];
          String ssubtitle = titles[1];

          BaseComponent[] title =
              new ComponentBuilder(stitle.replace("%p%", player.getName())).create();
          BaseComponent[] subtitle =
              new ComponentBuilder(ssubtitle.replace("%p%", player.getName())).create();

          TitleUtil.sendFullTitle(player, fadeIn, stay, fadeOut, subtitle, title);
        } else {
          BaseComponent[] title =
              new ComponentBuilder(line.replace("%p%", player.getName())).create();
          BaseComponent[] subtitle = new ComponentBuilder("").create();

          TitleUtil.sendFullTitle(player, fadeIn, stay, fadeOut, subtitle, title);
        }
      }
    }
    count++;
    if ((count + 1) > list.size()) {
      count = 0;
    }
  }
  /**
   * Sends a plugin message to the specified player.
   *
   * @param pluginMessage The message to send
   * @param proxiedPlayer The player to send the message to
   */
  @Override
  public void sendPluginMessage(PluginMessage pluginMessage, ProxiedPlayer proxiedPlayer) {
    try {
      if (proxiedPlayer != null) {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        DataOutputStream outputStream = new DataOutputStream(byteArrayOutputStream);
        if (BungeeCordMessage.class.isAssignableFrom(pluginMessage.getClass())) {

          BungeeCordMessage bungeeCordMessage = (BungeeCordMessage) pluginMessage;
          outputStream.writeUTF(bungeeCordMessage.getSubChannel());
          bungeeCordMessage.write(outputStream);
          proxiedPlayer.sendData(
              MessagingLib.BUNGEE_CORD_CHANNEL, byteArrayOutputStream.toByteArray());
        } else {
          outputStream.writeInt(pluginMessage.getClass().getName().hashCode());
          pluginMessage.write(outputStream);
          proxiedPlayer.sendData(
              MessagingLib.MESSAGING_LIB_CHANNEL, byteArrayOutputStream.toByteArray());
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 27
0
  @Override
  public void execute(CommandSender cs, String[] args) {
    if (!(cs instanceof ProxiedPlayer)) return;
    ProxiedPlayer p = (ProxiedPlayer) cs;

    if (args.length <= 0) {
      Util.message(p, Util.getFriendHelp());
      return;
    }
    switch (args[0]) {
      case "help":
        Util.message(p, Util.getFriendHelp());
        break;

      case "list":
        break;

      case "accept":
        switch (args.length) {
          case 1:
            Util.debugBoolean(DebugMessage.ACCEPT_LAST, acceptLastFriend(p), "%here%", p.getName());
            break;
          case 2:
            acceptFriend(p, args[1]);
            break;
          default:
            Util.message(p, Util.getFriendHelp());
            break;
        }
        break;

      case "add":
        if (args.length == 2) addFriend(p, args[1]);
        else Util.message(p, Util.getFriendHelp());
        break;

      case "remove":
        if (args.length == 2) removeFriend(p, args[1]);
        else Util.message(p, Util.getFriendHelp());
        break;

      default:
        break;
    }
  }
Exemplo n.º 28
0
  public static String formatMessage(
      String message,
      PwnBungeeChat plugin,
      ProxiedPlayer sender,
      Chatter chatter,
      Channel channel) {
    String outputMessage = channel.getFormat();
    outputMessage = outputMessage.replace("%nick", channel.getNick());
    outputMessage = outputMessage.replace("%server", sender.getServer().getInfo().getName());
    if (chatter.getPrefix() != null) {
      outputMessage = outputMessage.replace("%prefix", chatter.getPrefix());
    } else {
      outputMessage = outputMessage.replace("%prefix", "");
    }
    outputMessage = outputMessage.replace("%player", chatter.getName());
    if (chatter.getSuffix() != null) {
      outputMessage = outputMessage.replace("%suffix", chatter.getSuffix());
    } else {
      outputMessage = outputMessage.replace("%suffix", "");
    }
    outputMessage = outputMessage.replace("%message", message);

    return outputMessage;
  }
Exemplo n.º 29
0
 // OTEK LUBI W DUPE
 @Override
 public void execute(CommandSender commandSender, String[] args) {
   ProxiedPlayer pp = (ProxiedPlayer) commandSender;
   User user = UserManager.getUser(pp.getUniqueId());
   if (commandSender instanceof ProxiedPlayer) {
     if (!user.can(type)) {
       pp.sendMessage(Settings.NO_PERM);
       return;
     }
   }
   if (args.length != 0) {
     pp.sendMessage(Settings.BAD_USAGE + "/spawn");
     return;
   }
   Sector sector = SectorManager.getSectorByLocation(0, 0);
   if (!user.getSector().equals(sector)) {
     pp.connect(sector.getServer());
   }
   sector
       .getClient()
       .sendPacket(
           new PlayerTeleportRequestPacket(pp.getUniqueId().toString(), 5, 1, "-33:90:-148"));
   pp.sendMessage(Settings.TELEPORT_IS_PENDING);
 }
Exemplo n.º 30
0
  private static void createNewPlayer(final ProxiedPlayer player) {
    String ip = player.getAddress().getAddress().toString();
    final GSPlayer gsPlayer =
        new GSPlayer(
            player.getName(), (FeatureDetector.canUseUUID()) ? player.getUUID() : null, true);

    DatabaseManager.players.insertPlayer(gsPlayer, ip.substring(1, ip.length()));

    if (ConfigManager.main.NewPlayerBroadcast) {
      String welcomeMsg = null;
      sendBroadcast(
          welcomeMsg =
              ConfigManager.messages.NEW_PLAYER_BROADCAST.replace("{player}", player.getName()));
      // Firing custom event
      ProxyServer.getInstance()
          .getPluginManager()
          .callEvent(new NewPlayerJoinEvent(player.getName(), welcomeMsg));
    }

    onlinePlayers.put(player.getName(), gsPlayer);
    LoggingManager.log(ConfigManager.messages.PLAYER_LOAD.replace("{player}", gsPlayer.getName()));

    if (ConfigManager.spawn.SpawnNewPlayerAtNewspawn && SpawnManager.NewPlayerSpawn != null) {
      SpawnManager.newPlayers.add(player);

      ProxyServer.getInstance()
          .getScheduler()
          .schedule(
              geSuit.instance,
              new Runnable() {

                @Override
                public void run() {
                  SpawnManager.sendPlayerToNewPlayerSpawn(gsPlayer);
                  SpawnManager.newPlayers.remove(player);
                }
              },
              300,
              TimeUnit.MILLISECONDS);
    }
  }