ChangeDataValueTimer.java 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. This file is part of mcMMO.
  3. mcMMO is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. mcMMO is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with mcMMO. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. package com.gmail.nossr50.runnables;
  15. import java.util.ArrayDeque;
  16. import org.bukkit.block.Block;
  17. /*
  18. * This file was created for a breakage introduced in 1.1-R2
  19. * It should be removed afterwards if the breakage is removed.
  20. */
  21. public class ChangeDataValueTimer implements Runnable {
  22. private ArrayDeque<Block> queue;
  23. public ChangeDataValueTimer(ArrayDeque<Block> queue) {
  24. this.queue = queue;
  25. }
  26. public void run() {
  27. int size = queue.size();
  28. if(size == 0) return;
  29. if(size > 25) {
  30. size = (int) Math.floor(size / 10);
  31. }
  32. for(int i = 0; i < size; i++) {
  33. Block change = queue.poll();
  34. if(change == null) continue;
  35. change.setData((byte) 5);
  36. }
  37. }
  38. }