I am developing a plugin and so far is going pretty well, except 1 thing. I can't figure out how to set intervals to be used in my plugin. For example for every 5 dirt blocks a player places i want a command to run such as /eco give playername 500 giving them $500 Anyone know how to do the interval thing in java code? PM or email thanks please. OR POST XD
Just set a hashmap, and then whenver a player places a block, just add 1 to it. Then, just run a conditional if the player has placed 5 dirt blocks.
But i would many conditionals to do this...? Say if i wanted every 5 blocks so I would put 1 for 10, 15, 20, etc...
Nah.. only one conditional would be needed really. If you wanted to do every 5. you would just reset the variable everytime 5 is hit. Logic: Code (Text): place dirt: update player variable + 1 if player variable is equal to 5: execute command reset player variable to 0 that would ensure that every 5th block would execute the command OR you could do a modulo and just check if the player variable can be divided by 5 with no remainder. That would make it a multiple of 5, meaning it would have to be an iteration of a 5th block.
Okay... what if I wanted it to stack so that a player will have placed 24 blocks, (Not resetting it to 0) and on the 25th they get $500... I don't want it to reset, the point is to make a block placing counter to reward them as an example.
Then what you could do is create a multidimensional Map like <playername, Block, integer> and that way, one HashMap can store all of the placement you want.
Okay I admit it i want to make a killstreak plugin and every 5 kills I want it to give a money multiplied reward! anyone also know how to make a broadcast in eclipse code of a similar format to this ******HEY YOU******* YEAH YOU LOOK HERE ******HEY YOU******* With configurable multiline support in config.yml also how do i create a placeholder like %player% or %coords% to display the coords they are at?
Even you didn't know that at some point. Be a little less harsh, please Code (Text): String message = "taco <noob>"; player.sendMessage(message.replace("<noob>", player.getName())); Post everything else you need in a reply, I'll help you out! It just got a little jumbled in the above posts.
I want to be able to use placeholders in my config, how do I make a method that checks if the string %coords% or %player% is used in the config?