Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7eaed46
commit 3e2ae82
Showing
6 changed files
with
567 additions
and
0 deletions.
There are no files selected for viewing
125 changes: 125 additions & 0 deletions
125
.../gnomeffinway/depenizen/events/ASkyBlock/PlayerCompletesSkyBlockChallengeScriptEvent.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,125 @@ | ||
package net.gnomeffinway.depenizen.events.ASkyBlock; | ||
|
||
import com.wasteofplastic.askyblock.events.ChallengeCompleteEvent; | ||
import net.aufdemrand.denizen.BukkitScriptEntryData; | ||
import net.aufdemrand.denizen.events.BukkitScriptEvent; | ||
import net.aufdemrand.denizen.objects.dEntity; | ||
import net.aufdemrand.denizen.objects.dItem; | ||
import net.aufdemrand.denizen.objects.dPlayer; | ||
import net.aufdemrand.denizen.utilities.DenizenAPI; | ||
import net.aufdemrand.denizencore.objects.Element; | ||
import net.aufdemrand.denizencore.objects.dList; | ||
import net.aufdemrand.denizencore.objects.dObject; | ||
import net.aufdemrand.denizencore.scripts.ScriptEntryData; | ||
import net.aufdemrand.denizencore.scripts.containers.ScriptContainer; | ||
import net.aufdemrand.denizencore.utilities.CoreUtilities; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
// <--[event] | ||
// @Events | ||
// player completes skyblock challenge | ||
// | ||
// @Regex ^on player completes skyblock challenge$ | ||
// | ||
// @Cancellable false | ||
// | ||
// @Triggers when a player completes a skyblock challenge. | ||
// | ||
// @Context | ||
// <context.challenge> Returns the name of the challenge. | ||
// <context.xp_reward> Return the amount of experience to be rewarded. | ||
// <context.money_reward> Returns the amount of money to be rewarded. | ||
// <context.item_rewards> Returns a list of items to be awarded. | ||
// NOTE: item rewards is dependant on how the plugin handles item rewards. Untested and no guarantee of working. | ||
// | ||
// @Plugin Depenizen, A SkyBlock | ||
// | ||
// --> | ||
|
||
public class PlayerCompletesSkyBlockChallengeScriptEvent extends BukkitScriptEvent implements Listener { | ||
|
||
public PlayerCompletesSkyBlockChallengeScriptEvent instance; | ||
public ChallengeCompleteEvent event; | ||
public Element challenge; | ||
public Element xp_reward; | ||
public Element money_reward; | ||
public dList item_rewards; | ||
|
||
public PlayerCompletesSkyBlockChallengeScriptEvent() { | ||
instance = this; | ||
} | ||
|
||
@Override | ||
public boolean couldMatch(ScriptContainer scriptContainer, String s) { | ||
return CoreUtilities.toLowerCase(s).startsWith("player completes skyblock challenge"); | ||
} | ||
|
||
@Override | ||
public boolean matches(ScriptContainer scriptContainer, String s) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "PlayerCompletesSkyBlockChallenge"; | ||
} | ||
|
||
@Override | ||
public void init() { | ||
Bukkit.getServer().getPluginManager().registerEvents(this, DenizenAPI.getCurrentInstance()); | ||
} | ||
|
||
@Override | ||
public void destroy() { | ||
ChallengeCompleteEvent.getHandlerList().unregister(this); | ||
} | ||
|
||
@Override | ||
public boolean applyDetermination(ScriptContainer container, String determination) { | ||
return super.applyDetermination(container, determination); | ||
} | ||
|
||
@Override | ||
public ScriptEntryData getScriptEntryData() { | ||
return new BukkitScriptEntryData(new dPlayer(event.getPlayer()), null); | ||
} | ||
|
||
@Override | ||
public dObject getContext(String name) { | ||
if (name.equals("challenge")) { | ||
return challenge; | ||
} | ||
else if (name.equals("xp_reward")) { | ||
return xp_reward; | ||
} | ||
else if (name.equals("money_reward")) { | ||
return money_reward; | ||
} | ||
else if (name.equals("item_rewards")) { | ||
return item_rewards; | ||
} | ||
return super.getContext(name); | ||
} | ||
|
||
@EventHandler | ||
public void onPlayerCompletesSkyBlockChallenge(ChallengeCompleteEvent event) { | ||
if (dEntity.isNPC(event.getPlayer())) { | ||
return; | ||
} | ||
challenge = new Element(event.getChallengeName()); | ||
xp_reward = new Element(event.getExpReward()); | ||
money_reward = new Element(event.getMoneyReward()); | ||
item_rewards = new dList(); | ||
for (String i : event.getItemRewards()) { | ||
dItem item = dItem.valueOf(i); | ||
if (item != null) { | ||
item_rewards.add(item.identify()); | ||
} | ||
} | ||
this.event = event; | ||
fire(); | ||
} | ||
|
||
} |
109 changes: 109 additions & 0 deletions
109
...ain/java/net/gnomeffinway/depenizen/events/ASkyBlock/PlayerEntersSkyBlockScriptEvent.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,109 @@ | ||
package net.gnomeffinway.depenizen.events.ASkyBlock; | ||
|
||
import com.wasteofplastic.askyblock.events.IslandEnterEvent; | ||
import net.aufdemrand.denizen.BukkitScriptEntryData; | ||
import net.aufdemrand.denizen.events.BukkitScriptEvent; | ||
import net.aufdemrand.denizen.objects.dEntity; | ||
import net.aufdemrand.denizen.objects.dLocation; | ||
import net.aufdemrand.denizen.objects.dPlayer; | ||
import net.aufdemrand.denizen.utilities.DenizenAPI; | ||
import net.aufdemrand.denizencore.objects.dObject; | ||
import net.aufdemrand.denizencore.scripts.ScriptEntryData; | ||
import net.aufdemrand.denizencore.scripts.containers.ScriptContainer; | ||
import net.aufdemrand.denizencore.utilities.CoreUtilities; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
// <--[event] | ||
// @Events | ||
// player enters skyblock | ||
// | ||
// @Regex ^on player enters skyblock$ | ||
// | ||
// @Cancellable false | ||
// | ||
// @Triggers when a player goes to a skyblock island. | ||
// | ||
// @Context | ||
// <context.owner> Returns the owner of the island. | ||
// <context.island_location> Returns the location of the island. | ||
// <context.location> Returns the location the player entered at. | ||
// | ||
// @Plugin Depenizen, A SkyBlock | ||
// | ||
// --> | ||
|
||
public class PlayerEntersSkyBlockScriptEvent extends BukkitScriptEvent implements Listener { | ||
|
||
public PlayerEntersSkyBlockScriptEvent instance; | ||
public IslandEnterEvent event; | ||
public dLocation location; | ||
public dLocation island_location; | ||
public dPlayer owner; | ||
|
||
public PlayerEntersSkyBlockScriptEvent() { | ||
instance = this; | ||
} | ||
|
||
@Override | ||
public boolean couldMatch(ScriptContainer scriptContainer, String s) { | ||
return CoreUtilities.toLowerCase(s).startsWith("player enters skyblock"); | ||
} | ||
|
||
@Override | ||
public boolean matches(ScriptContainer scriptContainer, String s) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "PlayerEntersSkyBlock"; | ||
} | ||
|
||
@Override | ||
public void init() { | ||
Bukkit.getServer().getPluginManager().registerEvents(this, DenizenAPI.getCurrentInstance()); | ||
} | ||
|
||
@Override | ||
public void destroy() { | ||
IslandEnterEvent.getHandlerList().unregister(this); | ||
} | ||
|
||
@Override | ||
public boolean applyDetermination(ScriptContainer container, String determination) { | ||
return super.applyDetermination(container, determination); | ||
} | ||
|
||
@Override | ||
public ScriptEntryData getScriptEntryData() { | ||
return new BukkitScriptEntryData(new dPlayer(event.getPlayer()), null); | ||
} | ||
|
||
@Override | ||
public dObject getContext(String name) { | ||
if (name.equals("owner")) { | ||
return owner; | ||
} | ||
else if (name.equals("island_location")) { | ||
return island_location; | ||
} | ||
else if (name.equals("location")) { | ||
return location; | ||
} | ||
return super.getContext(name); | ||
} | ||
|
||
@EventHandler | ||
public void onPlayerEntersSkyblock(IslandEnterEvent event) { | ||
if (dEntity.isNPC(event.getPlayer())) { | ||
return; | ||
} | ||
island_location = new dLocation(event.getIslandLocation()); | ||
location = new dLocation(event.getLocation()); | ||
owner = new dPlayer(event.getIslandOwner()); | ||
this.event = event; | ||
fire(); | ||
} | ||
} |
110 changes: 110 additions & 0 deletions
110
...main/java/net/gnomeffinway/depenizen/events/ASkyBlock/PlayerExitsSkyBlockScriptEvent.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,110 @@ | ||
package net.gnomeffinway.depenizen.events.ASkyBlock; | ||
|
||
import com.wasteofplastic.askyblock.events.IslandEnterEvent; | ||
import com.wasteofplastic.askyblock.events.IslandExitEvent; | ||
import net.aufdemrand.denizen.BukkitScriptEntryData; | ||
import net.aufdemrand.denizen.events.BukkitScriptEvent; | ||
import net.aufdemrand.denizen.objects.dEntity; | ||
import net.aufdemrand.denizen.objects.dLocation; | ||
import net.aufdemrand.denizen.objects.dPlayer; | ||
import net.aufdemrand.denizen.utilities.DenizenAPI; | ||
import net.aufdemrand.denizencore.objects.dObject; | ||
import net.aufdemrand.denizencore.scripts.ScriptEntryData; | ||
import net.aufdemrand.denizencore.scripts.containers.ScriptContainer; | ||
import net.aufdemrand.denizencore.utilities.CoreUtilities; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
// <--[event] | ||
// @Events | ||
// player exits skyblock | ||
// | ||
// @Regex ^on player exits skyblock$ | ||
// | ||
// @Cancellable false | ||
// | ||
// @Triggers when a player leaves a skyblock island. | ||
// | ||
// @Context | ||
// <context.owner> Returns the owner of the island. | ||
// <context.island_location> Returns the location of the island. | ||
// <context.location> Returns the location the player exited at. | ||
// | ||
// @Plugin Depenizen, A SkyBlock | ||
// | ||
// --> | ||
|
||
public class PlayerExitsSkyBlockScriptEvent extends BukkitScriptEvent implements Listener { | ||
|
||
public PlayerExitsSkyBlockScriptEvent instance; | ||
public IslandExitEvent event; | ||
public dLocation location; | ||
public dLocation island_location; | ||
public dPlayer owner; | ||
|
||
public PlayerExitsSkyBlockScriptEvent() { | ||
instance = this; | ||
} | ||
|
||
@Override | ||
public boolean couldMatch(ScriptContainer scriptContainer, String s) { | ||
return CoreUtilities.toLowerCase(s).startsWith("player exits skyblock"); | ||
} | ||
|
||
@Override | ||
public boolean matches(ScriptContainer scriptContainer, String s) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "PlayerEntersSkyBlock"; | ||
} | ||
|
||
@Override | ||
public void init() { | ||
Bukkit.getServer().getPluginManager().registerEvents(this, DenizenAPI.getCurrentInstance()); | ||
} | ||
|
||
@Override | ||
public void destroy() { | ||
IslandExitEvent.getHandlerList().unregister(this); | ||
} | ||
|
||
@Override | ||
public boolean applyDetermination(ScriptContainer container, String determination) { | ||
return super.applyDetermination(container, determination); | ||
} | ||
|
||
@Override | ||
public ScriptEntryData getScriptEntryData() { | ||
return new BukkitScriptEntryData(new dPlayer(event.getPlayer()), null); | ||
} | ||
|
||
@Override | ||
public dObject getContext(String name) { | ||
if (name.equals("owner")) { | ||
return owner; | ||
} | ||
else if (name.equals("island_location")) { | ||
return island_location; | ||
} | ||
else if (name.equals("location")) { | ||
return location; | ||
} | ||
return super.getContext(name); | ||
} | ||
|
||
@EventHandler | ||
public void onPlayerExitsSkyblock(IslandExitEvent event) { | ||
if (dEntity.isNPC(event.getPlayer())) { | ||
return; | ||
} | ||
island_location = new dLocation(event.getIslandLocation()); | ||
location = new dLocation(event.getLocation()); | ||
owner = new dPlayer(event.getIslandOwner()); | ||
this.event = event; | ||
fire(); | ||
} | ||
} |
Oops, something went wrong.