Solved Extending CraftPlayer

Discussion in 'Plugin Development' started by _Filip, Jul 22, 2014.

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

    _LB

    My point is that a plugin does not even have to interact with the ban list at all to give the effect of a player being banned.
     
  2. Offline

    _Filip

    I put the code up here if anyone wants to learn.

    _LB Most plugins do though.

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

    Deleted user

    TheSpherret
    Your plugin doesn't account for reloads

    And a better way to do this getSuperClass() chain
    Show Spoiler

    Field field = ((CraftEntity) e.getPlayer()).getHandle().getClass().getSuperclass().getSuperclass().getSuperclass().getDeclaredField("bukkitEntity");
    field.setAccessible(true);
    field.set(((CraftEntity) e.getPlayer()).getHandle(), new CraftPlayerProxy((CraftPlayer) e.getPlayer()));
    Show Spoiler
    Show Spoiler
    Show Spoiler
    Show Spoiler
    Show Spoiler
    Show Spoiler
    Show Spoiler


    Is to use Entity.class.getDeclaredField("bukkitEntity");

    Also, you don't properly initialize all the fields of CraftPlayer in your CraftPlayerProxy.

    Fields such as health, hiddenPlayers, inventory (In CraftHumanEntity)

    tl;dr this will break stuff
     
  4. Offline

    _Filip

    zombiekiller753 I didn't mean to make it an actual plugin, just as reference code.

    Also, what is the difference with your chain?
    EDIT: Sorry didn't open the last spammed spoiler.

    You're right, I didn't even realise that when I was writing it :p
     
  5. Offline

    Deleted user

    TheSpherret
    Well, I'm just worried that when someone looks at that, they get the wrong impression, such as "That's all I need to proxy it".

    As for the chain, it's just cleaner, like using variable names that actually give a hint as to what they hold (location, posX, etc) instead of 'a', 'b', etc.

    No one would look at the chain and say "Hey! That's a field in the Entity class"
     
  6. Offline

    _Filip

    zombiekiller753 Yeah, I wasn't really thinking when I wrote that. I just wrote the quickest thing I could think of.
    Thanks for pointing that out, I changed it :D. Also if they think that this is all they need to proxy it they'll learn their lesson.

    Alright it's fixed now.
     
Thread Status:
Not open for further replies.

Share This Page