Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tte sign testbranch #16

Merged
merged 161 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
161 commits
Select commit Hold shift + click to select a range
ed29a0a
begin new sign API
DerToaster98 Aug 1, 2024
0825279
add base class for signs and registration
DerToaster98 Aug 1, 2024
b66b5e0
add craft sign => For stuff like cruise signs or remote signs
DerToaster98 Aug 1, 2024
6a3ad90
implement listener that calls the individual registered signs
DerToaster98 Aug 1, 2024
9ca4816
add base for cruise-like signs
DerToaster98 Aug 2, 2024
c80df99
add overloaded internalProcessing method for craftsigns
DerToaster98 Aug 2, 2024
07e829e
add method to get ident of sign instance
DerToaster98 Aug 2, 2024
edbd6ef
call detect event with the sign
DerToaster98 Aug 2, 2024
0b3f467
migrate name sign to new sign API
DerToaster98 Aug 2, 2024
95cbe5b
organize imports
DerToaster98 Aug 2, 2024
f82bb7b
reimplement release sign with new sign api
DerToaster98 Aug 2, 2024
4692881
reimplement scuttle sign with new sign API
DerToaster98 Aug 2, 2024
08611a9
register release and scuttle signs
DerToaster98 Aug 2, 2024
d4f9cbb
migrate Move and RMove signs
DerToaster98 Aug 2, 2024
8f92799
move perm check to canPlayerUseOn
DerToaster98 Aug 4, 2024
81cf5a9
migrate helm sign
DerToaster98 Aug 4, 2024
99aa146
rename method to "onCraftisBusy" is it isn't always a parent craft bu…
DerToaster98 Aug 4, 2024
a66a0af
allow double colons in idents
DerToaster98 Aug 4, 2024
c4623f5
add comment for later
DerToaster98 Aug 4, 2024
9575095
make sign listener abstract and add abstraction layer to signs
DerToaster98 Aug 10, 2024
2997b1e
initialize sign listener like the version specific stuff
DerToaster98 Aug 10, 2024
604abeb
refactor sign base classes to use the abstraction class
DerToaster98 Aug 10, 2024
c1bf27d
add base for info signs
DerToaster98 Aug 10, 2024
0edd8cb
refactors
DerToaster98 Aug 10, 2024
d679689
add 1.21 implementation of signlistener
DerToaster98 Aug 10, 2024
02fe15e
fix imports
DerToaster98 Aug 10, 2024
ef9ca4b
add 1.20 implementation of listener
DerToaster98 Aug 10, 2024
383683e
add 1.18 signListener implementation
DerToaster98 Aug 10, 2024
f8e6c02
migrate teleport sign and fix move sign
DerToaster98 Aug 10, 2024
7260f9d
fix helm sign
DerToaster98 Aug 10, 2024
7b77377
add comment in TeleportSign
DerToaster98 Aug 10, 2024
ddec33c
migrate PilotSign
DerToaster98 Aug 10, 2024
a3b2c52
migrate cruise sign
DerToaster98 Aug 10, 2024
6913afe
forgot that
DerToaster98 Aug 10, 2024
57c9d98
migrate cruise signs
DerToaster98 Aug 10, 2024
38c644a
fix namesign
DerToaster98 Aug 10, 2024
0d61dd5
migrate speed sign
DerToaster98 Aug 10, 2024
f9681d4
own wrapper for SignTranslateEvent
DerToaster98 Aug 10, 2024
50b83dc
actually return something
DerToaster98 Aug 10, 2024
d95c1d0
migrate speed sign
DerToaster98 Aug 10, 2024
2a53a7c
forgot those
DerToaster98 Aug 10, 2024
35ea966
move status sign class
DerToaster98 Aug 11, 2024
d882603
add constants for colors and add enum for update reason
DerToaster98 Aug 11, 2024
1ede8b7
migrate status sign
DerToaster98 Aug 11, 2024
b546e7a
fix speed sign
DerToaster98 Aug 11, 2024
1bcae23
migrate craft pilot sign
DerToaster98 Aug 14, 2024
e89dbf5
register calls
DerToaster98 Aug 14, 2024
01cf53c
remove old sign
DerToaster98 Aug 14, 2024
540d89f
add helper methods
DerToaster98 Aug 14, 2024
47638bd
add todo notes
DerToaster98 Aug 15, 2024
bea521b
move status sign back to where it was
DerToaster98 Aug 19, 2024
e9b7c62
subscribe to event to re-register the craft sigsn
DerToaster98 Aug 19, 2024
5efcc73
remove unnecessary if
DerToaster98 Aug 19, 2024
4537421
Optional => Nullable string
DerToaster98 Aug 19, 2024
69d701d
typo fix
DerToaster98 Aug 19, 2024
b307c87
add overloaded register method
DerToaster98 Aug 19, 2024
8219dc3
Optional<Craft> => Nullable Craft
DerToaster98 Aug 19, 2024
0b3d5d1
remove static modifier
DerToaster98 Aug 19, 2024
344afce
refactor equals function
DerToaster98 Aug 19, 2024
a133c7b
documentation
DerToaster98 Aug 20, 2024
3a261a6
small corrections
DerToaster98 Aug 20, 2024
a755453
add base for subcraft signs
DerToaster98 Aug 20, 2024
e78f2fd
migrate Remote Sign
DerToaster98 Aug 27, 2024
ebc5a3b
Migrate subcraft rotate sign
DerToaster98 Aug 27, 2024
e493b78
fix refactor artifact
DerToaster98 Aug 27, 2024
dc0075c
remove unneeded variable => use the field!
DerToaster98 Aug 27, 2024
f8414ed
migrate contacts sign
DerToaster98 Aug 28, 2024
36fbe17
fix error
DerToaster98 Aug 28, 2024
1b512f2
add isEmpty() method and add implementation for equals
DerToaster98 Aug 28, 2024
c84a81a
if the other is null it will be false. Always
DerToaster98 Aug 28, 2024
48add81
begin migrating SignTranslateEvent to use the signwrapper (issue #688)
DerToaster98 Aug 28, 2024
104be46
add methods to directly allow Component as header dient
DerToaster98 Aug 28, 2024
22f1520
use new methods
DerToaster98 Aug 28, 2024
c583ab4
todo notes
DerToaster98 Aug 28, 2024
dce6e0f
use new methods in SignTranslateEvent
DerToaster98 Aug 28, 2024
514a447
add facing value to event
DerToaster98 Aug 29, 2024
fb0446e
add more utility and itnerface methods
DerToaster98 Aug 29, 2024
376986c
call the adatper
DerToaster98 Aug 29, 2024
4e407a3
implement methods in adatpers
DerToaster98 Aug 29, 2024
9531e36
adjust information signs
DerToaster98 Aug 29, 2024
630dd47
deprecation note
DerToaster98 Aug 29, 2024
13831c2
Merge branch 'main' into sign-rework
DerToaster98 Aug 29, 2024
9b20ae0
fix method name
DerToaster98 Aug 29, 2024
68c62a1
fix compile errors
DerToaster98 Aug 29, 2024
92141d4
fix release sign => it is not dependant on a craft existing!
DerToaster98 Aug 29, 2024
c55af06
Merge pull request #6 from TTE-DevTeam/1.21-readd-support
DerToaster98 Sep 5, 2024
1d648fe
Merge pull request #7 from TTE-DevTeam/attachment-blocks-disabled-by-…
DerToaster98 Sep 5, 2024
df064f6
Update CraftRotateCommand.java
DerToaster98 Sep 5, 2024
93d346a
Merge pull request #8 from TTE-DevTeam/passthrough-performance-fix
DerToaster98 Sep 5, 2024
98415fd
Merge pull request #9 from TTE-DevTeam/sign-rework
DerToaster98 Sep 5, 2024
2df78c5
fix startup error => can't retrieve ident while registering
DerToaster98 Sep 5, 2024
60858c6
Merge pull request #10 from TTE-DevTeam/sign-rework
DerToaster98 Sep 5, 2024
5248bc2
fix getSignWrappers() method for sign => NPE
DerToaster98 Sep 5, 2024
189782c
fix status sign
DerToaster98 Sep 5, 2024
a2350b2
craft is nullable
DerToaster98 Sep 5, 2024
7f46895
corrections to BlockFace access
DerToaster98 Sep 5, 2024
d5ded2e
more fixes regarding getting the blockface of a sign...
DerToaster98 Sep 5, 2024
aff2a1d
NPE prevention
DerToaster98 Sep 5, 2024
dc85f9d
add TODO note
DerToaster98 Sep 5, 2024
9f82820
remove spaces from suffix
DerToaster98 Sep 5, 2024
a307803
correction => if the ident has trailing : => don't add them yourself …
DerToaster98 Sep 5, 2024
453b0a5
startup correction
DerToaster98 Sep 5, 2024
ce7f379
forgot the space
DerToaster98 Sep 5, 2024
7075208
avoid double inversion
DerToaster98 Sep 5, 2024
1aaf852
crafttype is specified in second, not the third line
DerToaster98 Sep 5, 2024
d70b65b
typo
DerToaster98 Sep 5, 2024
e8896a2
remote sign correction => don't use old list, use HashMap and use com…
DerToaster98 Sep 5, 2024
e2bae7d
fix information signs not updating
DerToaster98 Sep 6, 2024
c1b996b
comment out debug logs
DerToaster98 Sep 6, 2024
3194ed7
call update on the state, not on the block...
DerToaster98 Sep 6, 2024
2df0385
more elegant solution
DerToaster98 Sep 6, 2024
039756d
actually perform the update, event uses the signwrapper under the hoo…
DerToaster98 Sep 6, 2024
956053d
fix status sign (reimplement based on @Vaan1310 changes)
DerToaster98 Sep 6, 2024
9a40431
NPE prevention
DerToaster98 Sep 6, 2024
232ab10
remove unnecessary toUpperCase()
DerToaster98 Sep 6, 2024
91ff872
add eventtype enum (to api classes)
DerToaster98 Sep 6, 2024
3f8dfdb
refactor for eventtype enum (implementations)
DerToaster98 Sep 6, 2024
633f33c
refactor for eventtype enum (implementations (simple))
DerToaster98 Sep 6, 2024
3aa0dc9
Status Sign: round to 2 decimals
DerToaster98 Sep 6, 2024
5e0ed2e
supply eventType and use nullable for sign get access
DerToaster98 Sep 10, 2024
88baa63
just call it override
DerToaster98 Sep 10, 2024
1853ba7
add registry base class, implement it, and use it
DerToaster98 Sep 10, 2024
2316876
adjust comment
DerToaster98 Sep 10, 2024
238e989
adjust comment
DerToaster98 Sep 10, 2024
fd70b50
remove old code
DerToaster98 Sep 10, 2024
dd9e0cb
Merge branch 'main' of https://github.com/APDevTeam/Movecraft into AP…
DerToaster98 Sep 11, 2024
5d11290
Merge branch 'APDevTeam-main' into tte-sign-testbranch
DerToaster98 Sep 11, 2024
54336e5
remove 1.18 signListener
DerToaster98 Sep 11, 2024
ffc7dfe
fix build errors
DerToaster98 Sep 11, 2024
27b9491
properly implement shouldCancel method (API + examples)
DerToaster98 Sep 11, 2024
a71712f
properly implement shouldCancel in the rest
DerToaster98 Sep 11, 2024
f7fd65e
add override items and tools
DerToaster98 Sep 11, 2024
6a09a70
small tweaks regarding interactions
DerToaster98 Sep 11, 2024
d912af5
shorten fuel string length
DerToaster98 Sep 11, 2024
a2c4691
shorten text
DerToaster98 Sep 11, 2024
8e7f1bf
NPE prevention
DerToaster98 Sep 11, 2024
82d4693
shrink string more
DerToaster98 Sep 11, 2024
08b4e6d
respect edits with dyecolors, wax, etc
DerToaster98 Sep 12, 2024
bf9f926
kilo, million, billion, trillion fuel
DerToaster98 Sep 12, 2024
e3a730c
extract base elements from Cruise sign into a toggle sign
DerToaster98 Sep 12, 2024
e06e37e
replacement for resetSigns => DO NOT MERGE INTO API YET
DerToaster98 Sep 12, 2024
a426bcf
update signs after detect
DerToaster98 Sep 12, 2024
088ca62
fix indexOutOfBoundsException
DerToaster98 Sep 12, 2024
74d103f
forgot facing check in cruise sign
DerToaster98 Sep 12, 2024
64dcadb
reset columns when switiching lines
DerToaster98 Sep 12, 2024
869cb5a
cancel sign clicks on crafts in all cases
DerToaster98 Sep 12, 2024
c345a25
only cancel when sign is empty
DerToaster98 Sep 12, 2024
481948b
properly toggle other signs off
DerToaster98 Sep 12, 2024
9b29de6
also return true in that case, otherwise no update
DerToaster98 Sep 12, 2024
ff7c777
allow toggle signs to decide if they are resetted by a different togg…
DerToaster98 Sep 12, 2024
9f3eb36
remove version specific versions of the signListener as 1.18 is gone …
DerToaster98 Sep 13, 2024
dc459d2
adapt to refactoring
DerToaster98 Sep 13, 2024
60959b1
adapt remaining implementations to refactor
DerToaster98 Sep 13, 2024
77bb394
use newer method
DerToaster98 Sep 13, 2024
b09af7b
fix compile errors and remove old code
DerToaster98 Sep 13, 2024
834794f
fix override param
DerToaster98 Sep 13, 2024
2454f78
fix subcraft sign creation
DerToaster98 Sep 15, 2024
397e7fe
apply default text and implement processSignChange
DerToaster98 Sep 15, 2024
441452c
correct typo
DerToaster98 Sep 15, 2024
0433e31
return true
DerToaster98 Sep 17, 2024
0ce7710
call stuff for the other side, if that side is a movecraft sign
DerToaster98 Sep 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 41 additions & 18 deletions Movecraft/src/main/java/net/countercraft/movecraft/Movecraft.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import net.countercraft.movecraft.config.Settings;
import net.countercraft.movecraft.craft.ChunkManager;
import net.countercraft.movecraft.craft.CraftManager;
import net.countercraft.movecraft.craft.datatag.CraftDataTagRegistry;
import net.countercraft.movecraft.features.contacts.ContactsCommand;
import net.countercraft.movecraft.features.contacts.ContactsManager;
import net.countercraft.movecraft.features.contacts.ContactsSign;
Expand Down Expand Up @@ -209,37 +208,61 @@ public void onEnable() {
getCommand("crafttype").setExecutor(new CraftTypeCommand());
getCommand("craftinfo").setExecutor(new CraftInfoCommand());

// Naming scheme: If it has parameters, append a double colon except if it is a subcraft
// Parameters follow on the following lines
getServer().getPluginManager().registerEvents(new BlockListener(), this);
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
getServer().getPluginManager().registerEvents(new ChunkManager(), this);
getServer().getPluginManager().registerEvents(new AscendSign(), this);
getServer().getPluginManager().registerEvents(new CraftSign(), this);
getServer().getPluginManager().registerEvents(new CruiseSign(), this);
getServer().getPluginManager().registerEvents(new DescendSign(), this);
getServer().getPluginManager().registerEvents(new HelmSign(), this);
getServer().getPluginManager().registerEvents(new MoveSign(), this);
getServer().getPluginManager().registerEvents(new NameSign(), this);
getServer().getPluginManager().registerEvents(new PilotSign(), this);
getServer().getPluginManager().registerEvents(new RelativeMoveSign(), this);
getServer().getPluginManager().registerEvents(new ReleaseSign(), this);
getServer().getPluginManager().registerEvents(new RemoteSign(), this);
getServer().getPluginManager().registerEvents(new SpeedSign(), this);
getServer().getPluginManager().registerEvents(new SubcraftRotateSign(), this);
getServer().getPluginManager().registerEvents(new TeleportSign(), this);
getServer().getPluginManager().registerEvents(new ScuttleSign(), this);
//getServer().getPluginManager().registerEvents(new AscendSign(), this);
AbstractMovecraftSign.register("Ascend:", new AscendSign("Ascend:"));
//getServer().getPluginManager().registerEvents(new CruiseSign(), this);
AbstractMovecraftSign.register("Cruise:", new CruiseSign("Cruise:"));
//getServer().getPluginManager().registerEvents(new DescendSign(), this);
AbstractMovecraftSign.register("Descend:", new DescendSign("Descend:"));
//getServer().getPluginManager().registerEvents(new HelmSign(), this);
AbstractMovecraftSign.register("[Helm]", new HelmSign());
AbstractMovecraftSign.register(HelmSign.PRETTY_HEADER, new HelmSign());
//getServer().getPluginManager().registerEvents(new MoveSign(), this);
AbstractMovecraftSign.register("Move:", new MoveSign());
//getServer().getPluginManager().registerEvents(new NameSign(), this);
AbstractMovecraftSign.register("Name:", new NameSign());
//getServer().getPluginManager().registerEvents(new PilotSign(), this);
AbstractMovecraftSign.register("Pilot:", new PilotSign());
//getServer().getPluginManager().registerEvents(new RelativeMoveSign(), this);
AbstractMovecraftSign.register("RMove:", new RelativeMoveSign());
//getServer().getPluginManager().registerEvents(new ReleaseSign(), this);
AbstractMovecraftSign.register("Release", new ReleaseSign());
//getServer().getPluginManager().registerEvents(new RemoteSign(), this);
AbstractMovecraftSign.register("Remote Sign", new RemoteSign());
//getServer().getPluginManager().registerEvents(new SpeedSign(), this);
AbstractMovecraftSign.register("Speed:", new SpeedSign());
AbstractMovecraftSign.register("Status:", new StatusSign());
AbstractMovecraftSign.register("Contacts:", new ContactsSign());
//getServer().getPluginManager().registerEvents(new SubcraftRotateSign(), this);
AbstractMovecraftSign.register("Subcraft Rotate", new SubcraftRotateSign(CraftManager.getInstance()::getCraftTypeFromString, Movecraft::getInstance));
//getServer().getPluginManager().registerEvents(new TeleportSign(), this);
AbstractMovecraftSign.register("Teleport:", new TeleportSign());
//getServer().getPluginManager().registerEvents(new ScuttleSign(), this);
AbstractMovecraftSign.register("Scuttle", new ScuttleSign());
getServer().getPluginManager().registerEvents(new CraftPilotListener(), this);
getServer().getPluginManager().registerEvents(new CraftReleaseListener(), this);
getServer().getPluginManager().registerEvents(new SignListener(), this);
// Moved to compat section!
//getServer().getPluginManager().registerEvents(new SignListener(), this);

AbstractMovecraftSign.registerCraftPilotSigns(CraftManager.getInstance().getCraftTypes(), CraftPilotSign::new);

var contactsManager = new ContactsManager();
contactsManager.runTaskTimerAsynchronously(this, 0, 20);
getServer().getPluginManager().registerEvents(contactsManager, this);
getServer().getPluginManager().registerEvents(new ContactsSign(), this);
//getServer().getPluginManager().registerEvents(new ContactsSign(), this);
getServer().getPluginManager().registerEvents(new CraftTypeListener(), this);
getCommand("contacts").setExecutor(new ContactsCommand());

var statusManager = new StatusManager();
statusManager.runTaskTimerAsynchronously(this, 0, 1);
getServer().getPluginManager().registerEvents(statusManager, this);
getServer().getPluginManager().registerEvents(new StatusSign(), this);
//getServer().getPluginManager().registerEvents(new StatusSign(), this);

logger.info("[V " + getDescription().getVersion() + "] has been enabled.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import net.countercraft.movecraft.Movecraft;
import net.countercraft.movecraft.craft.CraftManager;
import net.countercraft.movecraft.localisation.I18nSupport;
import net.countercraft.movecraft.sign.AbstractMovecraftSign;
import net.countercraft.movecraft.sign.CraftPilotSign;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,107 +3,100 @@
import net.countercraft.movecraft.MovecraftLocation;
import net.countercraft.movecraft.craft.Craft;
import net.countercraft.movecraft.craft.type.CraftType;
import net.countercraft.movecraft.events.CraftDetectEvent;
import net.countercraft.movecraft.events.SignTranslateEvent;
import org.bukkit.ChatColor;
import org.bukkit.Tag;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import net.countercraft.movecraft.sign.AbstractInformationSign;
import net.countercraft.movecraft.sign.SignListener;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.Style;
import org.bukkit.entity.Player;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class ContactsSign implements Listener {
private static final String HEADER = "Contacts:";
import java.util.List;

@EventHandler
public void onCraftDetect(@NotNull CraftDetectEvent event) {
World world = event.getCraft().getWorld();
for (MovecraftLocation location : event.getCraft().getHitBox()) {
var block = location.toBukkit(world).getBlock();
if (!Tag.SIGNS.isTagged(block.getType()))
continue;
public class ContactsSign extends AbstractInformationSign {

BlockState state = block.getState();
if (!(state instanceof Sign sign))
continue;
protected final int MAX_DISTANCE_COLOR_RED = 64 * 64;
protected final int MAX_DISTANCE_COLOR_YELLOW = 128 * 128;

if (!ChatColor.stripColor(sign.getLine(0)).equalsIgnoreCase(HEADER))
continue;

sign.setLine(1, "");
sign.setLine(2, "");
sign.setLine(3, "");
sign.update();
}
}

@EventHandler
public final void onSignTranslateEvent(@NotNull SignTranslateEvent event) {
if (!ChatColor.stripColor(event.getLine(0)).equalsIgnoreCase(HEADER))
return;
protected @NotNull Component contactsLine(@NotNull Craft base, @NotNull Craft target) {
MovecraftLocation baseCenter = base.getHitBox().getMidPoint();
MovecraftLocation targetCenter = target.getHitBox().getMidPoint();
int distanceSquared = baseCenter.distanceSquared(targetCenter);

Craft base = event.getCraft();
int line = 1;
for (Craft target : base.getDataTag(Craft.CONTACTS)) {
if (line > 3)
break;
String craftTypeName = target.getType().getStringProperty(CraftType.NAME);
if (craftTypeName.length() > 9)
craftTypeName = craftTypeName.substring(0, 7);

event.setLine(line++, contactsLine(base, target));
Style style = STYLE_COLOR_GREEN;
if (distanceSquared <= MAX_DISTANCE_COLOR_RED) {
style = STYLE_COLOR_RED;
}
while (line <= 3) {
event.setLine(line++, "");
else if (distanceSquared <= MAX_DISTANCE_COLOR_YELLOW) {
style = STYLE_COLOR_YELLOW;
}
}

private static @NotNull String contactsLine(@NotNull Craft base, @NotNull Craft target) {
MovecraftLocation baseCenter = base.getHitBox().getMidPoint();
MovecraftLocation targetCenter = target.getHitBox().getMidPoint();
int distanceSquared = baseCenter.distanceSquared(targetCenter);

String result = ChatColor.BLUE + target.getType().getStringProperty(CraftType.NAME);
if (result.length() > 9)
result = result.substring(0, 7);
Component result = Component.text(craftTypeName + " ").style(style);

result += " " + (int) Math.sqrt(distanceSquared);
int diffX = baseCenter.getX() - targetCenter.getX();
int diffZ = baseCenter.getZ() - targetCenter.getZ();
String directionStr = "" + (int) Math.sqrt(distanceSquared);
if (Math.abs(diffX) > Math.abs(diffZ)) {
if (diffX<0) {
result +=" E";
directionStr +=" E";
} else {
result +=" W";
directionStr +=" W";
}
} else {
if (diffZ<0) {
result +=" S";
directionStr +=" S";
} else {
result +=" N";
directionStr +=" N";
}
}
result = result.append(Component.text(directionStr).style(STYLE_COLOR_WHITE));
return result;
}

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onSignClickEvent(@NotNull PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
@Override
protected boolean internalProcessSignWithCraft(Action clickType, SignListener.SignWrapper sign, Craft craft, Player player) {
player.performCommand("contacts");

Block block = event.getClickedBlock();
if (block == null)
return;
if (!(block.getState() instanceof Sign sign))
return;
return true;
}

@Override
protected @Nullable Component getUpdateString(int lineIndex, Component oldData, Craft craft) {
Craft contact = null;
List<Craft> contacts = craft.getDataTag(Craft.CONTACTS);
if (contacts.isEmpty() || contacts.size() < lineIndex) {
return EMPTY;
}
contact = contacts.get(lineIndex);

return contactsLine(craft, contact);
}

@Override
protected @Nullable Component getDefaultString(int lineIndex, Component oldComponent) {
return EMPTY;
}

@Override
protected void performUpdate(Component[] newComponents, SignListener.SignWrapper sign, REFRESH_CAUSE refreshCause) {
for (int i = 0; i < newComponents.length; i++) {
Component newComp = newComponents[i];
if (newComp != null) {
sign.line(i, newComp);
}
}
if (refreshCause != REFRESH_CAUSE.SIGN_MOVED_BY_CRAFT && sign.block() != null) {
sign.block().update();
}
}

if (!ChatColor.stripColor(sign.getLine(0)).equalsIgnoreCase(HEADER))
return;
@Override
protected void onCraftIsBusy(Player player, Craft craft) {

event.setCancelled(true);
event.getPlayer().performCommand("contacts");
}
}
Loading