[Lib] ForceRespawn - Bypass the death screen - 1.2.5 to 1.6.2

Discussion in 'Resources' started by psycowithespn, Jul 11, 2013.

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

    psycowithespn

    ForceRespawn is a library plugin, like TagAPI, that allows plugins to force players to respawn. It was designed because of a flaw in my plugin TF2 in which damage taken does not count armor, so people were "dieing" when they had health left.

    Why use ForceRespawn?
    Using ForceRespawn instead of doing armor calculations can decrease some load on the server and also remove any hacky NMS that has to keep updating. You can just let players die normally.

    How do I use this?
    First off, you need to make sure ForceRespawn is accessible to your project. You can grab the latest version here. If you are using maven, you just need to add this repository and dependency:
    Code:
    <repository>
      <id>forcerespawn</id>
      <url>http://repo.chaseoes.com/content/groups/public</url>
    </repository>
     
    <dependency>
      <groupId>com.chaseoes</groupId>
      <artifactId>ForceRespawn-Plugin</artifactId>
      <version>LATEST</version>
    </dependency>
    
    OK, now that your project can find ForceRespawn, you will want to listen to the ForceRespawnEvent. It is called 1 tick after PlayerDeathEvent. This event contains the player that will be force respawned, getPlayer(), and whether or not they will be respawned, isForcedRespawn(). You can mark a player to be force respwaned or not with setForcedRespawn(boolean). Here is an example of the event in action:

    Code:
    @EventHandler
    public void onForceRespawn(ForceRespawnEvent event) {
        if (event.getPlayer().getName().equals("Notch")) {
            event.setForcedRespawn(true);
        }
    }
    
    In the above code, if the players name is Notch, then they will be marked for a forced respawn.

    If you know a player is on a death screen, then you can also use ForceRespawn.sendRespawnPacket(Player) to respawn them. This would most likely be useful on login, but you could be creative. If the player is not on a death screen when this method is called, it simply does nothing.

    Where should I link my users to your plugin?
    http://dev.bukkit.org/bukkit-plugins/force-respawn/

    Have a question or need help?
    Ask away in the comments below or find me in IRC on esper.net. I am normally in #bukkit, #bukkitdev, and #tf2plugin.
     
    _DSH105_ likes this.
  2. Offline

    kreashenz

    Or the Packet205ClientCommand
    Code:java
    1. Packet205ClientCommand packet = new Packet205ClientCommand();
    2. packet.a = 1;
    3. ((CraftPlayer) p).getHandle().playerConnection.a(packet);


    http://forums.bukkit.org/threads/153592/ <-- Exactly the same thing, much easier without a lib.
     
  3. Offline

    TomFromCollege

    psycowithespn

    I have to agree with kreashenz, if you're developing a plugin, you don't want to have to rely on others to update their work before your events continue to work...
    I guess having an event is nice, but in this case the event doesn't really make sense.
    onForceRespawn() assumes the player has forceRespawned and then ask if event should be cancelled or not. You'd put this in the PlayerDeathEvent if anything.
     
  4. Offline

    psycowithespn

    kreashenz and TomFromCollege

    Feel free to use NMS. This was just convenience I created to go along with another plugin that I did not want any NMS in. I figured if I wanted something like this, then someone else in the community might want it too. Also, the ForceRespawnEvent defaults to "cancelled" first. It requires another plugin to set forcedRespawn to true in order to work. Also, I did try using the PlayerDeathEvent, but that resulted in items being dropped at the respawn location. ForceRespawnEvent is called 1 tick after to fix that.

    tl;dr I understand your concerns but this will still exist for my purposes.
     
Thread Status:
Not open for further replies.

Share This Page