Skip to content

Commit

Permalink
add support for 1.16 Crimson and Warped signs to sign command
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 10, 2020
1 parent dbcdae3 commit 302af55
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Expand Up @@ -42,7 +42,7 @@ public SignCommand() {
// Specify 'automatic' as a type to use whatever sign type and direction is already placed there.
// If there is not already a sign there, defaults to a sign_post.
//
// Optionally specify a material to use. If not specified, will use an oak sign.
// Optionally specify a material to use. If not specified, will use an oak sign (unless the block is already a sign, and 'type' is 'automatic').
//
// @Tags
// <LocationTag.sign_contents>
Expand All @@ -65,7 +65,6 @@ private enum Type {AUTOMATIC, SIGN_POST, WALL_SIGN}

@Override
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {

for (Argument arg : scriptEntry.getProcessedArgs()) {
if (!scriptEntry.hasObject("type")
&& arg.matchesEnum(Type.values())) {
Expand All @@ -91,14 +90,12 @@ else if (!scriptEntry.hasObject("text")) {
arg.reportUnhandled();
}
}

if (!scriptEntry.hasObject("location")) {
throw new InvalidArgumentsException("Must specify a Sign location!");
}
if (!scriptEntry.hasObject("text")) {
throw new InvalidArgumentsException("Must specify sign text!");
}

scriptEntry.defaultObject("type", new ElementTag(Type.AUTOMATIC.name()));
}

Expand All @@ -116,15 +113,13 @@ public void execute(final ScriptEntry scriptEntry) {
ListTag text = scriptEntry.getObjectTag("text");
LocationTag location = scriptEntry.getObjectTag("location");
MaterialTag material = scriptEntry.getObjectTag("material");

if (scriptEntry.dbCallShouldDebug()) {
Debug.report(scriptEntry, getName(), typeElement.debug()
+ location.debug()
+ (direction == null ? "" : ArgumentHelper.debugObj("direction", direction))
+ (material == null ? "" : material.debug())
+ text.debug());
}

Type type = Type.valueOf(typeElement.asString().toUpperCase());
Block sign = location.getBlock();
if (type != Type.AUTOMATIC
Expand Down Expand Up @@ -156,7 +151,6 @@ else if (!MaterialCompat.isAnySign(sign.getType())) {
}
}
BlockState signState = sign.getState();

Utilities.setSignLines((Sign) signState, text.toArray(new String[4]));
}
}
Expand Up @@ -22,6 +22,13 @@ public class MaterialCompat {
}

public static boolean isStandingSign(Material material) {
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_16)) {
switch (material) {
case CRIMSON_SIGN:
case WARPED_SIGN:
return true;
}
}
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_14)) {
switch (material) {
case ACACIA_SIGN:
Expand All @@ -39,6 +46,13 @@ public static boolean isStandingSign(Material material) {
}

public static boolean isWallSign(Material material) {
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_16)) {
switch (material) {
case CRIMSON_WALL_SIGN:
case WARPED_WALL_SIGN:
return true;
}
}
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_14)) {
switch (material) {
case ACACIA_WALL_SIGN:
Expand Down

0 comments on commit 302af55

Please sign in to comment.