Package simpleserver

Examples of simpleserver.Player


  @Override
  protected Chat getMessageInstance(Player sender, String message) {
    String[] arguments = extractArguments(message);

    if (arguments.length > 0) {
      Player reciever = sender.getServer().findPlayer(arguments[0]);
      if (reciever == null) {
        sender.addTMessage(Color.RED, "Player not online (%s)", arguments[0]);
      } else {
        return new PrivateChat(sender, reciever);
      }
View Full Code Here


  public void execute(Player player, String message) {
    String[] arguments = extractArguments(message);
    Server server = player.getServer();

    if (arguments.length >= 1) {
      Player p = player.getServer().findPlayer(arguments[0]);
      if (p == null) {
        server.ipBans.addBan(arguments[0]);
        player.addTMessage(Color.GRAY, "IP Address %s has been banned!", arguments[0]);
        server.adminLog("User " + player.getName() + " banned IP:\t "
            + arguments[0]);
      } else {
        server.ipBans.addBan(p.getIPAddress());
        server.kick(p.getName(), t("IP Banned!"));
        String msg = t("Player %s has been IP banned!", p.getName());
        server.runCommand("say", msg);
        server.adminLog("User " + player.getName() + " banned ip:\t "
            + arguments[0] + "\t(" + p.getName() + ")");
      }
    } else {
      player.addTMessage(Color.RED, "No player or IP specified.");
    }
  }
View Full Code Here

    super("gamemode [PLAYER] MODE", "set gameMode for a specific player.");
  }

  public void execute(Player player, String message) {
    String[] args = extractArguments(message);
    Player target;
    Integer gameMode;

    try {
      if (args.length == 1) {
        target = player;
        gameMode = Integer.parseInt(args[0]);
      } else if (args.length == 2) {
        target = player.getServer().findPlayer(args[0]);
        if (target == null) {
          player.addTMessage(Color.RED, "Player not online (%s)", args[1]);
          return;
        }
        gameMode = Integer.parseInt(args[1]);
      } else {
        player.addTMessage(Color.RED, "Invalid number of arguments!");
        return;
      }
    } catch (NumberFormatException e) {
      player.addTMessage(Color.RED, "Invalid gameMode %s!", args[0]);
      return;
    }

    if (gameMode != 0 && gameMode != 1 && gameMode != 2) {
      player.addTMessage(Color.RED, "Invalid gameMode %d!", gameMode);
      return;
    }
    player.getServer().runCommand("gamemode", gameMode + " " + target.getName());

  }
View Full Code Here

  public void propagate(Chat chat, String message) {
    propagate(chat, message, true);
  }

  private void forwardToServer(Chat chat, String message) {
    Player sender = chat.getSender();
    String forwardMessage = String.format(server.config.properties.get("msgForwardFormat"), chat, message);

    for (String msgPart : wrapMessage(forwardMessage)) {
      forwardedMessages.put(String.format("<%s> %s", sender.getName(), msgPart));
      sender.forwardMessage(msgPart);
    }
  }
View Full Code Here

    }
  }

  private Player nearestPlayer() {
    Player[] players = server.playerList.getArray();
    Player nearest = null;
    double bestdistance = 255;
    for (Player p : players) {
      // fugly as hell :D
      double distx = Math.abs(p.x() - position.x());
      double disty = Math.abs(p.y() - position.y());
View Full Code Here

    if (e == null) {
      System.out.println("NPC " + purename + ": Event " + ev + " not found!");
      return;
    }

    Player nearest = nearestPlayer();

    ArrayList<String> args = new ArrayList<String>();
    args.add(purename); // NPC name
    args.add("collect"); // NPC trigger
    // collect trigger arguments
View Full Code Here

    args.add(String.valueOf(i.data)); // meta data
    server.eventhost.execute(e, nearest, true, args);
  }

  private void loginEvent() {
    Player nearest = nearestPlayer();

    Event e = server.eventhost.findEvent(ev);
    if (e == null) {
      System.out.println("NPC " + purename + ": Event " + ev + " not found!");
      return;
View Full Code Here

    args.add("login"); // NPC trigger
    server.eventhost.execute(e, nearest, true, args);
  }

  private void logoutEvent() {
    Player nearest = nearestPlayer();

    Event e = server.eventhost.findEvent(ev);
    if (e == null) {
      System.out.println("NPC " + purename + ": Event " + ev + " not found!");
      return;
View Full Code Here

    try {
      Thread.sleep(1000);
    } catch (Exception e) {
    }

    Player nearest = nearestPlayer();

    Event e = server.eventhost.findEvent(ev);
    if (e == null) {
      System.out.println("NPC " + purename + ": Event " + ev + " not found!");
      return;
View Full Code Here

    push(a);
  }

  private void getgroup() {
    String s = pop();
    Player tmp = e.server.findPlayer(s);
    if (tmp == null) {
      e.notifyError("getgroup: Player not found! Returning group -1");
      push(-1);
    } else {
      push(tmp.getGroupId());
    }
  }
View Full Code Here

TOP

Related Classes of simpleserver.Player

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.