From b93cb3ff699354df4e9f03b8f2ec298c603a16ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9D=8F=E9=BB=91?= Date: Mon, 22 Oct 2018 23:14:52 +0800 Subject: [PATCH] + SimpleCounter update --- .../skymc/taboolib/common/util/SimpleCounter.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/skymc/taboolib/common/util/SimpleCounter.java b/src/main/java/me/skymc/taboolib/common/util/SimpleCounter.java index 7955d59..3f05e49 100644 --- a/src/main/java/me/skymc/taboolib/common/util/SimpleCounter.java +++ b/src/main/java/me/skymc/taboolib/common/util/SimpleCounter.java @@ -8,16 +8,28 @@ public class SimpleCounter { private int timer; private int limit; + private boolean ignoredFirst; + private boolean counterFirst; public SimpleCounter(int limit) { + this(limit, false); + } + + public SimpleCounter(int limit, boolean ignoredFirst) { this.timer = 0; this.limit = limit; + this.ignoredFirst = true; + this.counterFirst = true; } public boolean next() { if (--timer <= 0) { timer = limit; - return true; + if (ignoredFirst && counterFirst) { + counterFirst = false; + } else { + return true; + } } return false; }