forked from PseudoKnight/Stargate-Bukkit
-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce LineData instead of SignLine before formatting
- Loading branch information
1 parent
67f4895
commit 23fec8b
Showing
38 changed files
with
502 additions
and
348 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
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
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
11 changes: 11 additions & 0 deletions
11
src/main/java/org/sgrewritten/stargate/api/network/portal/PortalPositionAttachment.java
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,11 @@ | ||
package org.sgrewritten.stargate.api.network.portal; | ||
|
||
public interface PortalPositionAttachment { | ||
|
||
|
||
Type getType(); | ||
|
||
enum Type { | ||
LINE_FORMATTER | ||
} | ||
} |
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
4 changes: 1 addition & 3 deletions
4
...twork/portal/format/AbstractSignLine.java → ...k/portal/formatting/AbstractSignLine.java
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
29 changes: 29 additions & 0 deletions
29
src/main/java/org/sgrewritten/stargate/api/network/portal/formatting/LineFormatter.java
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 org.sgrewritten.stargate.api.network.portal.formatting; | ||
|
||
import org.sgrewritten.stargate.api.network.portal.PortalPositionAttachment; | ||
import org.sgrewritten.stargate.api.network.portal.formatting.data.LineData; | ||
|
||
/** | ||
* A formatter for formatting a line on a sign | ||
*/ | ||
public interface LineFormatter extends PortalPositionAttachment { | ||
|
||
/** | ||
* @param lineData <p>The line data to format</p> | ||
* @return <p>Formatted sign lines</p> | ||
*/ | ||
default SignLine[] formatLineData(LineData[] lineData){ | ||
SignLine[] output = new SignLine[lineData.length]; | ||
for (int i = 0; i < lineData.length; i++) { | ||
output[i] = convertToSignLine(lineData[i]); | ||
} | ||
return output; | ||
} | ||
|
||
SignLine convertToSignLine(LineData lineData); | ||
|
||
@Override | ||
default Type getType() { | ||
return Type.LINE_FORMATTER; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...pi/network/portal/format/NetworkLine.java → ...etwork/portal/formatting/NetworkLine.java
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
2 changes: 1 addition & 1 deletion
2
...api/network/portal/format/PortalLine.java → ...network/portal/formatting/PortalLine.java
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
2 changes: 1 addition & 1 deletion
2
...e/api/network/portal/format/SignLine.java → ...i/network/portal/formatting/SignLine.java
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
2 changes: 1 addition & 1 deletion
2
...i/network/portal/format/SignLineType.java → ...twork/portal/formatting/SignLineType.java
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
4 changes: 1 addition & 3 deletions
4
...work/portal/format/StargateComponent.java → .../portal/formatting/StargateComponent.java
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
2 changes: 1 addition & 1 deletion
2
...format/StargateComponentDeserialiser.java → ...atting/StargateComponentDeserialiser.java
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
2 changes: 1 addition & 1 deletion
2
...e/api/network/portal/format/TextLine.java → ...i/network/portal/formatting/TextLine.java
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
23 changes: 23 additions & 0 deletions
23
src/main/java/org/sgrewritten/stargate/api/network/portal/formatting/data/LineData.java
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,23 @@ | ||
package org.sgrewritten.stargate.api.network.portal.formatting.data; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.sgrewritten.stargate.api.network.portal.formatting.LineFormatter; | ||
import org.sgrewritten.stargate.api.network.portal.formatting.SignLineType; | ||
|
||
/** | ||
* Used as input arguments for {@link LineFormatter} | ||
*/ | ||
public interface LineData{ | ||
|
||
/** | ||
* @return <p>The line type of this line data</p> | ||
*/ | ||
@NotNull SignLineType getType(); | ||
|
||
/** | ||
* | ||
* @return <p>The unformatted text for this line data</p> | ||
*/ | ||
@NotNull String getText(); | ||
} |
30 changes: 30 additions & 0 deletions
30
...ain/java/org/sgrewritten/stargate/api/network/portal/formatting/data/NetworkLineData.java
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,30 @@ | ||
package org.sgrewritten.stargate.api.network.portal.formatting.data; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.sgrewritten.stargate.api.network.Network; | ||
import org.sgrewritten.stargate.api.network.portal.formatting.SignLineType; | ||
|
||
import java.util.Objects; | ||
|
||
public class NetworkLineData implements LineData { | ||
|
||
private final Network network; | ||
|
||
public NetworkLineData(@NotNull Network network) { | ||
this.network = Objects.requireNonNull(network); | ||
} | ||
|
||
public @NotNull Network getNetwork() { | ||
return network; | ||
} | ||
|
||
@Override | ||
public @NotNull SignLineType getType() { | ||
return SignLineType.NETWORK; | ||
} | ||
|
||
@Override | ||
public @NotNull String getText() { | ||
return network.getName(); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...main/java/org/sgrewritten/stargate/api/network/portal/formatting/data/PortalLineData.java
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,40 @@ | ||
package org.sgrewritten.stargate.api.network.portal.formatting.data; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.sgrewritten.stargate.api.network.portal.Portal; | ||
import org.sgrewritten.stargate.api.network.portal.formatting.SignLineType; | ||
|
||
import java.util.Objects; | ||
|
||
public class PortalLineData implements LineData { | ||
|
||
private Portal portal; | ||
private final SignLineType portalType; | ||
private final String portalName; | ||
|
||
public PortalLineData(@NotNull Portal portal, SignLineType portalType){ | ||
this.portal = Objects.requireNonNull(portal); | ||
this.portalName = portal.getName(); | ||
this.portalType = Objects.requireNonNull(portalType); | ||
} | ||
|
||
public PortalLineData(@NotNull String portalName, SignLineType portalType){ | ||
this.portalName = Objects.requireNonNull(portalName); | ||
this.portalType = Objects.requireNonNull(portalType); | ||
} | ||
|
||
public @Nullable Portal getPortal() { | ||
return this.portal; | ||
} | ||
|
||
@Override | ||
public @NotNull SignLineType getType() { | ||
return portalType; | ||
} | ||
|
||
@Override | ||
public @NotNull String getText() { | ||
return portalName; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/org/sgrewritten/stargate/api/network/portal/formatting/data/TextLineData.java
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,43 @@ | ||
package org.sgrewritten.stargate.api.network.portal.formatting.data; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.sgrewritten.stargate.api.network.portal.formatting.SignLineType; | ||
import org.sgrewritten.stargate.network.portal.formatting.HighlightingStyle; | ||
|
||
public class TextLineData implements LineData { | ||
|
||
private final String text; | ||
private final SignLineType type; | ||
private HighlightingStyle highlightingStyle = null; | ||
|
||
public TextLineData(){ | ||
this.text = ""; | ||
this.type = SignLineType.TEXT; | ||
} | ||
|
||
public TextLineData(String text, SignLineType type){ | ||
this.text = text; | ||
this.type = type; | ||
} | ||
|
||
public TextLineData(String text, HighlightingStyle highlightingStyle) { | ||
this.text = text; | ||
this.type = SignLineType.TEXT; | ||
this.highlightingStyle = highlightingStyle; | ||
} | ||
|
||
@Override | ||
public @NotNull SignLineType getType() { | ||
return this.type; | ||
} | ||
|
||
@Override | ||
public @NotNull String getText() { | ||
return this.text; | ||
} | ||
|
||
public @Nullable HighlightingStyle getHighlightingStyle(){ | ||
return this.highlightingStyle; | ||
} | ||
} |
Oops, something went wrong.