Permission Bug

Discussion in 'Plugin Development' started by baldursgate3, May 12, 2013.

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

    baldursgate3

    My problem:
    When player uses the command and he has permission, the command works.
    When he does not have the permission, and the command wasn't turned off, he is still effected by the plugin and he cannot turn it off.
    Main point:
    I want it to be command-less, so when the player has permission, he's affected and when he doesn't have it, the plugin does not effect him.
    If anyone has any idea how to fix it, please do tell.
    Here's my code for plugin.

    public void onPlayerJump(PlayerMoveEvent event) {
    Player p = event.getPlayer();
    Location from = event.getFrom();
    Location to = event.getTo();
    if ((to.getY() > from.getY()) && (plugin.activePlayers.containsKey(p))) {
    Location loc = p.getLocation();
    double loc_y = loc.getY() - 2.0D;
    loc.setY(loc_y);
    Block floor = loc.getBlock();
    if ((floor.getTypeId() != 0) && (loc_y < 128.0D)) {
    int m = ((Integer)plugin.activePlayers.get(p)).intValue();
    double velo_x = (to.getX() - from.getX()) * m;
    double velo_y = (to.getY() - from.getY()) * m;
    double velo_z = (to.getZ() - from.getZ()) * m;

    Vector velo_new = new Vector(velo_x, velo_y, velo_z);
    p.setVelocity(velo_new);

    I want it to be disabled when the player has no permissions.
     
  2. Offline

    chasechocolate

    What's your onCommand()?
     
  3. Offline

    baldursgate3

    public boolean onCommand(CommandSender sender, Command cmd, String label, String args[])
    {
    if(cmd.getName().equalsIgnoreCase("mj"))
    {
    if(!(sender instanceof Player))
    {
    logMessage("The /mj command can only be used in game.");
    return true;
    }
    if(args.length == 0)
    {
    Player p = (Player)sender;
    int amp = defaultMultiplier;
    if(activePlayers.containsKey(p))
    {
    p.sendMessage((new StringBuilder()).append(ChatColor.RED).append("").toString());
    activePlayers.remove(p);
    return true;
    } else
    {
    p.sendMessage((new StringBuilder()).append(ChatColor.RED).append("").toString());
    activePlayers.put(p, Integer.valueOf(amp));
    return true;
    }
    }
     
  4. Offline

    chasechocolate

    Code:java
    1. if(player.hasPermission("some.permission.node")){
    2. //The player has access, do stuff
    3. }
     
  5. Offline

    baldursgate3

    What's the best editing program?
    I accidently deleted the source code.
     
  6. Offline

    chasechocolate

  7. Offline

    baldursgate3

    [quote uid=90645296 name="chasechocolate" post=1668283]baldursgate3 IDE? I use Eclipse.[/quote]
    Do you mind doing me a small favour?
    My computer has been not working lately - maybe because it's too old , and i cannot seem to install any programs.
    All i have is the .jar file, and it functions well but i cannot do anything about it as my computer's useless.
    All i'm asking is, for you do add the permission to my plugin and to compile it, the plugin is mostly made by user "flungo", but he allowed me to make changes to it while he's doing his work at college, so if you can.
    Can you do it for me? I would appreciate it alot.
    Got permission to modify it*
    Link: <Edit by Moderator: Redacted mediafire url>

    So, could you do it? I might go offline for a week, as i'm getting a new computer.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 6, 2016
Thread Status:
Not open for further replies.

Share This Page