Worldguard region to glass when player near?

Discussion in 'Plugin Development' started by pablo67340, Mar 2, 2015.

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

    pablo67340

    Hi there,

    I am trying to figure this out, and i am quite stuck. I am trying to make it so when a player is approx 2 blocks away from any part of a world guard region, it will generate a glass wall near them, and follow them if they run. Kind of like a magic carpet, that blocks entry. Could someone please help?

    Thanks in advanced!
     
  2. Offline

    SuchSwegMuchWow

    @pablo67340 Also wondered about this, but never really tried it out. I think that sending block updates is one way of doing this
     
  3. Offline

    pablo67340

    Has anyone come up with something?
     
  4. Offline

    TehHypnoz

    I have created a plugin like this a while ago, when a player moves you need to check if they are near the region and if so use the Player.sendBlockChange() method to create a 'wall' (other players won't see it). Keep in mind that they can glitch through the wall, so if they try to enter spawn, teleport them back. I'm currently on my phone, if you can reply to this I will probably see it tomorrow and can post an example.
     
  5. Offline

    nj2miami

    This would be a highly heavy plugin as you would have to continuously monitor player position in world in relation to all other WG regions not to mention constantly update the "floating wall" with every movement they make. I would be willing to wager heavily this would become a lag monster with even a few users on any normal server.

    Mind you the PlayerMoveEvent is called everytime ANY movement is made, whether it is where they look or where they move. Every tick basically you are asking the server to check where the player is, check all WG regions which exist, determine if they are within 2 blocks? (not even sure how that math would work out) then place a wall of blocks?

    I know graphically, that sounds cool, but not sure how appropriate. I could suggest *maybe* using WGRegionEvents and then rejecting the user upon entry?
     
  6. Offline

    pablo67340

    If you have ever seen the plugin called "war" they do this with their own regions. Keep in mind it does not do this for every region, only regions listed in the config. only protects specific regions.

    Sorry for double post, forgot to reply to you! Do you still have the example on hand?

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

    Techcable

    War doesn't find the edges of the world guard region. It uses setMaterial instead of sendBlockChange so it is visible to everyone.
     
  8. Offline

    TehHypnoz

    My example code results in huge lag or even crashes when the spawn is too big, but what you should do is this:

    In the PlayerMoveEvent, check if the player is in the region (you will have to find this out yourself). If he is not, check if he is close to the region. Then you can create a border using the following code (creates red stained glass):

    Code:
    p.sendBlockChange(block, Material.STAINED_GLASS, (byte) 14);
    
    Make sure to replace it with air again when they move away from the region:

    Code:
    p.sendBlockChange(block, Material.AIR, (byte) 0);
    
     
  9. Offline

    Techcable

    @pablo67340
    I've got a class that allows you to create blocks visible only to certain players.
    This intercepts outgoing packets using protocol lib so it isn't glitchy.

    Link

    Make sure to read the license on top of the code.
     
Thread Status:
Not open for further replies.

Share This Page