Need help with 2 things permission and ...

Discussion in 'Plugin Development' started by ahuby09, Feb 7, 2014.

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

    ahuby09

    how would make permissions also give permissions with signs , and also how would i make it when you click a certain block it will send you back to spawn ?
     
  2. Offline

    Freelix2000

    First, you must define a spawn location. If you want the spawn location to remain the same even after the plugin disables, it will have to write to data. You should first make a default in the config with location data, which might look like this: world:x:y:z:pitch:yaw. Then you can get that as a string, use the 'split' method to use 's' as a separator, and turn it into a location with
    Code:java
    1. String data = getConfig().getString("YOUR_DEFAULT_NAME");
    2. Location loc = new Location(Bukkit.getWorld(data.split(":")[0], Double.parseDouble(data.split(":")[1]), Double.parseDouble(data.split(":")[2]), Double.parseDouble(data.split(":")[3]), Float.parseFloat(data.split(":")[4]), Float.parseFloat(data.split(":")[5]));

    Then to detect the sign click, make an event that looks like this:
    Code:java
    1. @EventHandler
    2. public void onInteract(PlayerInteractEvent e){
    3. Player p = e.getPlayer();
    4. if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK) && e.getClickedBlock().getState() instanceof Sign){
    5. Sign sign = (Sign) e.getClickedBlock().getState();
    6. if(sign.getLine(0).equals("HUB"){
    7. //Define "loc" as hub location here
    8. p.teleport(loc);
    9. }
    10. }
    11. }

    I'm not really sure how to assign permissions, I've never made a permissions plugin before, but you can use that event to assign permissions as well. Also, like the locations, permissions will not be there when the plugin disables, or even when the player leaves. You will have to write the permissions to a file and assign them when a player joins for them to be somewhat permanent.
     
Thread Status:
Not open for further replies.

Share This Page