, LifeCycle {
35 |
36 | MachineProperty getProperty();
37 |
38 | default UUID getId() {
39 | return getProperty().getUuid();
40 | }
41 |
42 | default Location getLocation() {
43 | return getProperty().getLocation();
44 | }
45 |
46 | default IState getState() {
47 | return getProperty().getState();
48 | }
49 |
50 | default void update() {
51 | this.update(this);
52 | }
53 |
54 | default Class extends IMachine> getType() {
55 | return this.getClass();
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/io/ib67/astralflow/machines/IState.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * AstralFlow - The plugin enriches bukkit servers
4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | */
21 |
22 | package io.ib67.astralflow.machines;
23 |
24 | import org.jetbrains.annotations.ApiStatus;
25 |
26 | /**
27 | * Data of machine, you can use it for persistence.
28 | * Just subclass this and add your properties, we'll load/save/serialize them for you transparently.
29 | */
30 | @ApiStatus.AvailableSince("0.1.0")
31 | public interface IState {
32 | @SuppressWarnings("unused")
33 | IState EMPTY = new EmptyState();
34 | default Class extends IState> getType() {
35 | return this.getClass();
36 | }
37 |
38 | class EmptyState implements IState {
39 |
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/io/ib67/astralflow/machines/LifeCycle.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * AstralFlow - The plugin enriches bukkit servers
4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | */
21 |
22 | package io.ib67.astralflow.machines;
23 |
24 | import org.jetbrains.annotations.ApiStatus;
25 |
26 | /**
27 | * Represents a lifecycle-able object.
28 | */
29 | @ApiStatus.AvailableSince("0.1.0")
30 | public interface LifeCycle {
31 | /**
32 | * Calls when the chunk is loaded and your machine is ready to initialize.
33 | * You can get {@link io.ib67.astralflow.scheduler.TickReceipt} by calling {@link io.ib67.astralflow.manager.IMachineManager#getReceiptByMachine(IMachine)}.
34 | */
35 | default void onLoad() {
36 | }
37 |
38 | /**
39 | * Called when chunk is unloading or machine is deactivated. Save your data into state here.
40 | */
41 | default void onUnload() {
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/io/ib67/astralflow/machines/Tickless.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * AstralFlow - The plugin enriches bukkit servers
4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | */
21 |
22 | package io.ib67.astralflow.machines;
23 |
24 | import org.jetbrains.annotations.ApiStatus;
25 |
26 | import java.lang.annotation.*;
27 |
28 | /**
29 | * An annotation that represents tick-less machines.
30 | *
31 | * Machines with this annotation will not be ticked.
32 | */
33 | @ApiStatus.AvailableSince("0.1.0")
34 | @Target(ElementType.TYPE)
35 | @Retention(RetentionPolicy.RUNTIME)
36 | @Documented
37 | public @interface Tickless {
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/io/ib67/astralflow/machines/exception/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * AstralFlow - The plugin enriches bukkit servers
4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | */
21 |
22 | /**
23 | * Exceptions that related to some machines.
24 | */
25 | package io.ib67.astralflow.machines.exception;
--------------------------------------------------------------------------------
/src/main/java/io/ib67/astralflow/machines/factories/IMachineFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * AstralFlow - The plugin enriches bukkit servers
4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | */
21 |
22 | package io.ib67.astralflow.machines.factories;
23 |
24 | import io.ib67.astralflow.machines.IMachine;
25 | import io.ib67.astralflow.machines.MachineProperty;
26 | import org.jetbrains.annotations.ApiStatus;
27 |
28 | /**
29 | * A factory that creates machine by a given {@link MachineProperty}.
30 | *
31 | * @param The type of the machine.
32 | */
33 | @ApiStatus.AvailableSince("0.1.0")
34 | @FunctionalInterface
35 | public interface IMachineFactory {
36 |
37 | T createMachine(MachineProperty property);
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/io/ib67/astralflow/machines/factories/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * AstralFlow - The plugin enriches bukkit servers
4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | */
21 |
22 | /**
23 | * About machine creation. Users can customize their machine initialization by registering a {@link io.ib67.astralflow.machines.factories.IMachineFactory}
24 | * Also see: {@link io.ib67.astralflow.api.AstralFlowAPI#getFactories()}
25 | */
26 | package io.ib67.astralflow.machines.factories;
--------------------------------------------------------------------------------
/src/main/java/io/ib67/astralflow/machines/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * AstralFlow - The plugin enriches bukkit servers
4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | */
21 |
22 | /**
23 | * Things about machines.
24 | */
25 | package io.ib67.astralflow.machines;
--------------------------------------------------------------------------------
/src/main/java/io/ib67/astralflow/machines/trait/Interactive.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * AstralFlow - The plugin enriches bukkit servers
4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | */
21 |
22 | package io.ib67.astralflow.machines.trait;
23 |
24 | import org.bukkit.entity.Player;
25 | import org.bukkit.event.block.Action;
26 | import org.bukkit.inventory.ItemStack;
27 | import org.jetbrains.annotations.ApiStatus;
28 | import org.jetbrains.annotations.Nullable;
29 |
30 | /**
31 | * Represents an interactive trait for machines.
32 | */
33 | @ApiStatus.AvailableSince("0.1.0")
34 | public interface Interactive {
35 | /**
36 | * Called when a player tries to interact with the machine. (clicking)
37 | *
38 | * @param clickType The type of interaction.
39 | * @param player The player that interacted.
40 | * @param itemInHand The item in the player's hand.
41 | */
42 | void onInteract(Action clickType, Player player, @Nullable ItemStack itemInHand);
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/io/ib67/astralflow/machines/trait/Pushable.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * AstralFlow - The plugin enriches bukkit servers
4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | */
21 |
22 | package io.ib67.astralflow.machines.trait;
23 |
24 | import org.bukkit.Location;
25 | import org.bukkit.util.Vector;
26 | import org.jetbrains.annotations.ApiStatus;
27 |
28 |
29 | /**
30 | * Represents a trait that can be moved.
31 | */
32 | @ApiStatus.AvailableSince("0.1.0")
33 | @ApiStatus.Experimental
34 | public interface Pushable {
35 | void push(Location newLocation, Vector direction);
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/io/ib67/astralflow/machines/trait/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * AstralFlow - The plugin enriches bukkit servers
4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | */
21 |
22 | /**
23 | * Machine Features.
24 | */
25 | package io.ib67.astralflow.machines.trait;
--------------------------------------------------------------------------------
/src/main/java/io/ib67/astralflow/manager/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * AstralFlow - The plugin enriches bukkit servers
4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | */
21 |
22 | /**
23 | * Managers for some basic components.
24 | */
25 | package io.ib67.astralflow.manager;
--------------------------------------------------------------------------------
/src/main/java/io/ib67/astralflow/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * AstralFlow - The plugin enriches bukkit servers
4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | */
21 |
22 | /**
23 | * The root package.
24 | * Before diving into AstralFlow, You should mention that there're many `Simple` or `XXImpl` classes.
25 | * Generally, these classes are for internal use only and you're not supposed to use them due to not clearly defined behaviours.
26 | * Always use these abstract classes (or interfaces), have fun!
27 | */
28 | package io.ib67.astralflow;
--------------------------------------------------------------------------------
/src/main/java/io/ib67/astralflow/scheduler/AwaitingTickable.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * AstralFlow - The plugin enriches bukkit servers
4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | */
21 |
22 | package io.ib67.astralflow.scheduler;
23 |
24 | import io.ib67.astralflow.Tickable;
25 | import lombok.RequiredArgsConstructor;
26 | import lombok.SneakyThrows;
27 | import org.jetbrains.annotations.ApiStatus;
28 |
29 | import java.util.concurrent.atomic.AtomicInteger;
30 |
31 | @ApiStatus.Internal
32 | @RequiredArgsConstructor
33 | public final class AwaitingTickable> {
34 | public final Tickable tickable;
35 | public final TickReceipt receipt;
36 | public final AtomicInteger exceptionCounter = new AtomicInteger(); // for SimpleCatchingScheduler.
37 |
38 | @SuppressWarnings("all")
39 | public void tick() throws Throwable {
40 | if (receipt.tick(tickable)) {
41 | tickable.update();
42 | }
43 | }
44 |
45 | @Deprecated
46 | @SneakyThrows
47 | public boolean tickAlsoClean() {
48 | if (receipt.isDropped()) {
49 | return true;
50 | }
51 | tick();
52 | return false;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/io/ib67/astralflow/scheduler/Scheduler.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * AstralFlow - The plugin enriches bukkit servers
4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | */
21 |
22 | package io.ib67.astralflow.scheduler;
23 |
24 | import io.ib67.astralflow.Tickable;
25 | import org.jetbrains.annotations.ApiStatus;
26 |
27 | /**
28 | * Task Scheduler.
29 | * Calls every element for every tick.
30 | * Also see {@link Tickable}
31 | */
32 | @ApiStatus.AvailableSince("0.1.0")
33 | public interface Scheduler {
34 |
35 | /**
36 | * tick all things if their receipt allows.
37 | */
38 | @ApiStatus.Internal
39 | void tick();
40 |
41 | /**
42 | * Add a ticking target, throws {@link IllegalArgumentException} when you're attempting to add an object which already exists.
43 | * Always invoke tick( itself )
44 | *
45 | * @param tickable target.
46 | * @param tickType
47 | * @return Receipt. also see {@link TickReceipt}
48 | */
49 | > TickReceipt add(Tickable tickable);
50 |
51 | /**
52 | * Remove from ticklist.
53 | *
54 | * @param tickable tickable object.
55 | */
56 | void remove(Tickable> tickable);
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/io/ib67/astralflow/scheduler/exception/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * AstralFlow - The plugin enriches bukkit servers
4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | */
21 |
22 | /**
23 | * Exceptions may throw in tick loop
24 | */
25 | package io.ib67.astralflow.scheduler.exception;
--------------------------------------------------------------------------------
/src/main/java/io/ib67/astralflow/scheduler/internal/SchedulerAdapter.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * AstralFlow - The plugin enriches bukkit servers
4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | */
21 |
22 | package io.ib67.astralflow.scheduler.internal;
23 |
24 | import io.ib67.astralflow.scheduler.Scheduler;
25 | import lombok.Getter;
26 | import lombok.RequiredArgsConstructor;
27 | import org.bukkit.scheduler.BukkitRunnable;
28 | import org.jetbrains.annotations.ApiStatus;
29 |
30 | @RequiredArgsConstructor
31 | @Getter
32 | @ApiStatus.Internal
33 | public final class SchedulerAdapter extends BukkitRunnable {
34 | private final Scheduler delegatedScheduler;
35 |
36 | @Override
37 | public void run() {
38 | delegatedScheduler.tick();
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/io/ib67/astralflow/scheduler/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * AstralFlow - The plugin enriches bukkit servers
4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | */
21 |
22 | /**
23 | * The scheduler and TickReceipt
24 | */
25 | package io.ib67.astralflow.scheduler;
--------------------------------------------------------------------------------
/src/main/java/io/ib67/astralflow/scheduler/strategies/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * AstralFlow - The plugin enriches bukkit servers
4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | */
21 |
22 | /**
23 | * Some built-in presets for {@link io.ib67.astralflow.scheduler.TickReceipt#requires(java.util.function.Predicate)}
24 | */
25 | package io.ib67.astralflow.scheduler.strategies;
--------------------------------------------------------------------------------
/src/main/java/io/ib67/astralflow/security/ISecurityService.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * AstralFlow - The plugin enriches bukkit servers
4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | */
21 |
22 | package io.ib67.astralflow.security;
23 |
24 | import io.ib67.astralflow.security.mem.ILeakTracker;
25 | import org.jetbrains.annotations.ApiStatus;
26 |
27 | /**
28 | * A security service holds things related to security, from gaming one to jvm one.
29 | */
30 | @ApiStatus.AvailableSince("0.1.0")
31 | public interface ISecurityService {
32 | /**
33 | * Get a tracker for mem leak detection.
34 | *
35 | * @return tracker.
36 | */
37 | ILeakTracker getLeakTracker();
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/io/ib67/astralflow/security/impl/SimpleSecurityService.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * AstralFlow - The plugin enriches bukkit servers
4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | */
21 |
22 | package io.ib67.astralflow.security.impl;
23 |
24 | import io.ib67.astralflow.security.ISecurityService;
25 | import io.ib67.astralflow.security.mem.ILeakTracker;
26 | import lombok.Getter;
27 | import lombok.RequiredArgsConstructor;
28 | import org.jetbrains.annotations.ApiStatus;
29 |
30 | @ApiStatus.Internal
31 | @RequiredArgsConstructor
32 | public final class SimpleSecurityService implements ISecurityService {
33 | @Getter
34 | private final ILeakTracker leakTracker;
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/io/ib67/astralflow/security/mem/ILeakTracker.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * AstralFlow - The plugin enriches bukkit servers
4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | */
21 |
22 | package io.ib67.astralflow.security.mem;
23 |
24 | import org.jetbrains.annotations.ApiStatus;
25 |
26 | /**
27 | * A class that tracks object live time and detects memory leaks.
28 | */
29 | @ApiStatus.AvailableSince("0.1.0")
30 | public interface ILeakTracker {
31 | /**
32 | * Add an object into the track list. Tracker will alert if the object kept in memory for many rounds.
33 | *
34 | * @param obj
35 | */
36 | void track(Object obj);
37 |
38 | /**
39 | * Contrary to {@link #track(Object)}
40 | *
41 | * @param obj
42 | */
43 | void untrack(Object obj);
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/io/ib67/astralflow/security/mem/impl/TrackedObject.java:
--------------------------------------------------------------------------------
1 | /*
2 | *
3 | * AstralFlow - The plugin enriches bukkit servers
4 | * Copyright (C) 2022 The Inlined Lambdas and Contributors
5 | *
6 | * This library is free software; you can redistribute it and/or
7 | * modify it under the terms of the GNU Lesser General Public
8 | * License as published by the Free Software Foundation; either
9 | * version 2.1 of the License, or (at your option) any later version.
10 | *
11 | * This library is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 | * Lesser General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU Lesser General Public
17 | * License along with this library; if not, write to the Free Software
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 | * USA
20 | */
21 |
22 | package io.ib67.astralflow.security.mem.impl;
23 |
24 | import lombok.AllArgsConstructor;
25 |
26 | import java.lang.ref.WeakReference;
27 |
28 | @AllArgsConstructor
29 | final class TrackedObject {
30 | public WeakReference