-
-
Notifications
You must be signed in to change notification settings - Fork 46
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
Open
Jsinco
wants to merge
34
commits into
DenizenScript:master
Choose a base branch
from
BreweryTeam:master
base: master
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 16 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
b681351
working on it
Jsinco 7820362
working on it
Jsinco fceacdb
laptop push
Jsinco dadac47
should be ready for pull
Jsinco b89a1d8
Merge remote-tracking branch 'origin/master'
Jsinco 92b1f86
BreweryX support
Jsinco ab820b4
laptop push
Jsinco 09bc856
code fixes
Jsinco 3e3b437
rename classes
Jsinco 89399ef
add BreweryX dependency
Jsinco 477394b
add BreweryX dependency
Jsinco 1814caa
fix review issues
Jsinco 529119c
turn bplayer obj to extension
Jsinco 4c78d7f
Merge branch 'master' of https://github.com/Jsinco/Depenizen
Jsinco e1cfe5e
Merge branch 'master' of https://github.com/Jsinco/Depenizen
Jsinco 8d1993d
Merge branch 'master' of https://github.com/Jsinco/Depenizen
Jsinco 45d41d0
review changes
Jsinco 9862906
review changes
Jsinco cdaf64f
stray newline
Jsinco 68644f0
register tagProcessor with object init
Jsinco 827ed9b
Merge branch 'DenizenScript:master' into master
Jsinco 0e573d7
Merge branch 'DenizenScript:master' into master
Jsinco ba65850
Merge branch 'DenizenScript:master' into master
Jsinco 49b681d
Update BreweryX dependency, fix a couple of things after Aya's review.
Jsinco e96c8c4
fix identifier, get names based on quality. Add is_valid, has_glint, …
Jsinco 2e87411
remove double stray parenthesis
Jsinco 877bd48
Merge branch 'DenizenScript:master' into master
Jsinco 2dfb00a
change wood comment and include BreweryX in BukkitPlugins.md
Jsinco 740d367
Merge remote-tracking branch 'origin/master'
Jsinco a659be6
Merge branch 'DenizenScript:master' into master
Jsinco 9254240
change where BRecipeTag is created
Jsinco cf57064
oops, left an extra ';'
Jsinco ed22938
change comment on this event
Jsinco 5f92726
add type context comment to BrewModifyEvent
Jsinco 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 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
23 changes: 23 additions & 0 deletions
23
src/main/java/com/denizenscript/depenizen/bukkit/bridges/BreweryXBridge.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 com.denizenscript.depenizen.bukkit.bridges; | ||
|
||
import com.denizenscript.denizencore.events.ScriptEvent; | ||
import com.denizenscript.denizencore.objects.ObjectFetcher; | ||
import com.denizenscript.depenizen.bukkit.Bridge; | ||
import com.denizenscript.depenizen.bukkit.events.breweryx.BreweryChatDistortScriptEvent; | ||
import com.denizenscript.depenizen.bukkit.events.breweryx.BreweryDrinkScriptEvent; | ||
import com.denizenscript.depenizen.bukkit.events.breweryx.BreweryIngredientAddScriptEvent; | ||
import com.denizenscript.depenizen.bukkit.events.breweryx.BreweryModifyBrewScriptEvent; | ||
import com.denizenscript.depenizen.bukkit.objects.breweryx.BreweryRecipeTag; | ||
import com.denizenscript.depenizen.bukkit.properties.breweryx.BreweryPlayerExtensions; | ||
|
||
public class BreweryXBridge extends Bridge { | ||
@Override | ||
public void init() { | ||
ScriptEvent.registerScriptEvent(BreweryDrinkScriptEvent.class); | ||
ScriptEvent.registerScriptEvent(BreweryModifyBrewScriptEvent.class); | ||
ScriptEvent.registerScriptEvent(BreweryIngredientAddScriptEvent.class); | ||
ScriptEvent.registerScriptEvent(BreweryChatDistortScriptEvent.class); | ||
ObjectFetcher.registerWithObjectFetcher(BreweryRecipeTag.class); | ||
BreweryPlayerExtensions.register(); | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
...ava/com/denizenscript/depenizen/bukkit/events/breweryx/BreweryChatDistortScriptEvent.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,81 @@ | ||
package com.denizenscript.depenizen.bukkit.events.breweryx; | ||
|
||
import com.denizenscript.denizen.events.BukkitScriptEvent; | ||
import com.denizenscript.denizen.objects.PlayerTag; | ||
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData; | ||
import com.denizenscript.denizencore.objects.ObjectTag; | ||
import com.denizenscript.denizencore.objects.core.ElementTag; | ||
import com.denizenscript.denizencore.scripts.ScriptEntryData; | ||
import com.dre.brewery.api.events.PlayerChatDistortEvent; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
public class BreweryChatDistortScriptEvent extends BukkitScriptEvent implements Listener { | ||
|
||
|
||
// <--[event] | ||
// @Events | ||
// brewery chat distort | ||
// | ||
// @Cancellable true | ||
// | ||
// @Triggers when a drunk brewery player's chat is distorted. | ||
// | ||
// @Context | ||
// <context.message> Returns the message to be sent after being distorted. | ||
// <context.original_message> Returns the original message before being distorted. | ||
// <context.player> Returns a PlayerTag of the player that had their chat distorted. | ||
// | ||
// @Determine | ||
// ElementTag to set the message to be sent after being distorted. | ||
// | ||
// @Plugin Depenizen, BreweryX | ||
// | ||
// @Player Always. | ||
// | ||
// @Group Depenizen | ||
// | ||
// --> | ||
public BreweryChatDistortScriptEvent() { | ||
registerCouldMatcher("brewery chat distort"); | ||
} | ||
|
||
public PlayerChatDistortEvent event; | ||
public PlayerTag playerTag; | ||
|
||
@Override | ||
public boolean matches(ScriptPath path) { | ||
return super.matches(path); | ||
} | ||
|
||
@Override | ||
public ScriptEntryData getScriptEntryData() { | ||
return new BukkitScriptEntryData(event.getPlayer()); | ||
} | ||
|
||
@Override | ||
public ObjectTag getContext(String name) { | ||
return switch (name) { | ||
case "message" -> new ElementTag(event.getDistortedMessage()); | ||
case "original_message" -> new ElementTag(event.getWrittenMessage()); | ||
case "player" -> playerTag; | ||
default -> super.getContext(name); | ||
}; | ||
} | ||
|
||
@Override | ||
public boolean handleDetermination(ScriptPath path, String prefix, ObjectTag value) { | ||
if (prefix.equals("message")) { | ||
event.setDistortedMessage(value.asElement().asString()); | ||
return true; | ||
} | ||
return super.handleDetermination(path, prefix, value); | ||
} | ||
|
||
@EventHandler | ||
public void onChatDistort(PlayerChatDistortEvent event) { | ||
this.event = event; | ||
this.playerTag = new PlayerTag(event.getPlayer()); | ||
fire(event); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
...main/java/com/denizenscript/depenizen/bukkit/events/breweryx/BreweryDrinkScriptEvent.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,70 @@ | ||
package com.denizenscript.depenizen.bukkit.events.breweryx; | ||
|
||
|
||
import com.denizenscript.denizen.events.BukkitScriptEvent; | ||
import com.denizenscript.denizen.objects.ItemTag; | ||
import com.denizenscript.denizen.objects.PlayerTag; | ||
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData; | ||
import com.denizenscript.denizencore.objects.ObjectTag; | ||
import com.denizenscript.denizencore.scripts.ScriptEntryData; | ||
import com.denizenscript.depenizen.bukkit.objects.breweryx.BreweryRecipeTag; | ||
import com.dre.brewery.api.events.brew.BrewDrinkEvent; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
public class BreweryDrinkScriptEvent extends BukkitScriptEvent implements Listener { | ||
|
||
// <--[event] | ||
// @Events | ||
// brewery drink | ||
// | ||
// @Cancellable true | ||
// | ||
// @Triggers when a player drinks a potion that is considered a BreweryX potion. | ||
// | ||
// @Context | ||
// <context.item> Returns an ItemTag of the potion that was drunk. | ||
// <context.recipe> Returns an BRecipeTag of the recipe that the brew is based off of. | ||
// <context.player> Returns a PlayerTag of the player that drank the brew. | ||
// | ||
// @Plugin Depenizen, BreweryX | ||
// | ||
// @Player Always. | ||
// | ||
// @Group Depenizen | ||
// | ||
// --> | ||
public BreweryDrinkScriptEvent() { | ||
registerCouldMatcher("brewery drink"); | ||
} | ||
|
||
public BrewDrinkEvent event; | ||
public BreweryRecipeTag recipeTag; | ||
|
||
@Override | ||
public boolean matches(ScriptPath path) { | ||
return super.matches(path); | ||
} | ||
|
||
@Override | ||
public ScriptEntryData getScriptEntryData() { | ||
return new BukkitScriptEntryData(event.getPlayer()); | ||
} | ||
|
||
@Override | ||
public ObjectTag getContext(String name) { | ||
return switch (name) { | ||
case "recipe" -> recipeTag; | ||
case "item" -> new ItemTag(event.getBrew().createItem(event.getBrew().getCurrentRecipe())); | ||
case "player" -> new PlayerTag(event.getPlayer()); | ||
default -> super.getContext(name); | ||
}; | ||
} | ||
|
||
@EventHandler | ||
public void onBrewDrinkEvent(BrewDrinkEvent event) { | ||
this.event = event; | ||
this.recipeTag = new BreweryRecipeTag(event.getBrew().getCurrentRecipe()); | ||
fire(event); | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
...a/com/denizenscript/depenizen/bukkit/events/breweryx/BreweryIngredientAddScriptEvent.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,89 @@ | ||
package com.denizenscript.depenizen.bukkit.events.breweryx; | ||
|
||
import com.denizenscript.denizen.events.BukkitScriptEvent; | ||
import com.denizenscript.denizen.objects.ItemTag; | ||
import com.denizenscript.denizen.objects.LocationTag; | ||
import com.denizenscript.denizen.objects.PlayerTag; | ||
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData; | ||
import com.denizenscript.denizencore.objects.ObjectTag; | ||
import com.denizenscript.denizencore.objects.core.ElementTag; | ||
import com.denizenscript.denizencore.scripts.ScriptEntryData; | ||
import com.dre.brewery.api.events.IngedientAddEvent; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
public class BreweryIngredientAddScriptEvent extends BukkitScriptEvent implements Listener { | ||
|
||
// <--[event] | ||
// @Events | ||
// brewery ingredient add | ||
// | ||
// @Cancellable true | ||
// | ||
// @Triggers when a player adds an ingredient to a cauldron. | ||
// | ||
// @Context | ||
// <context.item> Returns an ItemTag of the ingredient that was added. | ||
// <context.location> Returns a LocationTag of the cauldron. | ||
// <context.player> Returns a PlayerTag of the player that added the ingredient. | ||
// <context.take_item> Returns an ElementTag of whether the item should be taken from the player. | ||
// | ||
// @Determine | ||
// ItemTag to set the ingredient that was added. | ||
// ElementTag(Boolean) to set whether the item should be taken from the player. | ||
// | ||
// @Plugin Depenizen, BreweryX | ||
// | ||
// @Player Always. | ||
// | ||
// @Group Depenizen | ||
// | ||
// --> | ||
public BreweryIngredientAddScriptEvent() { | ||
registerCouldMatcher("brewery ingredient add"); | ||
} | ||
|
||
public IngedientAddEvent event; | ||
|
||
@Override | ||
public boolean matches(ScriptPath path) { | ||
return super.matches(path); | ||
} | ||
|
||
@Override | ||
public ScriptEntryData getScriptEntryData() { | ||
return new BukkitScriptEntryData(event.getPlayer()); | ||
} | ||
|
||
@Override | ||
public ObjectTag getContext(String name) { | ||
return switch (name) { | ||
case "location" -> new LocationTag(event.getBlock().getLocation()); | ||
case "player" -> new PlayerTag(event.getPlayer()); | ||
case "item" -> new ItemTag(event.getIngredient()); | ||
case "take_item" -> new ElementTag(event.willTakeItem()); | ||
default -> super.getContext(name); | ||
}; | ||
} | ||
|
||
@Override | ||
public boolean handleDetermination(ScriptPath path, String prefix, ObjectTag value) { | ||
switch (prefix) { | ||
case "item" -> { | ||
event.setIngredient(((ItemTag) value).getItemStack()); | ||
return true; | ||
} | ||
case "take_item" -> { | ||
event.setTakeItem(((ElementTag) value).asBoolean()); | ||
return true; | ||
} | ||
} | ||
return super.handleDetermination(path, prefix, value); | ||
} | ||
|
||
@EventHandler | ||
public void onIngredientAddEvent(IngedientAddEvent event) { | ||
this.event = event; | ||
fire(event); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
...java/com/denizenscript/depenizen/bukkit/events/breweryx/BreweryModifyBrewScriptEvent.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,71 @@ | ||
package com.denizenscript.depenizen.bukkit.events.breweryx; | ||
|
||
import com.denizenscript.denizen.events.BukkitScriptEvent; | ||
import com.denizenscript.denizen.objects.ItemTag; | ||
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData; | ||
import com.denizenscript.denizencore.objects.ObjectTag; | ||
import com.denizenscript.denizencore.objects.core.ElementTag; | ||
import com.denizenscript.denizencore.scripts.ScriptEntryData; | ||
import com.denizenscript.depenizen.bukkit.objects.breweryx.BreweryRecipeTag; | ||
import com.dre.brewery.api.events.brew.BrewModifyEvent; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
public class BreweryModifyBrewScriptEvent extends BukkitScriptEvent implements Listener { | ||
|
||
// <--[event] | ||
// @Events | ||
// brewery brew modify | ||
// | ||
// @Cancellable true | ||
// | ||
// @Triggers When a Brew has been created or modified. | ||
// Usually happens on filling from cauldron, distilling and aging. | ||
// Modifications to the Brew or the PotionMeta can be done now | ||
// Cancelling reverts the Brew to the state it was before the modification | ||
// | ||
// @Context | ||
// <context.item> Returns an ItemTag of the potion that was drunk. | ||
// <context.recipe> Returns an BRecipeTag of the recipe that the brew is based off of. | ||
// | ||
// @Plugin Depenizen, BreweryX | ||
// | ||
// @Group Depenizen | ||
// | ||
// --> | ||
public BreweryModifyBrewScriptEvent() { | ||
registerCouldMatcher("brewery brew modify"); | ||
} | ||
|
||
public BrewModifyEvent event; | ||
public BreweryRecipeTag recipeTag; | ||
public String type; | ||
|
||
@Override | ||
public boolean matches(ScriptPath path) { | ||
return super.matches(path); | ||
} | ||
|
||
@Override | ||
public ScriptEntryData getScriptEntryData() { | ||
return new BukkitScriptEntryData(null, null); | ||
} | ||
|
||
@Override | ||
public ObjectTag getContext(String name) { | ||
return switch (name) { | ||
case "recipe" -> recipeTag; | ||
case "type" -> new ElementTag(type); | ||
case "item" -> new ItemTag(event.getBrew().createItem(event.getBrew().getCurrentRecipe())); | ||
default -> super.getContext(name); | ||
}; | ||
} | ||
|
||
@EventHandler | ||
public void onBrewModifyEvent(BrewModifyEvent event) { | ||
this.event = event; | ||
this.recipeTag = new BreweryRecipeTag(event.getBrew().getCurrentRecipe()); | ||
this.type = event.getType().name(); | ||
fire(event); | ||
} | ||
} |
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.
stray double newline