-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
BreweryX (v3.3.6+) Support #430
base: master
Are you sure you want to change the base?
Conversation
|
||
@Override | ||
public boolean couldMatch(ScriptPath path) { | ||
return path.eventLower.startsWith("brewery chat distort"); |
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 is the legacy scriptevent format, please check the code in Denizen-Core, Denizen, or dDiscordBot for modern examples
|
||
@Override | ||
public ScriptEntryData getScriptEntryData() { | ||
return new BukkitScriptEntryData(new PlayerTag(event.getPlayer()), null); |
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 should just be new BukkitScriptEntryData(event.getPlayer()
iirc
|
||
@Override | ||
public boolean handleDetermination(ScriptPath path, String prefix, ObjectTag value) { | ||
if (prefix.equals("message") && value instanceof ElementTag elementTag) { |
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.
the ElementTag cast is redundant
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.
Sorry, I didn't understand this one.
if (prefix.equals("message") && value instanceof ElementTag elementTag) { // FIXME - Cast redundant but .toString() returns class and hash?
import org.bukkit.entity.Player; | ||
|
||
// TODO: OfflinePlayer support | ||
public class BPlayerTag implements ObjectTag { |
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 whole object doesn't make sense -- this should just be an extension of PlayerTag
also identifying players by name hasn't been permissible in Minecraft in around 10 years now, since Minecraft 1.7.6 added UUIDs
public class BRecipeTag implements ObjectTag { | ||
|
||
// <--[ObjectType] | ||
// @name BRecipeTag |
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.
should use the full BreweryRecipeTag
// @description | ||
// Returns the ID of the recipe as specified in the config. | ||
// --> | ||
if (attribute.startsWith("id")) { |
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 is the legacy tag system, again look at modern code or DenizenScript/Denizen#2355 or https://guide.denizenscript.com/guides/contributing/property-dev.html
I fixed a bunch of the commented issues. Not sure if I got everything 100% but just let me know what needs to be fixed and I'll get on it! |
// <context.player> Returns a PlayerTag of the player that had their chat distorted. | ||
// | ||
// @Determine | ||
// ElementTag(String) to set the message to be sent after being distorted. |
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.
ElementTag(String)
doesn't exist, it's just ElementTag
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Player; | ||
|
||
public class BreweryPlayerTag implements ObjectTag { |
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.
As noted before this object doesn't make sense, it should just be an extension
tagProcessor.registerTag(ElementTag.class, "id", (attribute, object) -> { | ||
/* | ||
This being optional was infrastructure added by the original authors and is not used | ||
in Brewery. It will be deprecated and replaced soon. |
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 comment should just be a //
comment not the weird line break multiline comment thing
|
||
@Override | ||
public boolean handleDetermination(ScriptPath path, String prefix, ObjectTag value) { | ||
if (prefix.equals("message") && value instanceof ElementTag elementTag) { // FIXME - Cast redundant but .toString() returns class and hash? |
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.
... what?
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.
I think I might just be confused here. If I don't cast the ObjectTag to an ElementTag I can't do value.asString(). When you told me the cast was redundant I assumed you meant I could just do ObjectTag#toString(). Just looked again and I'm guessing you wanted me to do value.asElement().asString()
?
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.
I'm confused why you think toString doesn't work but yes asElement().asString() is the most proper option
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.
Going to the declaration of value.toString() brought me to the Object.java class which is why I why I figured it wouldn't work. Sorry about that
pom.xml
Outdated
@@ -39,6 +39,10 @@ | |||
<enabled>true</enabled> | |||
</snapshots> | |||
</repository> | |||
<repository> | |||
<id>spigot-repo</id> |
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 shouldn't be here
public class BreweryRecipeTag implements ObjectTag { | ||
|
||
// <--[ObjectType] | ||
// @name BRecipeTag |
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.
the name is still wrong here
// @returns ElementTag(Number) | ||
// @plugin Depenizen, BreweryX | ||
// @description | ||
// Returns the distill runs of the recipe |
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.
.
at end
// Returns the cooking time of the recipe. | ||
// --> | ||
tagProcessor.registerTag(ElementTag.class, "cooking_time", (attribute, object) -> { | ||
return new ElementTag(object.bRecipe.getCookingTime()); |
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.
sounds like it should probably be a DurationTag
?
src/main/java/com/denizenscript/depenizen/bukkit/objects/breweryx/BreweryRecipeTag.java
Show resolved
Hide resolved
// @returns ElementTag(Number) | ||
// @plugin Depenizen, BreweryX | ||
// @description | ||
// Returns the amount of alcohol in a perfect potion. |
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.
What unit is this? Item stacks of an alcohol item, percentage, decimal, ...?
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.
"alcohol: Absolute amount of alcohol 0-100 in a perfect potion (will be added directly to the player, where 100 means fainting)"
Just returns the int written in Brewery's config for the specific recipe. I'll add that longer description to the comment
|
||
// <--[tag] | ||
// @attribute <BRecipeTag.effects> | ||
// @returns ListTag(ElementTag) |
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.
if it's a list of element just write ListTag
Fixed the new issues |
|
||
public class BreweryChatDistortScriptEvent extends BukkitScriptEvent implements Listener { | ||
|
||
|
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.
stray double newline
|
||
// <--[ObjectType] | ||
// @name BreweryRecipeTag | ||
// @prefix brecipe |
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.
the prefix is still wrong
public static void register() { | ||
|
||
// <--[tag] | ||
// @attribute <BRecipeTag.id> |
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.
name in meta is still wrong
tagProcessor.registerTag(ElementTag.class, "id", (attribute, object) -> { | ||
|
||
// This being optional was infrastructure added by the original authors and is not used | ||
// in Brewery. It will be deprecated and replaced soon. |
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 still shouldn't have all the stray newlines here
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 still has a stray newline in the middle of it
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.
removed
|
||
// <--[tag] | ||
// @attribute <BRecipeTag.cooking_time> | ||
// @returns ElementTag(Number) |
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.
return type here is outdated
// @returns ElementTag(Number) | ||
// @plugin Depenizen, BreweryX | ||
// @description | ||
// Returns the absolute amount of alcohol 0-100 in a perfect potion (will be added directly to the player, where 100 means fainting) |
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.
.
at end
|
||
public static void register() { | ||
// <--[tag] | ||
// @attribute <BPlayerTag.drunkenness> |
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 labeling is wrong
// @description | ||
// Returns the drunkness of the brewery player. | ||
// --> | ||
PlayerTag.tagProcessor.registerTag(ElementTag.class, "drunkenness", (attribute, object) -> { |
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.
format the tags like brewery_drunkenness
// Returns the drunkness of the brewery player. | ||
// --> | ||
PlayerTag.tagProcessor.registerTag(ElementTag.class, "drunkenness", (attribute, object) -> { | ||
BPlayer bPlayer = BPlayer.hasPlayer(object.getPlayerEntity()) ? BPlayer.get(object.getPlayerEntity()) : null; |
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.
If this can null out, that should be explain in the tag meta. If this shouldn't have in practice, shouldn't have all the redundant checks
// @description | ||
// Returns the quality of the brewery player's drunkenness (drunkeness * drunkeness). | ||
// --> | ||
PlayerTag.tagProcessor.registerTag(ElementTag.class, "quality", (attribute, object) -> { |
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.
should use registerOnlineOnlyTag if it requires online players
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.
Doesn't require them to be online, just for Brewery to have data about them
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.
then use getOfflinePlayer
not playerEntity
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.
fixed
Changed |
Please approve this, i need Depenizen x BreweryX ASAP! |
Been a bit. Any updates on this? |
Many many months ago in the Denizen Discord, I wanted to figure out how to start the execution of a script from another plugin so I could include Denizen support in BreweryX. After the discussion I decided to implement BreweryX into Depenizen instead. Everything should be compatible starting with release 3.2.0 of BreweryX (which I plan to release soon after this pull request). Hopefully there isn't much I need to change here, I'm a first-time contributer but I did my best to follow the style of other plugin bridges.
BreweryX Github: https://github.com/Jsinco/BreweryX
Spigot page: https://www.spigotmc.org/resources/breweryx.114777/