-
-
Notifications
You must be signed in to change notification settings - Fork 89
[Feature / Cleanup] Sign rework (WIP) #679
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
Open
DerToaster98
wants to merge
123
commits into
APDevTeam:main
Choose a base branch
from
TTE-DevTeam:sign-rework
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
123 commits
Select commit
Hold shift + click to select a range
ed29a0a
begin new sign API
DerToaster98 0825279
add base class for signs and registration
DerToaster98 b66b5e0
add craft sign => For stuff like cruise signs or remote signs
DerToaster98 6a3ad90
implement listener that calls the individual registered signs
DerToaster98 9ca4816
add base for cruise-like signs
DerToaster98 c80df99
add overloaded internalProcessing method for craftsigns
DerToaster98 07e829e
add method to get ident of sign instance
DerToaster98 edbd6ef
call detect event with the sign
DerToaster98 0b3f467
migrate name sign to new sign API
DerToaster98 95cbe5b
organize imports
DerToaster98 f82bb7b
reimplement release sign with new sign api
DerToaster98 4692881
reimplement scuttle sign with new sign API
DerToaster98 08611a9
register release and scuttle signs
DerToaster98 d4f9cbb
migrate Move and RMove signs
DerToaster98 8f92799
move perm check to canPlayerUseOn
DerToaster98 81cf5a9
migrate helm sign
DerToaster98 99aa146
rename method to "onCraftisBusy" is it isn't always a parent craft bu…
DerToaster98 a66a0af
allow double colons in idents
DerToaster98 c4623f5
add comment for later
DerToaster98 9575095
make sign listener abstract and add abstraction layer to signs
DerToaster98 2997b1e
initialize sign listener like the version specific stuff
DerToaster98 604abeb
refactor sign base classes to use the abstraction class
DerToaster98 c1bf27d
add base for info signs
DerToaster98 0edd8cb
refactors
DerToaster98 d679689
add 1.21 implementation of signlistener
DerToaster98 02fe15e
fix imports
DerToaster98 ef9ca4b
add 1.20 implementation of listener
DerToaster98 383683e
add 1.18 signListener implementation
DerToaster98 f8e6c02
migrate teleport sign and fix move sign
DerToaster98 7260f9d
fix helm sign
DerToaster98 7b77377
add comment in TeleportSign
DerToaster98 ddec33c
migrate PilotSign
DerToaster98 a3b2c52
migrate cruise sign
DerToaster98 6913afe
forgot that
DerToaster98 57c9d98
migrate cruise signs
DerToaster98 38c644a
fix namesign
DerToaster98 0d61dd5
migrate speed sign
DerToaster98 f9681d4
own wrapper for SignTranslateEvent
DerToaster98 50b83dc
actually return something
DerToaster98 d95c1d0
migrate speed sign
DerToaster98 2a53a7c
forgot those
DerToaster98 35ea966
move status sign class
DerToaster98 d882603
add constants for colors and add enum for update reason
DerToaster98 1ede8b7
migrate status sign
DerToaster98 b546e7a
fix speed sign
DerToaster98 1bcae23
migrate craft pilot sign
DerToaster98 e89dbf5
register calls
DerToaster98 01cf53c
remove old sign
DerToaster98 540d89f
add helper methods
DerToaster98 47638bd
add todo notes
DerToaster98 bea521b
move status sign back to where it was
DerToaster98 e9b7c62
subscribe to event to re-register the craft sigsn
DerToaster98 5efcc73
remove unnecessary if
DerToaster98 4537421
Optional => Nullable string
DerToaster98 69d701d
typo fix
DerToaster98 b307c87
add overloaded register method
DerToaster98 8219dc3
Optional<Craft> => Nullable Craft
DerToaster98 0b3d5d1
remove static modifier
DerToaster98 344afce
refactor equals function
DerToaster98 a133c7b
documentation
DerToaster98 3a261a6
small corrections
DerToaster98 a755453
add base for subcraft signs
DerToaster98 e78f2fd
migrate Remote Sign
DerToaster98 ebc5a3b
Migrate subcraft rotate sign
DerToaster98 e493b78
fix refactor artifact
DerToaster98 dc0075c
remove unneeded variable => use the field!
DerToaster98 f8414ed
migrate contacts sign
DerToaster98 36fbe17
fix error
DerToaster98 1b512f2
add isEmpty() method and add implementation for equals
DerToaster98 c84a81a
if the other is null it will be false. Always
DerToaster98 48add81
begin migrating SignTranslateEvent to use the signwrapper (issue #688)
DerToaster98 104be46
add methods to directly allow Component as header dient
DerToaster98 22f1520
use new methods
DerToaster98 c583ab4
todo notes
DerToaster98 dce6e0f
use new methods in SignTranslateEvent
DerToaster98 514a447
add facing value to event
DerToaster98 fb0446e
add more utility and itnerface methods
DerToaster98 376986c
call the adatper
DerToaster98 4e407a3
implement methods in adatpers
DerToaster98 9531e36
adjust information signs
DerToaster98 630dd47
deprecation note
DerToaster98 13831c2
Merge branch 'main' into sign-rework
DerToaster98 9b20ae0
fix method name
DerToaster98 68c62a1
fix compile errors
DerToaster98 92141d4
fix release sign => it is not dependant on a craft existing!
DerToaster98 2df78c5
fix startup error => can't retrieve ident while registering
DerToaster98 960b30a
fix getSignWrappers() method for sign => NPE
DerToaster98 060d8b4
fix status sign
DerToaster98 debb191
craft is nullable
DerToaster98 39e08a5
corrections to BlockFace access
DerToaster98 9b7ea60
more fixes regarding getting the blockface of a sign...
DerToaster98 48a9bc1
NPE prevention
DerToaster98 ca35cd3
add TODO note
DerToaster98 464fcd6
remove spaces from suffix
DerToaster98 b65562e
correction => if the ident has trailing : => don't add them yourself …
DerToaster98 132f179
startup correction
DerToaster98 5ff7af8
forgot the space
DerToaster98 9fb1917
avoid double inversion
DerToaster98 e09c26d
crafttype is specified in second, not the third line
DerToaster98 6b1d67f
typo
DerToaster98 eb50ec4
remote sign correction => don't use old list, use HashMap and use com…
DerToaster98 8e76762
fix information signs not updating
DerToaster98 d86b510
comment out debug logs
DerToaster98 5ac3fc6
call update on the state, not on the block...
DerToaster98 7bf7297
more elegant solution
DerToaster98 0178865
actually perform the update, event uses the signwrapper under the hoo…
DerToaster98 9da541b
fix status sign (reimplement based on @Vaan1310 changes)
DerToaster98 26d1497
NPE prevention
DerToaster98 1153498
remove unnecessary toUpperCase()
DerToaster98 731aae7
add eventtype enum (to api classes)
DerToaster98 baad4f8
refactor for eventtype enum (implementations)
DerToaster98 cdd55d1
refactor for eventtype enum (implementations (simple))
DerToaster98 f4eef4a
Status Sign: round to 2 decimals
DerToaster98 4bc2ad4
supply eventType and use nullable for sign get access
DerToaster98 21c61c0
just call it override
DerToaster98 9acc31a
add registry base class, implement it, and use it
DerToaster98 aef31b4
adjust comment
DerToaster98 970d49d
adjust comment
DerToaster98 0da888d
remove old code
DerToaster98 bf29040
index out of bounds exception patch
DerToaster98 d44c29d
add getter for crafttype
DerToaster98 ca320fc
cherry pick commit
DerToaster98 dcddc05
cherry pick commit
DerToaster98 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
Movecraft/src/main/java/net/countercraft/movecraft/listener/SignListener.java
This file contains hidden or 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,2 @@ | ||
| package net.countercraft.movecraft.listener;public class SignListener { | ||
| } |
2 changes: 2 additions & 0 deletions
2
api/src/main/java/net/countercraft/movecraft/sign/AbstractCraftSign.java
This file contains hidden or 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,2 @@ | ||
| package net.countercraft.movecraft.sign;public class AbstractCraftSign { | ||
| } |
83 changes: 83 additions & 0 deletions
83
api/src/main/java/net/countercraft/movecraft/sign/AbstractMovecraftSign.java
This file contains hidden or 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,83 @@ | ||
| package net.countercraft.movecraft.sign; | ||
|
|
||
| import net.countercraft.movecraft.craft.Craft; | ||
| import net.countercraft.movecraft.util.MathUtils; | ||
| import org.bukkit.block.Sign; | ||
| import org.bukkit.entity.Player; | ||
| import org.bukkit.event.block.Action; | ||
| import org.bukkit.event.block.SignChangeEvent; | ||
|
|
||
| import javax.annotation.Nonnull; | ||
| import javax.annotation.Nullable; | ||
| import java.util.Collections; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.Optional; | ||
|
|
||
| public abstract class AbstractMovecraftSign { | ||
|
|
||
| private static final Map<String, AbstractMovecraftSign> SIGNS = Collections.synchronizedMap(new HashMap<>()); | ||
|
|
||
| public static boolean hasBeenRegistered(final String ident) { | ||
| return SIGNS.containsKey(ident); | ||
| } | ||
|
|
||
| public static Optional<AbstractMovecraftSign> tryGet(final String ident) { | ||
| String identToUse = ident.toUpperCase(); | ||
| if (identToUse.indexOf(":") >= 0) { | ||
| identToUse = identToUse.split(":")[0]; | ||
| } | ||
| return Optional.ofNullable(SIGNS.getOrDefault(identToUse, null)); | ||
| } | ||
|
|
||
| public static void forceRegister(final String ident, final @Nonnull AbstractMovecraftSign instance) { | ||
| register(ident, instance, true); | ||
| } | ||
|
|
||
| public static void register(final String ident, final @Nonnull AbstractMovecraftSign instance, boolean allowOverride) { | ||
| if (allowOverride) { | ||
| SIGNS.put(ident.toUpperCase(), instance); | ||
| } else { | ||
| SIGNS.putIfAbsent(ident.toUpperCase(), instance); | ||
| } | ||
| } | ||
|
|
||
| protected final Optional<String> optPermission; | ||
|
DerToaster98 marked this conversation as resolved.
Outdated
|
||
|
|
||
| public AbstractMovecraftSign() { | ||
| this(null); | ||
| } | ||
|
|
||
| public AbstractMovecraftSign(String permissionNode) { | ||
| this.optPermission = Optional.ofNullable(permissionNode); | ||
| } | ||
|
|
||
| // Return true to cancel the event | ||
| public boolean processSignClick(Action clickType, Sign sign, Player player) { | ||
| if (!this.isSignValid(clickType, sign, player)) { | ||
| return false; | ||
| } | ||
| if (!this.canPlayerUseSign(clickType, sign, player)) { | ||
| return false; | ||
| } | ||
|
|
||
| return internalProcessSign(clickType, sign, player, getCraft(sign)); | ||
| } | ||
|
|
||
| protected boolean canPlayerUseSign(Action clickType, Sign sign, Player player) { | ||
| if (this.optPermission.isPresent()) { | ||
| return player.hasPermission(this.optPermission.get()); | ||
| } | ||
| return true; | ||
| } | ||
|
|
||
| protected Optional<Craft> getCraft(Sign sign) { | ||
| return Optional.ofNullable(MathUtils.getCraftByPersistentBlockData(sign.getLocation())); | ||
| } | ||
|
|
||
| public abstract boolean shouldCancelEvent(boolean processingSuccessful, @Nullable Action type, boolean sneaking); | ||
| protected abstract boolean isSignValid(Action clickType, Sign sign, Player player); | ||
| protected abstract boolean internalProcessSign(Action clickType, Sign sign, Player player, Optional<Craft> craft); | ||
| public abstract boolean processSignChange(SignChangeEvent event); | ||
|
|
||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.