예제 #1
0
  private void updateCustomBlockDesigns(Player[] players, long data, BlockDesign design) {

    PacketCustomBlockDesign p = new PacketCustomBlockDesign(msw(data), lsw(data), design);

    for (Player player : players) {
      if (player instanceof SpoutCraftPlayer) {
        SpoutCraftPlayer sp = (SpoutCraftPlayer) player;
        if (sp.isSpoutCraftEnabled()) {
          sp.sendPacket(p);
        }
      }
    }
  }
예제 #2
0
  private void updateCustomClientData(Player[] players, int id) {

    int blockId = itemBlock.get(id);

    short metaData = (short) itemMetaData.get(id);

    @SuppressWarnings("unused")
    String pluginName = (String) itemPlugin.get(id);

    PacketCustomItem p = new PacketCustomItem(id, blockId, metaData);

    for (Player player : players) {
      if (player instanceof SpoutCraftPlayer) {
        SpoutCraftPlayer sp = (SpoutCraftPlayer) player;
        if (sp.isSpoutCraftEnabled()) {
          sp.sendPacket(p);
        }
      }
    }
  }
예제 #3
0
  public void sendBlockOverrideToPlayers(
      Player[] players, BlockVector blockVector, Integer blockId, Integer metaData) {

    PacketCustomBlockOverride p =
        new PacketCustomBlockOverride(
            blockVector.getBlockX(),
            blockVector.getBlockY(),
            blockVector.getBlockZ(),
            blockId,
            metaData);

    for (Player player : players) {
      if (player instanceof SpoutCraftPlayer) {
        SpoutCraftPlayer sp = (SpoutCraftPlayer) player;
        if (sp.isSpoutCraftEnabled()) {
          sp.sendPacket(p);
        }
      }
    }
  }
예제 #4
0
 @Override
 public void a(Packet3Chat packet) {
   String chat = packet.message;
   if (chat.trim().isEmpty()) {
     return;
   }
   if (!allowReload && chat.equalsIgnoreCase("/reload")) {
     allowReload = true;
     SpoutCraftPlayer player = (SpoutCraftPlayer) SpoutCraftPlayer.getPlayer(getPlayer());
     if (!player.isSpoutCraftEnabled()) {
       player.sendMessage(ChatColor.RED + "Spout does not support the /reload command.");
       player.sendMessage(ChatColor.RED + "Unexpected behavior may occur.");
       player.sendMessage(ChatColor.RED + "We recommend using /stop and restarting.");
       player.sendMessage(ChatColor.RED + "Or you can use /spout reload to reload the config.");
       player.sendMessage(
           ChatColor.RED + "If you want to use /reload anyway, use the command again.");
     } else {
       Label warning =
           new DecayingLabel(
               200,
               ChatColor.RED
                   + "Spout does not support the /reload command."
                   + "\n"
                   + ChatColor.RED
                   + "Unexpected behavior may occur."
                   + "\n"
                   + ChatColor.RED
                   + "We recommend using /stop and restarting."
                   + " \n"
                   + ChatColor.RED
                   + "Or you can use /spout reload to reload the config."
                   + "\n"
                   + ChatColor.RED
                   + "If you want to use /reload anyway, use the command again.");
       warning.setX(100).setY(100).setPriority(RenderPriority.Lowest);
       player.getMainScreen().attachWidget(Spout.getInstance(), warning);
     }
     return;
   }
   super.a(packet);
 }
예제 #5
0
  @Override
  public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

    if (args.length == 0) {
      sender.sendMessage("[Spout] Server version: " + p.getDescription().getVersion());
      return true;
    }

    if (!sender.isOp()) {
      sender.sendMessage("[Spout] This command is Op only");
      return true;
    }

    String c = args[0];

    if (c.equals("reload")) {
      (new ConfigReader()).read();
      sender.sendMessage("Configuration for Spout has been reloaded.");
      return true;
    }
    if (c.equals("version")) {
      sender.sendMessage("[Spout] Server version: " + p.getDescription().getVersion());

      CommandSender target = sender;

      if (args.length > 1) {
        target = p.getServer().getPlayer(args[1]);
        if (target == null) {
          sender.sendMessage("[Spout] Unknown player: " + args[1]);
          return true;
        }
      }

      if (!(target instanceof Player)) {
        sender.sendMessage("[Spout] Client version: no client");
      }
      if (!(target instanceof SpoutPlayer)) {
        sender.sendMessage("[Spout] Client version: standard client");
      } else {
        SpoutCraftPlayer sp = (SpoutCraftPlayer) target;
        if (!sp.isSpoutCraftEnabled()) {
          sender.sendMessage("[Spout] Client version: standard client");
        } else {
          sender.sendMessage("[Spout] Client version: " + sp.getVersionString());
        }
      }
      return true;
    }
    if (c.equals("verify") && args.length > 1) {
      sender.sendMessage("[Spout] Temporarily setting the motd to: " + args[1]);
      sender.sendMessage("[Spout] It will return to its original setting in ~5 mins");
      if (motd_temp == null) {
        motd_temp = ((CraftServer) Bukkit.getServer()).getHandle().server.motd;
      } else {
        Bukkit.getServer().getScheduler().cancelTask(motd_task);
      }
      ((CraftServer) Bukkit.getServer()).getHandle().server.motd = args[1];
      motd_task =
          Bukkit.getServer()
              .getScheduler()
              .scheduleSyncDelayedTask(
                  p,
                  new Runnable() {
                    @Override
                    public void run() {
                      ((CraftServer) Bukkit.getServer()).getHandle().server.motd = motd_temp;
                      motd_temp = null;
                    }
                  },
                  20 * 60 * 5);
      return true;
    }

    return false;
  }