[Util] Make players flashing red! [NMS]

Discussion in 'Resources' started by bigteddy98, Mar 13, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    bigteddy98

    This resource is no longer available.
     
  2. Offline

    Arcoz

    Seems pretty neat for one of my upcoming plugins :p
     
    bigteddy98 likes this.
  3. Offline

    bigteddy98

    Nice :D
     
  4. Offline

    Phasesaber

    I love the getMCClass() and getCraftClass() methods, good thinking! :D
     
    Wizehh, Skyost and bigteddy98 like this.
  5. Offline

    AstramG

    I applaud you for your recent contributions.
    *clap*
     
    KingFaris11 and bigteddy98 like this.
  6. Offline

    Ultimate_n00b

    Fancy fact, there's a method called broadcastEntityEffect or so..
    Edit: forgot to mention.. you use the distance method on EVERY player in the world...
     
  7. Offline

    bigteddy98

    Thanks a lot man

    People might not always want to broadcast the effect, maybe they want to customize it and send the packets only to specific players. With that in my mind I don't really like broadcastEntityEffect, but thanks :).

    How do you mean? That's what should happend, right?
    //btw, I'm still finding out what's more lightweight: sending the packets to everyone in the world, or calling the distance method many times.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  8. Offline

    SoThatsIt

    the distance method = lag
    because
    squareroot = lag

    if you need to check that a player is within a certain radius of a point use distanceSquared and then check if that is less than your radius squared
     
    Chinwe and Ultimate_n00b like this.
  9. Offline

    bigteddy98

    Thanks, will probably send the packet to everyone in the next update, do you think thats better?
     
  10. Offline

    SoThatsIt

    no, just use the method i stated above

    Loc.distanceSquared(Player.getLocation()) < radius * radius
     
  11. Offline

    bigteddy98

    Thanks a lot man, haven't been working with these methods before, so thanks for helping me.
     
  12. Offline

    Scizzr

    When you're comparing distance, make sure to check that the players are in the same world. If you don't, you'll get an exception that the distance between two worlds can't be measured. :)
    Otherwise, pretty cool. I love the methods you have for NMS and CraftBukkit. Clever job.
     
  13. Offline

    bigteddy98

    I am looping through all players in the same world, so that isn't necessary I think:
    Code:java
    1. for (Player pl : p.getWorld().getPlayers()) {

    Thanks man :).
     
  14. Offline

    Scizzr

    Ah, carry on.
     
  15. You've contributed a lot o.o Nice!
     
    bigteddy98 likes this.
  16. Offline

    TigerHix

    Code:java
    1. [16:25:44] [Server thread/WARN]: java.lang.ClassNotFoundException: net.minecraft.type.v1_7_R3.PacketPlayOutAnimation
    2. [16:25:44] [Server thread/WARN]:at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:67)
    3. [16:25:44] [Server thread/WARN]:at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:62)
    4. [16:25:44] [Server thread/WARN]:at java.lang.ClassLoader.loadClass(Unknown Source)
    5. [16:25:44] [Server thread/WARN]:at java.lang.ClassLoader.loadClass(Unknown Source)
    6. [16:25:44] [Server thread/WARN]:at java.lang.Class.forName0(Native Method)
    7. [16:25:44] [Server thread/WARN]:at java.lang.Class.forName(Unknown Source)
    8. [16:25:44] [Server thread/WARN]:at XX.RedFactory.getMCClass(RedFactory.java:134)
    9. [16:25:44] [Server thread/WARN]:at XX.RedFactory.<clinit>(RedFactory.java:24)
    10.  


    o_0
     
  17. Offline

    bigteddy98

    Which CB version are you running?
    Edit: You've changed your getMCClass method, you should have this:
    Code:java
    1. String className = "net.minecraft.server." + version + name;

    But for some reason I think you've changed it to:
    Code:java
    1. String className = "net.minecraft.type." + version + name;
     
  18. Offline

    TigerHix


    Aha! Perhaps I copied the SkyFactory's getMCClass method to this class. Sorry :p
     
  19. Offline

    bigteddy98

    Should be the same, but np ;)
     
  20. Offline

    YoloEnderman

    Thanks this helped me in one of my plugins!
     
    bigteddy98 likes this.
  21. Offline

    ChipDev

    Great job!
    1 )Make a server called 'Opposites' and do this to everyone... every tick.
    2 )On hit turn it off.
    3 ) Everyone has their own name tag, but upside-down (grumm, dinner bone) with your other skin changing.. They are upside-down!
    4 ) Forward goes back vice verca

    >: D
     
    stirante and LordVakar like this.
  22. Offline

    NonameSL

    Good job! But...The toggling should be like this: If the player is red, then remove it, and if he isn't, add it like it should be. But instead, if player is red, you have to make it red, if he isn't, remove red? Why is that?
    BTW: I created this static method to nag a player, make him red and move his screen. It can also be used to make an alarm clock!
    Code:java
    1.  
    2. public static void nag(String name){
    3. nag(Bukkit.getPlayerExact(name));
    4. }
    5. public static void nag(Player p){
    6. try {
    7. Object nms_entity = getHandle.invoke(p);
    8. Object packet = packetPlayOutAnimation.newInstance(nms_entity, 1);
    9. if (p.getLocation().distance(p.getLocation()) <= 50) {
    10. Object nms_player = getHandle.invoke(p);
    11. Object nms_connection = playerConnection.get(nms_player);
    12. sendPacket.invoke(nms_connection, packet);
    13. }
    14. } catch (Exception e) {
    15. e.printStackTrace();
    16. }
    17. }
    18.  
     
Thread Status:
Not open for further replies.

Share This Page