WorldEdit API : Count Certain Block in an Area

Discussion in 'Plugin Development' started by GayZoTe, Aug 2, 2015.

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

    GayZoTe

    hello, i wan't help for the worldeditapi

    i wan't to count certain block in a wordedit selection

    in word edit the //count command is great but i wan't to do that in java.. :(

    i've search in the worldedit java docs, and i don't find it..

    cordially
     
  2. @GayZoTe
    Code:
      @Command(aliases={"/count"}, usage="<block>", desc="Counts the number of a certain type of block", flags="d", min=1, max=1)
      @CommandPermissions({"worldedit.analysis.count"})
      public void count(CommandContext args, LocalSession session, LocalPlayer player, EditSession editSession)
        throws WorldEditException
      {
        boolean useData = args.hasFlag('d');
        if (args.getString(0).contains(":")) {
          useData = true;
        }
        if (useData)
        {
          Set<BaseBlock> searchBlocks = this.we.getBlocks(player, args.getString(0), true);
          int count = editSession.countBlocks(session.getSelection(player.getWorld()), searchBlocks);
          player.print("Counted: " + count);
        }
        else
        {
          Set<Integer> searchIDs = this.we.getBlockIDs(player, args.getString(0), true);
          int count = editSession.countBlock(session.getSelection(player.getWorld()), searchIDs);
          player.print("Counted: " + count);
        }
      }
     
  3. Offline

    GayZoTe

    hello ! thanks for the reply, but, what is 'we' ? i've tested worldedit, worldeditplugin and worldedit api :/
    and, how to launch count?
     
  4. @GayZoTe
    It's the WorldEdit instance, I believe the instance is obtainable through WorldEditPlugin#getWorldEdit(). And what do you mean how to launch count?
     
  5. Offline

    GayZoTe

    i'ts WorldEdit.getInstance(); ^^ but how can i count that? i'ts in a void, there are many ways to start counting, count(); say me to add arguments, bug i don't know what is arg1, arg2, etc..

    bump

    up..

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

    GayZoTe

  7. Offline

    GayZoTe

  8. @GayZoTe
    Code:
    Set<BaseBlock> searchBlocks = this.we.getBlocks(player, args.getString(0), true);
    int count = editSession.countBlocks(session.getSelection(player.getWorld()), searchBlocks);
     
  9. Offline

    GayZoTe

    @megamichiel
     
  10. @GayZoTe
    How does one launch a number?
     
  11. Offline

    GayZoTe

    okay, your function to count , how does it work? i wan't to count in a certain moment, how can i do that? i see /count command in your code, i don't wan't to create an aliase of //count command, i wan't to launch the count in a java plugin

    OKAY I'VE UNDERSTAND, the int "count" is the number of counted block, and the function to count lunch on the onenable plugin i'ts that? but i wan't to count in a certain moment, how can i do that?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 11, 2016
  12. @GayZoTe
    The code I sent you was the code used for the //count command in WorldEdit, it shows exactly what you need to do to count the blocks. By your last message I understand that you barely have any knowledge in java. Please learn some java because Bukkit is built in Java and this is basic knowledge
     
  13. Offline

    GayZoTe

    and, if i wan't to count the blocks in a certain moment how can i do that ? and how to set the selection (min, max) and the block counted?
     
  14. @GayZoTe
    I edited the other message
     
  15. Offline

    GayZoTe

    2 word, fuck you. any knowledge in java? you see that where ? i'm french, si tu veux je peux te parler français la on se comprendra mieux parce que ton anglais il me fais galérer, i'ts hard to understand ? i'ts too for me, your code count okay? but i'ts a void, i'ts callable, i'ts a function. a scheduler in a void are callable, your code are callable with argument, you don't help me with this. you judge my java but you don't help me, i say to you how to edit the wordedit selection, how to edit the block counted, i'm good in java, i'm a noob in we API. Cordially.
     
  16. @GayZoTe
    That sounds like you have no idea how to put it in another place. If you mean something else, my apologies. If you do mean that, I rest my case.
     
  17. Offline

    GayZoTe

    i've the idea, call the function whith count(); but he tell me to add 4 arguments and i don't know how to manipulate that.
     
Thread Status:
Not open for further replies.

Share This Page