plugin if 10 blocks changed in 2 secomds

Discussion in 'Plugin Development' started by TimonMi, Feb 19, 2013.

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

    TimonMi

    Hey I'd wanted to make a anti-nodus plugin. First I'd wanted to block the build function. This means the player gets kicked if they place more than 10 blocks at 2 seconds. But I don't know how to do the time
     
  2. Offline

    caseif

    I'd suggest listening to the BlockPlaceEvent, then mapping the player to the Unix time that the event occurred at in a global variable. Then have a SyncRepeatingTask running which checks the current time and compares it to all values in the HashMap. If a certain player has too many entries in the HashMap that are less than 2 seconds old, kick them. Additionally, you'll want to delete all values older than two seconds and values of offline players.
     
  3. An easier way would be to make a HashMap<String, Integer> , listen to the BlockPlaceEvent and every time a player places a block add one to his name. Run a SyncRepeatingTask with a delay of 40 Ticks and at the end of the task you go through the list, get the values and check if there's one value higher than 10. Get the player by the key of that value, check if he's not null ( maybe he logged out in these 2 seconds) and kick him with your custom message.

    Edit: And don't forget to clear the hashmap at the end of your repeating task

    Sry, if I couldn't explain it well
     
  4. Offline

    TimonMi

    Please explain it for beginners, because I don't know what hashmaps are but I'm looking for it now. Can you give me a example?
     
  5. You shouldn't start with a plugin like this, if you don't even know what hashmaps are..

    #no offense
     
    Tirelessly likes this.
  6. Offline

    TimonMi

    Hmm.. Now i know what HashMaps are. But How do i create a HashMap for each player that joins?

    Code:
    for(int i = 1 ;i == this.getServer.getOnlinePlayers.length; i++;) {
    private HashMap<Player, Integer> event.getPlayer() = new HashMap<Player, Integer>();
    }
    Is That right?
     
  7. Offline

    Sagacious_Zed Bukkit Docs

    Your compiler should have told you that was wrong.
     
  8. Offline

    TimonMi

    Yes, but how it is right?
     
  9. Offline

    Sagacious_Zed Bukkit Docs

    Those series of statements and expressions is not correct as a whole. Individually you seems to have failed to declare a variable.
     
  10. Offline

    TimonMi

    Code:
    for(int i = 1 ;i == this.getServer.getOnlinePlayers.length; i++;) {
    Player p = event.getPlayer()
    private HashMap<Player, Integer> p = new HashMap<Player, Integer>();
    }
    Is it now Right?

    edit: oh, i'm silly thats not the problem
     
Thread Status:
Not open for further replies.

Share This Page