예제 #1
0
 @Override
 public void b(World world, int i, int j, int k, EntityHuman entityhuman) {
   if (entityhuman instanceof EntityPlayer) {
     SpoutCraftPlayer player =
         (SpoutCraftPlayer)
             SpoutManager.getPlayer((Player) ((EntityPlayer) entityhuman).getBukkitEntity());
     player.setLastClickedLocation(new Location(player.getWorld(), i, j, k));
   }
   parent.b(world, i, j, k, entityhuman);
 }
예제 #2
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);
        }
      }
    }
  }
예제 #3
0
 @Override
 public void a(Packet18ArmAnimation packet) {
   if (packet.a == -42) {
     SpoutCraftPlayer player = (SpoutCraftPlayer) SpoutCraftPlayer.getPlayer(getPlayer());
     player.setBuildVersion(1); // Don't know yet, just set above zero
     try {
       Spout.getInstance().playerListener.manager.onSpoutcraftEnable((SpoutPlayer) getPlayer());
     } catch (Exception e) {
       e.printStackTrace();
     }
   } else {
     super.a(packet);
   }
 }
예제 #4
0
  @Override
  public void run() {
    // counter++;
    Spout.getInstance().playerListener.manager.onServerTick();
    Player[] online = Bukkit.getServer().getOnlinePlayers();
    for (Player player : online) {
      if (player instanceof SpoutCraftPlayer) {
        ((SpoutCraftPlayer) player).onTick();
      }
    }
    SpoutCraftChunk.updateTicks();
    ((SimpleMaterialManager) SpoutManager.getMaterialManager()).onTick();
    Spout.getInstance().getEntityTrackingManager().onTick();
    ServerTickEvent event = new ServerTickEvent();
    Bukkit.getServer().getPluginManager().callEvent(event);

    // if (counter % 20 == 0) {
    //	for (World world : Bukkit.getServer().getWorlds()) {
    //		Chunk[] chunks = world.getLoadedChunks();
    //		for (Chunk chunk : chunks) {
    //			if (SpoutCraftChunk.replaceBukkitChunk(chunk)) {
    //				System.out.println("Bad Chunk at (" + chunk.getX() + ", " + chunk.getZ());
    //			}
    //		}
    //	}
    // }
    // if (counter % 1200 == 0) { //check every min
    //	(SimpleChunkDataManager)SpoutManager.getChunkDataManager()).testFileTimeouts();
    // }
  }
예제 #5
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);
        }
      }
    }
  }
예제 #6
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);
        }
      }
    }
  }
예제 #7
0
 @Override
 public float getDamage(EntityHuman entityhuman) {
   if (entityhuman instanceof EntityPlayer) {
     SpoutCraftPlayer player =
         (SpoutCraftPlayer)
             SpoutManager.getPlayer((Player) ((EntityPlayer) entityhuman).getBukkitEntity());
     Location target = player.getRawLastClickedLocation();
     if (target != null) {
       int index =
           CustomBlock.getIndex((int) target.getX(), (int) target.getY(), (int) target.getZ());
       Chunk chunk = target.getWorld().getChunkAt(target);
       if (chunk.getClass().equals(SpoutCraftChunk.class)) {
         TIntFloatHashMap hardnessOverrides = ((SpoutCraftChunk) chunk).hardnessOverrides;
         if (hardnessOverrides.containsKey(index)) {
           return hardnessOverrides.get(index);
         }
       }
     }
   }
   return parent.getDamage(entityhuman);
 }
예제 #8
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);
 }
예제 #9
0
 @Override
 public void a(Packet14BlockDig packet) {
   SpoutCraftPlayer player = (SpoutCraftPlayer) SpoutCraftPlayer.getPlayer(getPlayer());
   boolean inAir = false;
   if (player.canFly() && !player.getHandle().onGround) {
     inAir = true;
     player.getHandle().onGround = true;
   }
   super.a(packet);
   if (inAir) {
     player.getHandle().onGround = false;
   }
 }
예제 #10
0
 @Override
 public void run() {
   player.updateAppearance();
   player.updateWaypoints();
 }
예제 #11
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;
  }