Is it possible? cmd block - entity

Discussion in 'Spigot Plugin Development' started by WestZahid, May 19, 2016.

Thread Status:
Not open for further replies.
  1. Starts at Post #3

    Old Post:
    Hello,

    since I finally finish my limit chat distance I was thinking about command blocks.
    The problem with chat distance is ofc that I can only get all bukkitplayers and send them a message because the position of the command block is not set.

    What I need is a way to "mark" command blocks and save there position to send later my command with limit chat distance.

    So I start thinking about a new plugin "DummyNPC" or something.
    Type "/dummynpc [name]" and hit a command block - It save the location and give me a variable with its name, which spigot can handle like a normal player.... (my english is aweful xd)

    Is this possible?
    #InvisibleEntity?
     
    #1 WestZahid, May 19, 2016
    Last edited: May 24, 2016
  2. Get its location by checking if the sender is a BlockCommandSender, then getting its block.

    If all you're trying to do is execute a command on players within a certain radius, consider learning how to use target selectors.
     
  3. hey,

    thank you for your answer i was a bit busy in rl last days.
    do i understand it correct that "BlockCommandSender" is something like ConsoleCommandSender?

    atmo i use this code to check if sender is not a player:
    if(!(sender instanceof Player))

    so i must replace it with:
    if(sender instanceof ConsoleCommandSender){ CMD}
    AND
    if(sender instanceof BlockCommandSender){ CMD}
    ?

    And my next question is how do i use getBlock correct?

    atmo i use this code to check if players are in range (extra class):
    for (Player other : Bukkit.getOnlinePlayers())
    if (other.getWorld() == p.getWorld() && other.getLocation().distance(p.getLocation()) <= maxDistance){


    how must i modify it for command blocks?

    PS: sry i never use blockcommandsender befor and i find no nice tut on youtube with this tag
     
  4. If you actually take a look at the documentation, you can see that you can easily get the block associated with BlockCommandSender.
     
  5. if it would be "easy" for me i dont ask ...
    lets just say, it dont help me.

    ps: helpful part is empty
     
    #5 WestZahid, May 24, 2016
    Last edited: May 24, 2016
  6. ... have someone at least a plugin that use BlockCommandSender+getBlock?
    that i can look into it to help my self ..

    i dont want to push my post for this ... answer again .. so:
    EDIT: forget it sry that ive ask something in a forum
     
    #6 WestZahid, May 24, 2016
    Last edited: May 24, 2016
Thread Status:
Not open for further replies.