-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ Fixed sign showing up after the GUI is closed. + Added lombok (makes my life easier.) + Made async packet process sync (so it can interact with the world directly without the need of implementing your own solution or running up the task id number.)
- Loading branch information
Showing
5 changed files
with
69 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package dev.pns.signapi; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
public class Async2Sync { | ||
private final List<SignTask> signTasks = new ArrayList<>(); | ||
|
||
public Async2Sync(JavaPlugin plugin) { | ||
Bukkit.getScheduler().runTaskTimer(plugin, () -> { | ||
if (signTasks.isEmpty()) return; | ||
Iterator<SignTask> iterator = signTasks.iterator(); | ||
while (iterator.hasNext()) { | ||
SignTask signTask = iterator.next(); | ||
signTask.getPlayer().sendBlockChange(signTask.getBlock().getLocation(), signTask.getBlock().getBlockData()); | ||
signTask.getOnClose().method(signTask.getPlayer(), signTask.getLines()); | ||
iterator.remove(); | ||
} | ||
}, 0, 1); | ||
} | ||
|
||
public void add(SignTask signTask) { | ||
signTasks.add(signTask); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package dev.pns.signapi; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.Setter; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.entity.Player; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public class SignTask { | ||
private final Player player; | ||
private final SignGUI.onClose onClose; | ||
private final Block block; | ||
@Setter | ||
private String[] lines; | ||
} |