-
-
Notifications
You must be signed in to change notification settings - Fork 109
MaterialTag.sides,snowable,switchable Property Modernization #2661
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
Closed
Closed
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5f37814
Modernized sides property
heypr 11160f8
Modernized snowable property
heypr 9efca28
Modernized switchable property
heypr 212ef0e
Minor changes
heypr 86de447
Minor update
heypr d861eaa
Moved methods around
heypr 658d6c6
Update MaterialSwitchable.java
heypr bd78259
Merge remote-tracking branch 'upstream/dev' into modernization-2
heypr 4949eb5
Merge remote-tracking branch 'upstream/dev' into modernization-2
heypr 37552ea
switchable
heypr 044fb0e
Updated state method + added instanceof checks + updated switch command
heypr 8241e7a
Merge remote-tracking branch 'upstream/dev' into modernization-2
heypr fbc4020
Added describes check back, corrected snowable + sides
heypr 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
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
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 |
---|---|---|
|
@@ -2,52 +2,46 @@ | |
|
||
import com.denizenscript.denizen.objects.MaterialTag; | ||
import com.denizenscript.denizencore.objects.Mechanism; | ||
import com.denizenscript.denizencore.objects.ObjectTag; | ||
import com.denizenscript.denizencore.objects.core.ElementTag; | ||
import com.denizenscript.denizencore.objects.properties.Property; | ||
import com.denizenscript.denizencore.objects.properties.PropertyParser; | ||
import org.bukkit.block.data.BlockData; | ||
import org.bukkit.block.data.Snowable; | ||
|
||
public class MaterialSnowable implements Property { | ||
public class MaterialSnowable extends MaterialProperty<ElementTag> { | ||
|
||
public static boolean describes(ObjectTag material) { | ||
return material instanceof MaterialTag | ||
&& ((MaterialTag) material).hasModernData() | ||
&& ((MaterialTag) material).getModernData() instanceof Snowable; | ||
} | ||
// <--[tag] | ||
// @object MaterialTag | ||
// @name snowy | ||
// @input ElementTag(Boolean) | ||
// @description | ||
// Controls whether this material is covered in snow. | ||
// --> | ||
|
||
public static MaterialSnowable getFrom(ObjectTag _material) { | ||
if (!describes(_material)) { | ||
return null; | ||
} | ||
else { | ||
return new MaterialSnowable((MaterialTag) _material); | ||
} | ||
public static boolean describes(MaterialTag material) { | ||
BlockData data = material.getModernData(); | ||
return data instanceof Snowable; | ||
} | ||
|
||
public static final String[] handledMechs = new String[] { | ||
"snowy" | ||
}; | ||
MaterialTag material; | ||
|
||
|
||
public MaterialSnowable(MaterialTag _material) { | ||
material = _material; | ||
@Override | ||
public ElementTag getPropertyValue() { | ||
return new ElementTag(isSnowy()); | ||
} | ||
|
||
MaterialTag material; | ||
@Override | ||
public String getPropertyId() { | ||
return "snowy"; | ||
} | ||
|
||
public static void register() { | ||
@Override | ||
public void setPropertyValue(ElementTag value, Mechanism mechanism) { | ||
if (mechanism.requireBoolean()) { | ||
getSnowable().setSnowy(value.asBoolean()); | ||
} | ||
} | ||
|
||
// <--[tag] | ||
// @attribute <MaterialTag.snowy> | ||
// @returns ElementTag(Boolean) | ||
// @mechanism MaterialTag.snowy | ||
// @group properties | ||
// @description | ||
// Returns whether this material is covered in snow or not. | ||
// --> | ||
PropertyParser.registerStaticTag(MaterialSnowable.class, ElementTag.class, "snowy", (attribute, material) -> { | ||
return new ElementTag(material.isSnowy()); | ||
}); | ||
public static void register() { | ||
autoRegister("snowy", MaterialSnowable.class, ElementTag.class, true); | ||
} | ||
|
||
public Snowable getSnowable() { | ||
|
@@ -57,31 +51,4 @@ public Snowable getSnowable() { | |
public boolean isSnowy() { | ||
return getSnowable().isSnowy(); | ||
} | ||
|
||
@Override | ||
public String getPropertyString() { | ||
return String.valueOf(isSnowy()); | ||
} | ||
|
||
@Override | ||
public String getPropertyId() { | ||
return "snowy"; | ||
} | ||
|
||
@Override | ||
public void adjust(Mechanism mechanism) { | ||
|
||
// <--[mechanism] | ||
// @object MaterialTag | ||
// @name snowy | ||
// @input ElementTag(Boolean) | ||
// @description | ||
// Sets this material to be covered in snow, or not. | ||
// @tags | ||
// <MaterialTag.snowy> | ||
// --> | ||
if (mechanism.matches("snowy") && mechanism.requireBoolean()) { | ||
getSnowable().setSnowy(mechanism.getValue().asBoolean()); | ||
} | ||
} | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this deprecated mech meta is free-floating in a random spot, and the mech isn't registered?