Skip to content

Commit 0581f12

Browse files
author
codeHusky
committed
Working PageUpdatable code
1 parent 6be657b commit 0581f12

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/main/java/com/codehusky/huskyui/StateContainer.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ public void openState(@Nonnull final Player player, @Nonnull final String id) {
215215
InventoryUtil.close(player);
216216
Page page = (Page) state;
217217
Inventory toShow = page.getPageView();
218-
System.out.println(page.getUpdateTickRate());
219218
if(this.scheduledTask != null){
220219
this.scheduledTask.cancel();
221220
this.scheduledTask = null;
@@ -228,19 +227,20 @@ public void openState(@Nonnull final Player player, @Nonnull final String id) {
228227
if (container.getProperties(StringProperty.class).size() != 2) {
229228
scheduledTask.cancel();
230229
scheduledTask = null;
230+
return;
231231
}else{
232232
StringProperty property1 = ((StringProperty)container.getProperties(StringProperty.class).toArray()[0]);
233233
StringProperty property2 = ((StringProperty)container.getProperties(StringProperty.class).toArray()[1]);
234-
System.out.println(property1.getValue());
235234
if(!property2.getValue().equals(page.getId())) {
236235
if (!property1.getValue().equals(page.getId())) {
237236
scheduledTask.cancel();
238237
scheduledTask = null;
238+
return;
239239
}
240240
}
241241
}
242242
}
243-
if(page.getTicks() % page.getUpdateTickRate() == 0) {
243+
if(page.getActualTicks() % page.getUpdateTickRate() == 0) {
244244
this.pageUpdater.accept(page);
245245
}
246246
page.tickIncrement();

src/main/java/com/codehusky/huskyui/states/Page.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,14 @@ public int getRows() {
247247
}
248248
private long ticks = 0;
249249

250-
public long getTicks() {
250+
public long getActualTicks() {
251251
return ticks;
252252
}
253253

254+
public long getTicks() {
255+
return (long)Math.floor(ticks/updateTickRate);
256+
}
257+
254258
public void tickIncrement() {
255259
ticks++;
256260
}

0 commit comments

Comments
 (0)