Random Spawn Plugin

Discussion in 'Plugin Requests' started by Lightcaster5, Jul 11, 2019.

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

    Lightcaster5

    Name: RandomSpawn
    Version: 1.12.2
    Description: Randomly teleports players on first join/death to a random location IN set values. Players won't be teleported underground or in a cave. If anyone has played 2b2t before it is something like that. Along with the random spawn there should be a way to list blocks that players cannot spawn on/in.
    Example of the config:
    Code:
    #Players will be teleported randomly between values
    pos1: -100
    pos2: 100
    
    #Disallowed blocks
    enable-blacklist: 'true'
    blacklisted-blocks:
      - lava
      - water
      - cactus
      - diamond_block
    
    no-permission: '&cYou do not have permission to use this command!'
    Commands:
    /rtppos1 (sets the first position, this shouldn't use y-values)
    /rtppos2 (sets the second position, this shouldn't use y-values)

    Permissions:
    rtp.setpos (allows players to use the /rtppos1 & /rtppos2)
     
  2. Offline

    IncinerateZ

    This should cover what you're looking for.

    Teleports new players to your server to the specified coordinates, to the surface, and avoiding banned blocks.

    I'm quite new to dealing with configs so I made a separate readme textfile for specifications and descriptions.

    Commands: /rtp pos1, /rtp pos2
    Permissions: rtp.setpos

    Tell me if you need anything changed.
     
  3. Offline

    Lightcaster5

    Haven't tried it yet but I will when FileZilla loads. You said "new" players? This was meant to be new and onDeath... if it isn't I will let you know if I need more help because I know a little about java and the spigot api and might be able to modify your code or add a new class that does the same thing as the onPlayerJoin event.

    Edit:
    I just decompiled the code and saw that there was no onPlayerDeath event so I am just going to copy everything into intellij and copy the onPlayerJoin event and just change it to a death event. I will let you know if everything works after that. Thanks!

    Edit:
    Alright so everything kinda works... There is a problem where a player spawns on a block with no lava but there is lava right above the block so the player still dies.
     
    Last edited: Jul 15, 2019
  4. Offline

    KarimAKL

    @Lightcaster5 If you know about Java and the Bukkit/Spigot API, then why aren't you creating the plugin yourself? (I'm just curious) If you have any questions you could always ask in the Plugin Development forum.
     
  5. Offline

    Lightcaster5

    I said "I know a little about java and the spigot api" so stuff like making a simple help command with a few pages using arguments or making custom death messages. I asked for a plugin like this because it was far beyond what I knew and I already attempted creating the plugin myself more than three times so I thought it would be best to simply build off of someone elses code.
     
  6. Offline

    KarimAKL

    @Lightcaster5 I see. :7 When you say "lava right above the block", where do you mean? Would you like lava blocked only for the blocks the player is inside or also if lava is going to flow down onto the player? In case you also want possible flowing lava to be blocked, do you only want lava in the same X and Z or also lava that's going to flow down a path onto the player? I'm just asking so that @IncinerateZ doesn't have to. (in case they fix this for you)
     
  7. Offline

    Lightcaster5

    The problem is, now that you said it... the player still can spawn in flowing lava but I thought it was because there was air under the lava... What you pointed out is correct and flowing lava and flowing water need to be blocked too.

    Edit:
    This may be a me error... let me see what happens if I add the flowing variants to the blacklisted blocks list.

    Edit:
    It was a me error... Everything worked after I added the flowing variants to the blacklisted blocks list. Thanks @KarimAKL and @IncinerateZ for your help.

    Yet another... Edit:
    New problem... A player can still spawn on a block, lets say cobblestone, with air right above it but there is lava above the air. Example:
    Layer 3 - Lava (The plugin doesn't pick this up and the player still spawns in it)
    Layer 2 - Air (This means a player can spawn on the dirt below)
    Layer 1 - Dirt

    Please help.
     
    Last edited: Jul 15, 2019
  8. Offline

    IncinerateZ

    No problem, didn't quite get the on join part you requested due to wording stuff so I left it out :)

    Edit: Updated the plugin: download.
    Changes: -Added an onPlayerRespawn (This is better, but if you really want an onPlayerDeath, i'll change it for you)
    -Tweaked Config: Used STATIONARY_WATER and WATER.
    -Updated pos1 & pos2 subcommand to auto reload config.

    After these changes I tried replicating your bug but I couldn't get it to trigger, I guess it got fixed with the config tweaks?

    Lemme know if more problems arise (which shouldn't), or if you want it to be onPlayerDeath.

    Edit2: forgot to undo stuff i used for debugging; updated download link
     
    Last edited: Jul 15, 2019
  9. Offline

    KarimAKL

    A player is 2 blocks high; do you mean that their feet's block is air and their head's block is lava? Either way, answering my question from before should explain what you want.
     
  10. Offline

    Lightcaster5

    Feet block air, head block lava... And the command doesnt work at all... and for some reason the config isnt working to set the positions. The command gives no output but doesnt say "Unknown command. Type "/help" for help."

    I dont really understand your question all too well but all I need is for the player to not spawn in lava or flowing lava... in anyway that could kill them upon respawn or join.

    Now I have to get some sleep but I will be able to reply more tomorrow. Thanks for the help and all future help.
     
  11. Offline

    KarimAKL

    @Lightcaster5 I've made a little example in Windows Paint. :p (Took forever with my little knowledge of that app. xD)
    View attachment 32359
    Imagine the grey as stone (in a cave), the blue as a player and the red as a lava source block. That lava is gonna flow from there onto the player, i was asking if you wanted to check for lava that's gonna do something like that, or you just want to check the player's feet and head.
     
  12. Offline

    Lightcaster5

    I wanted it to check if the lava will or has already fallen to where the player is going to be randomly teleported to.

    Thanks and yes, adding a onPlayerDeath would be nice. I havent tested everything just yet because I cant get on my main pc but I will later and when I do I will be sure to let you know. Thanks!
     
    Last edited by a moderator: Jul 16, 2019
  13. Offline

    KarimAKL

    "will", does that include what i was trying to explain?
     
  14. Offline

    Lightcaster5

    yes, and I meant if the lava will fall on the player or has already fallen to the spot.
     
  15. Offline

    IncinerateZ

    Just to explain how the random teleportation method works is that it picks out a random location within the set range and teleports the player above the build limit and gradually brings them down (checking for air, and checking for banned blocks if air is not found), so the bug that occured should not have happened provided that the correct list of banned blocks is provided.

    This is the download for the onDeath version, when a player goes hits 0 hp or less they will instantly be respawned without being shown the 'You Died' screen.
     
    Last edited: Jul 18, 2019
  16. Offline

    Lightcaster5

    This works much better. Although just doing "/rtp" throws a message "An internal error has occurred" and the console says this:
    Code:
    18.07 08:06:30 [Server] ERROR null
    18.07 08:06:30 [Server] INFO org.bukkit.command.CommandException: Unhandled exception executing command 'rtp' in plugin RandomSpawn v1.0
    18.07 08:06:30 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
    18.07 08:06:30 [Server] INFO at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
    18.07 08:06:30 [Server] INFO at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand(CraftServer.java:648) ~[spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
    18.07 08:06:30 [Server] INFO at net.minecraft.server.v1_12_R1.PlayerConnection.handleCommand(PlayerConnection.java:1401) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
    18.07 08:06:30 [Server] INFO at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1236) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
    18.07 08:06:30 [Server] INFO at net.minecraft.server.v1_12_R1.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
    18.07 08:06:30 [Server] INFO at net.minecraft.server.v1_12_R1.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
    18.07 08:06:30 [Server] INFO at net.minecraft.server.v1_12_R1.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
    18.07 08:06:30 [Server] INFO at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_191]
    18.07 08:06:30 [Server] INFO at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_191]
    18.07 08:06:30 [Server] INFO at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
    18.07 08:06:30 [Server] INFO at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:748) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
    18.07 08:06:30 [Server] INFO at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
    18.07 08:06:30 [Server] INFO at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
    18.07 08:06:30 [Server] INFO at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
    18.07 08:06:30 [Server] INFO at java.lang.Thread.run(Thread.java:748) [?:1.8.0_191]
    18.07 08:06:30 [Server] INFO Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
    18.07 08:06:30 [Server] INFO at me.incineratez.randomspawn.commands.RandomSpawn.onCommand(RandomSpawn.java:27) ~[?:?]
    18.07 08:06:30 [Server] INFO at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
    18.07 08:06:30 [Server] INFO ... 15 more
    Also, for example if players spawn in lava they still burn and I dont know the method for it but I think it should be something like e.getPlayer.isBurning(false); and all the effects need to be cleared from the player as well. The very last thing I am facing is when the player does /suicide (one of the few commands they have that is built into essentials) your plugin doesn't kick in and take over... I will do my best but it would be much appreciated if you could work on it too. Thanks!


    Edit:
    I added a few more things to the death teleport event...
    Code:
    p.setFireTicks(0);
    for (PotionEffect effect : p.getActivePotionEffects())
         p.removePotionEffect(effect.getType());
     
    Last edited: Jul 18, 2019
  17. Offline

    IncinerateZ

    Oops I didnt add an edge case for that but you should be able to do it from your end: if(args.length == 0) whateverYouWant;

    I dont get that second bit but I'll try to see what I can do with that suicide bit since /kill works fine.
     
  18. Offline

    Lightcaster5

    /kill <yourname> and /suicide do the same things but /suicide gives me the "Respawn" and "Title Screen" display. And its all good, I forget things too lol, we're only human :p
    Thanks for all your work and please add the
     
  19. Offline

    IncinerateZ

    I've never really used /suicide before but /kill also shows the respawn and title screen overlay and triggers an onEntityDamage event which I used to cancel the player's death, not sure about suicide.

    Download link: link.
     
    Last edited: Jul 18, 2019
  20. Offline

    Resoluciones

    Hi I think this plugin is useful too. I am using a similar one, but sometimes players appear on the ocean, so maybe I will change it for this one.

    I wonder what happens if the players have already set the respawn sleeping on bed? Would this plugin cancel the respawn at bed, or the random spawn will persist?

    Thanks!
     
  21. Offline

    IncinerateZ

    The random spawn will persist, since the player technically does not die.
     
  22. Offline

    Lightcaster5

    Could that be added? Bed spawn support and any other vanilla spawn-setting feature support so it doesn't change/interfere with existing features. Thanks @Resoluciones for pointing it out and thanks @IncinerateZ for all the work you have done and all the future time spent into this plugin. I look forward to seeing what this plugin can become.
     
  23. Offline

    IncinerateZ

    The only vanilla spawn-setting feature I could think of was beds (other than setspawn) so I added support for it, I also added a toggle for onDeath or onRespawn. These new settings are added to the config 'bed-spawn' and 'on-death' respectively, default for both are true. Download link.
     
  24. Offline

    Lightcaster5

    The config didnt have a new section... are you sure that is the right version that is in the dropbox link?
     
  25. Offline

    CraftCreeper6

  26. Offline

    Lightcaster5

    I downloaded it and decompiled it as I do everytime a new version of it is released and nothing changed since the "bed support update" came... deleting the config will only reproduce the same one...
     
  27. Offline

    Resoluciones

    yeah I think the new options are not present in the config, maybe the Dev uploaded the same previous file.

    Can you clarify the difference between 'bed-spawn' and 'on-death'?

    As per I understand the player will random spawn on the following circuntances:

    1 - First join
    2 - After he dies (on respawn)

    So bed-spawn and on-death should be both on, right? Aren't them the same thing? Or maybe there is something I am not understanding.

    When the player login to the server, it will spawn where he left, right?

    Thanks!
     
  28. Offline

    Lightcaster5

    Alright so a few things, Yes I agree with the previous file... The difference is when you sleep in a bed it sets your spawn by that bed but the problem is the plugin doesn't (currently) use that information and overrides this and randomly teleports the player based on the config. The updated version of the plugin should test if a player has a "bed spawn" and if they do, tp them to it but if not randomly teleport the player based on the config. Lastly, yes... upon login, if the player didnt log off because of death, the player will stay in their current position until death, though if a player did log off because of death then the plugin should kick in and take over the player's new position.

    Hope this helped. I must go but I will be able to test, assist, and/or pass ideas when needed. Thanks everyone!
     
  29. Offline

    Resoluciones

    Hi! I've tested the plugin and when i died it tpped me to a random spot, neverthless i had a bed, I think it's not working 100% ok.
     
  30. Offline

    IncinerateZ

    The original plugin requester had requested that the events be fired onFirstJoin and onDeath. The difference between onDeath and onRespawn is that onDeath will instantly random-tp you ( or spawn you if you have a bed) without showing the 'You Died' screen, while onRespawn is triggered *after* you click on the 'Respawn' button. onDeath should not increase your death count nor will any items be dropped (even with gamerule keepInventory set to false).

    bed-spawn simply toggles the requested bed support to on or off while on-death toggles between onDeath and onRespawn.

    ill look into why the new config isnt loading.

    Edit: It seems like the upload to dropbox wasnt actually done, weird. Download link.
     
    Last edited: Jul 18, 2019
Thread Status:
Not open for further replies.

Share This Page