[HALP] A tangly, confusing struggle with CommandHelper. A cry for halp! #pleasecomeheresmartpeople

Discussion in 'CommandHelper' started by icheesy, Apr 15, 2012.

  1. icheesy

    icheesy Member

    Some super helpful things I desire: (I deeply appreciate it if you could help me... I was going to hire a plugin developer, but I know CommandHelper can do all this stuff! I give you my grateful thanks. You deserve more than that.)

    Using CommandHelper version 817-7c8e34a

    1. Function: This is supposed to have a (safe) lightning strike where a any player dies. Also, it is supposed to kick a player in the group called Tribute when they die. Using PermissionsEx.
    Problem: It kicks all groups! Whether they are in group Tribute or group Admin, they are still kicked. OPTIONAL: remove the fire caused by the lightning. CODE:
    Code (Text):

    bind(player_death, null, null, @event,
        #Safe lightning strikes where a player died
        lightning(ploc(player()), true)
    if (array_contains(pgroup(player()), 'Tribute'),
        kick(player(), 'You have \u00a74died\u00a7f. \u00a7aDonate to not get \u00a7cdeath-kicked.\u00a7b www.HG.owns.it'),
        msg('\u00a7aGood grief! Good thing you donated... Otherwise, you would be kicked')
    ))
     
    2. Function: If a player is inside the WorldGuard region called ‘arena’, then a death message is ejected. The deathmessage is: [In the Hunger Games] Tribute (player) has been slaughtered. ___ tributes are left. The ___ is the number of people inside the WorldGuard region called ‘arena’. If they are not in the region, no death message.
    Problem: I don’t know how to count the people inside the region. I know it’s something to do with all_players and/or sk_current_regions. Here’s my code:
    Code (Text):

    bind(player_death, null, null, @event,
    if (array_contains(sk_current_regions(), 'arena')), #this is the death message arena
              broadcast('\u00a7c[In the Hunger Games]\u00a7f'player()'\u00a77has been slaughtered.'[fill in this part]'tributes are left.)),
    die
    ))
     
    3. Function: When a player logs in, the first time, then run a certain command.
    From/credit ewized: CODE:
    Code (Text):
    [/S]
    [S]bind(player_join, null, null, @event, @server_name,[/S]
    [S]    #if the player is then group default it will run the command /warp test[/S]
    [S]    if(array_contains(pgroup(@event[player]), 'Tribute'), runas(~op,'/warp tutorial'))[/S]
    [S])[/S]
     
    Problem: It doesn’t work. And I’m pretty sure everytime they join, they will be warped there. Error:
    Code (Text):

    02:00:11 [INFO] icheesy [/192.168.1.1:56251] logged in with entity id 49968 at (
    [main] -38.57091493007559, 140.0, -5.136200053331624)
    02:00:11 [INFO] An unexpected exception occured during the execution of a script
    .
    02:00:11 [SEVERE] java.lang.ClassCastException: com.laytonsmith.abstraction.bukk
    it.BukkitMCPlayer cannot be cast to com.laytonsmith.abstraction.bukkit.BukkitMCC
    ommandSender
    02:00:11 [SEVERE]       at com.laytonsmith.abstraction.bukkit.BukkitMCServer.dis
    patchCommand(BukkitMCServer.java:56)
    02:00:11 [SEVERE]       at com.laytonsmith.core.functions.Meta$runas.exec(Meta.j
    ava:70)
    02:00:11 [SEVERE]       at com.laytonsmith.core.Script.eval(Script.java:284)
    02:00:11 [SEVERE]       at com.laytonsmith.core.Script.seval(Script.java:200)
    02:00:11 [SEVERE]       at com.laytonsmith.core.functions.BasicLogic$_if.execs(B
    asicLogic.java:48)
    02:00:11 [SEVERE]       at com.laytonsmith.core.Script.eval(Script.java:247)
    02:00:11 [SEVERE]       at com.laytonsmith.core.MethodScriptCompiler.execute(Met
    hodScriptCompiler.java:1165)
    02:00:11 [SEVERE]       at com.laytonsmith.core.Script.run(Script.java:154)
    02:00:11 [SEVERE]       at com.laytonsmith.core.events.AbstractEvent.execute(Abs
    tractEvent.java:66)
    02:00:11 [SEVERE]       at com.laytonsmith.core.events.BoundEvent.execute(BoundE
    vent.java:290)
    02:00:11 [SEVERE]       at com.laytonsmith.core.events.BoundEvent.trigger(BoundE
    vent.java:250)
    02:00:11 [SEVERE]       at com.laytonsmith.core.events.EventUtils.FireListeners(
    EventUtils.java:179)
    02:00:11 [SEVERE]       at com.laytonsmith.core.events.EventUtils.TriggerListene
    r(EventUtils.java:167)
    02:00:11 [SEVERE]       at com.laytonsmith.abstraction.bukkit.events.drivers.Buk
    kitPlayerListener.onPlayerJoin(BukkitPlayerListener.java:23)
    02:00:11 [SEVERE]       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native M
    ethod)
    02:00:11 [SEVERE]       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown S
    ource)
    02:00:11 [SEVERE]       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unkno
    wn Source)
    02:00:11 [SEVERE]       at java.lang.reflect.Method.invoke(Unknown Source)
    02:00:11 [SEVERE]       at org.bukkit.plugin.java.JavaPluginLoader$1.execute(Jav
    aPluginLoader.java:301)
    02:00:11 [SEVERE]       at org.bukkit.plugin.RegisteredListener.callEvent(Regist
    eredListener.java:62)
    02:00:11 [SEVERE]       at org.bukkit.plugin.SimplePluginManager.callEvent(Simpl
    ePluginManager.java:459)
    02:00:11 [SEVERE]       at net.minecraft.server.ServerConfigurationManager.c(Ser
    verConfigurationManager.java:132)
    02:00:11 [SEVERE]       at net.minecraft.server.NetLoginHandler.b(NetLoginHandle
    r.java:129)
    02:00:11 [SEVERE]       at net.minecraft.server.NetLoginHandler.a(NetLoginHandle
    r.java:41)
    02:00:11 [SEVERE]       at net.minecraft.server.NetworkListenThread.a(NetworkLis
    tenThread.java:61)
    02:00:11 [SEVERE]       at net.minecraft.server.MinecraftServer.w(MinecraftServe
    r.java:551)
    02:00:11 [SEVERE]       at net.minecraft.server.MinecraftServer.run(MinecraftSer
    ver.java:449)
    02:00:11 [SEVERE]       at net.minecraft.server.ThreadServerApplication.run(Sour
    ceFile:492)
    >
     
    FIXED

    4. Problem: This worked in a previous build, but I updated the build and now it doesn’t work:
    Code (Text):

    /hi = >>>
    set_timeout(6500, closure(runas('~op', sconcat(/spawn))))
    <<<
     
    Error:
    Code (Text):

    01:54:59 [WARNING] Task of 'CommandHelper' generated an exception
    java.lang.ClassCastException: com.laytonsmith.abstraction.bukkit.BukkitMCPlayer
    cannot be cast to com.laytonsmith.abstraction.bukkit.BukkitMCCommandSender
            at com.laytonsmith.abstraction.bukkit.BukkitMCServer.dispatchCommand(Buk
    kitMCServer.java:56)
            at com.laytonsmith.core.functions.Meta$runas.exec(Meta.java:70)
            at com.laytonsmith.core.Script.eval(Script.java:284)
            at com.laytonsmith.core.MethodScriptCompiler.execute(MethodScriptCompile
    r.java:1165)
            at com.laytonsmith.core.constructs.CClosure.execute(CClosure.java:125)
            at com.laytonsmith.core.functions.Scheduling$set_timeout$1.run(Schedulin
    g.java:293)
            at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(C
    raftScheduler.java:126)
            at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:517)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:449)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)
     
    5. Function: I want groups to have tags for when they chat! Give me an example so I can convert it!
    Problem: I don’t know where to start. I’m not sure if you’re modifying the set_display_name or chat.FIXED

    I totally understand how many issues I have :p, so you really don't have to spend all your time to answer them all (unless you insist ;)).
    -
    Thanks for taking your time to read this really long thing. I appreciate your reply![/code][/S][/code]
  2. icheesy

    icheesy Member

    OFFTOPIC.... Is anyone getting the 502 gateway nginx error on bukkit?
  3. PseudoKnight

    PseudoKnight Well-Known Member Developer

    I like how you structured your problems. Heh.

    1. Does pgroup() give an array of groups a player is in? If not, it might require a group.groupname permission node in PEX. If this isn't any help, an optional solution is to give the tribute group a certain permission node and then check for that with has_permission(). The code looks fine, otherwise. You don't need player() inside pgroup(), but that works.

    2. I fixed an error if they aren't in a region at all and added what you asked.
    PHP:

    bind(player_death, null, null, @event,
      if (and(is_array(sk_current_regions()), array_contains(sk_current_regions(), 'arena'))),
        assign(@count, 0)
        foreach(all_players(), @player,
          if(and(is_array(sk_current_regions(@player)), array_contains(sk_current_regions(@player), 'arena')),
            inc(@count)
          )
        )
        broadcast(concat('\u00a7c[In the Hunger Games]\u00a7f'player()'\u00a77has been slaughtered. ', @count, ' tributes are left.))
      )
    )
    3. Same problem as the first one.

    4. Odd, try this:
    PHP:

    /hi = >>>
    set_timeout(6500, closure(runas('~op', '/spawn')))
    <<<
    5. I haven't done this myself yet. I just use iChat right now (and two others prior to it). You can try set_display_name or player_chat event, but the former would probably be more compatible with other plugins. This is something I was planning on investigating.
  4. raGan

    raGan Member

    You just have to mark them when they join for the first time, so later they won't be warped.
    PHP:
    if(not(get_value(concat('washere.', @event[player])) == 1),
      YOUR CODE
      store_value(concat('washere.', @event[player]), 1)
    )
    Then you can also easily clear any player's value, so he will be treated like newcomer once again. That's pretty much what I'd do.
  5. icheesy

    icheesy Member

    Thanks guys! I solved the 5th problem! You have to cancel chat then make your own chat.
    Code:
    Code (Text):

    bind(player_chat, null, null, @chatevent,
    cancel()
    if(array_contains(pgroup(@chatevent[player]),'President'),
    assign(@groupPrefix,'§ePresident ')
    broadcast(concat(@groupPrefix,'§f',@chatevent[player],': ',@chatevent[message])))
     
  6. icheesy

    icheesy Member

    This gives an error too... I think runas is broken.
    Code (Text):

    19:25:12 [WARNING] Task of 'CommandHelper' generated an exception
    java.lang.ClassCastException: com.laytonsmith.abstraction.bukkit.BukkitMCPlayer
    cannot be cast to com.laytonsmith.abstraction.bukkit.BukkitMCCommandSender
            at com.laytonsmith.abstraction.bukkit.BukkitMCServer.dispatchCommand(Buk
    kitMCServer.java:56)
            at com.laytonsmith.core.functions.Meta$runas.exec(Meta.java:70)
            at com.laytonsmith.core.Script.eval(Script.java:284)
            at com.laytonsmith.core.MethodScriptCompiler.execute(MethodScriptCompile
    r.java:1165)
            at com.laytonsmith.core.constructs.CClosure.execute(CClosure.java:125)
            at com.laytonsmith.core.functions.Scheduling$set_timeout$1.run(Schedulin
    g.java:293)
            at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(C
    raftScheduler.java:126)
            at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:517)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:449)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)
     
    And I'm not sure how to fix number 1
  7. PseudoKnight

    PseudoKnight Well-Known Member Developer

    1. Did you not try either of the things I mentioned?

    4. runas() works great for me in a number of scenarios. I tried that very script and it works great. (CH #813) Something besides the script is wrong.
  8. LadyCailin

    LadyCailin Administrator Developer

    I broke the abstraction layer, so any "ClassCastExceptions" are my fault. They are probably going to break things all over the place, so for the meantime, just downgrade to a previously working version. It's a "super duper major holy crap, priority attention" bug, so that's the only thing I'm going to work on until it's fixed. Just one of the benefits of using dev versions :)
  9. PseudoKnight

    PseudoKnight Well-Known Member Developer

    It looks like this might be fixed in build #818. (thanks, wraithguard01!) But if that doesn't work for you guys, report the problem and go back to build #813.
  10. LadyCailin

    LadyCailin Administrator Developer

    Try 819. It's more likely to have fixed stuff.
  11. icheesy

    icheesy Member

  12. PseudoKnight

    PseudoKnight Well-Known Member Developer

    It looks like that is missing an end parentheses for the bind function, unless you just didn't include that in your paste.

    But the problem is inheritance in your permissions plugin. I'd do a loop that checks in reverse order of inheritance (eg. administrator -> member -> default) and break() when it finds one.

    PHP:
    bind(player_chat, null, null, @event,
    cancel() #does this create any problems with other plugins?
    assign(@groups, array('Administrator', 'Moderator', 'Member', 'default'))
    for(assign(@i, 0), lt(@i, array_size(@groups)), inc(@i),
      if(array_contains_ic(pgroup(), @groups[@i]),
        assign(@group, @groups[@i])
        break()
      )
    )
    broadcast(concat(@group, ' ', player(), ': ', @event['message']))
    )
     
    Unless someone has a better method, because that'd be nice.

    Or you can drop inheritance or you can put in negative nodes, but that might create undesired behavior in other plugins that you have setup where you expect inheritance.

    Those are long prefixes. You might want to create a separate prefix for each group -- maybe just a color. I use nested arrays for this in the groups ivar for another script I made.

    [edit again] Wait, how are you doing all that formatting in the snapshot? Is another plugin interacting or did you just strip down your pasted script?
  13. icheesy

    icheesy Member

    Oh I have different colors.... I stripped down my pasted script (the colors might confuse people too much as it is spammy).
    I know how to do your way, but I want separate name colors and chat colors... like how it is in my screenshot.
  14. PseudoKnight

    PseudoKnight Well-Known Member Developer

    My way still supports colors. You'd just use a nested array for each group that holds the id (groupname), and prefix. It's a lot cleaner, imo. It also allows you to check groups in order to output only for the player's highest group.

    PHP:

    assign(@groups, array(
    array('administrator', concat(color(red), 'ADM ', color(aqua))),
    array('member', concat(color(gold), 'MEM ', color(yellow))),
    ...