Solved Enderdragon Issue

Discussion in 'Plugin Development' started by FIRESTORMER, Oct 23, 2014.

Thread Status:
Not open for further replies.
  1. Hello.
    On my server I use a plugin that respawns the enderdragon once in a while, this gives everyone a fair chance to battle it. Everyone can also use /warp end to get there to fight it when it is alive. If you kill the enderdragon, you receive a decent amount of ingame money. I believe I am not the only server that has a feature like this.

    Recently I have found a bug. Players can go to the end from spawn, then if they attack the dragon once and use /back or any other command to teleport out of the end, they will automatically receive the reward for killing the dragon. I believe that Minecraft thinks the dragon is dead when the player leaves or something? I don’t believe it is the rewarding plugin that is causing it. Because it only rewards if you killed the mob.

    So I coded something that might fix this issue. Basically a player cannot teleport out of the end before the enderdragon is dead. Unfortunately I don’t think this is a solid fix for the issue, I was wondering if anyone had any suggestions to a different solution. Thank you for your time.
    Here is the code:
    Code:java
    1. @EventHandler
    2. public void onPlayerTeleport(PlayerTeleportEvent event){
    3. Player player = event.getPlayer();
    4. if (!player.hasPermission("rcad.bypass")) {
    5. if (player.getWorld().getName().equals("world_the_end")) {
    6. for(Entity ent : Bukkit.getServer().getWorld("world_the_end").getEntities()) {
    7. if (ent instanceof EnderDragon) {
    8. EnderDragon enderdragon = (EnderDragon) ent;
    9. if (enderdragon.getHealth() != enderdragon.getMaxHealth()) {
    10. event.setCancelled(true);
    11. player.sendMessage("§bYou cannot leave The End before the Enderdragon is dead!");
    12. }
    13. }
    14. }
    15. }
    16. }
    17. }
     
  2. Offline

    fireblast709

    FIRESTORMER If you post the code that triggers the reward, perhaps someone could spot a bug there.
     
  3. Offline

    teej107

  4. How would that fix the problem? Honestly it seems like it is exactly like what I already coded. The player can leave The End unless the dragon already lost health.
     
  5. Offline

    teej107

    FIRESTORMER Similar but different. Just keep track of the players who attack the mob and make it so they can't leave. After all, the exploit begins when a player attacks the enderdragon, right? Why do you have to include the players who haven't damaged it yet? Other than that, you should probably notify the dev of this exploit so he can fix it.
     
  6. FIRESTORMER the bug must be in the plugin. you can recognize this if you think about it. the plugin you're using for this is giving the money to the player. if the player kills the enderdragon the plugin gives the money. if the player leaves the end after hurting but not killing the enderdragon, the plugin gives the money. so it must be the plugin, they did not make sure that the enderdragon is dead in this plugin. maybe they used the wrong event, because they should ve use entitydeathevent, check if it is an enderdragon and give every player who is in the end at this moment the money. this are a few simple lines which would work perfectly, some programmer did bullshit there, that's it and nothing else.
     
    FIRESTORMER likes this.
  7. Shmobi That seems like the perfect solution. If the player can only get the money if he is in The End then this shouldn’t be a possible exploit. Thanks.
     
  8. FIRESTORMER set thread to solved, maybe like my post? :D
     
    FIRESTORMER likes this.
Thread Status:
Not open for further replies.

Share This Page