Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AreaShop events: bought, rented, resold, sold
- Loading branch information
1 parent
c002e59
commit 7312eec
Showing
5 changed files
with
338 additions
and
1 deletion.
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
81 changes: 81 additions & 0 deletions
81
...in/java/com/denizenscript/depenizen/bukkit/events/areashop/AreaShopBoughtScriptEvent.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.areashop; | ||
|
||
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.scripts.ScriptEntryData; | ||
import com.denizenscript.depenizen.bukkit.objects.areashop.AreaShopTag; | ||
import me.wiefferink.areashop.events.notify.BoughtRegionEvent; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
public class AreaShopBoughtScriptEvent extends BukkitScriptEvent implements Listener { | ||
|
||
// <--[event] | ||
// @Events | ||
// areashop shop bought | ||
// areashop <shop> bought | ||
// | ||
// @Regex ^on areashop [^\s]+ bought$ | ||
// | ||
// @Triggers when an AreaShop is bought. | ||
// | ||
// @Context | ||
// <context.shop> returns the AreaShop that's being bought. | ||
// | ||
// @Plugin Depenizen, AreaShop | ||
// | ||
// @Player Always (the buyer). | ||
// | ||
// @Group Depenizen | ||
// | ||
// --> | ||
|
||
public AreaShopBoughtScriptEvent() { | ||
instance = this; | ||
} | ||
|
||
public static AreaShopBoughtScriptEvent instance; | ||
public BoughtRegionEvent event; | ||
public AreaShopTag areaShop; | ||
|
||
@Override | ||
public boolean couldMatch(ScriptPath path) { | ||
return path.eventLower.startsWith("areashop") && path.eventArgLowerAt(2).equals("bought"); | ||
} | ||
|
||
@Override | ||
public boolean matches(ScriptPath path) { | ||
String shopName = path.eventArgLowerAt(2).replace("areashop@", ""); | ||
if (!shopName.equals("shop") && !areaShop.equals(AreaShopTag.valueOf(shopName))) { | ||
return false; | ||
} | ||
return super.matches(path); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "AreaShopBought"; | ||
} | ||
|
||
@Override | ||
public ScriptEntryData getScriptEntryData() { | ||
return new BukkitScriptEntryData(new PlayerTag(event.getRegion().getBuyer()), null); | ||
} | ||
|
||
@Override | ||
public ObjectTag getContext(String name) { | ||
if (name.equals("shop")) { | ||
return areaShop; | ||
} | ||
return super.getContext(name); | ||
} | ||
|
||
@EventHandler | ||
public void onAreaShopEvent(BoughtRegionEvent event) { | ||
areaShop = new AreaShopTag(event.getRegion()); | ||
this.event = event; | ||
fire(event); | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
...in/java/com/denizenscript/depenizen/bukkit/events/areashop/AreaShopRentedScriptEvent.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,86 @@ | ||
package com.denizenscript.depenizen.bukkit.events.areashop; | ||
|
||
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.denizenscript.depenizen.bukkit.objects.areashop.AreaShopTag; | ||
import me.wiefferink.areashop.events.notify.RentedRegionEvent; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
public class AreaShopRentedScriptEvent extends BukkitScriptEvent implements Listener { | ||
|
||
// <--[event] | ||
// @Events | ||
// areashop shop rented | ||
// areashop <shop> rented | ||
// | ||
// @Regex ^on areashop [^\s]+ rented$ | ||
// | ||
// @Triggers when an AreaShop is rented. | ||
// | ||
// @Context | ||
// <context.shop> returns the AreaShop that's being rented. | ||
// <context.extended> returns true if the region has been extended, false if this is the first time buying the region. | ||
// | ||
// @Plugin Depenizen, AreaShop | ||
// | ||
// @Player Always (the renter). | ||
// | ||
// @Group Depenizen | ||
// | ||
// --> | ||
|
||
public AreaShopRentedScriptEvent() { | ||
instance = this; | ||
} | ||
|
||
public static AreaShopRentedScriptEvent instance; | ||
public RentedRegionEvent event; | ||
public AreaShopTag areaShop; | ||
|
||
@Override | ||
public boolean couldMatch(ScriptPath path) { | ||
return path.eventLower.startsWith("areashop") && path.eventArgLowerAt(2).equals("rented"); | ||
} | ||
|
||
@Override | ||
public boolean matches(ScriptPath path) { | ||
String shopName = path.eventArgLowerAt(2).replace("areashop@", ""); | ||
if (!shopName.equals("shop") && !areaShop.equals(AreaShopTag.valueOf(shopName))) { | ||
return false; | ||
} | ||
return super.matches(path); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "AreaShopRented"; | ||
} | ||
|
||
@Override | ||
public ScriptEntryData getScriptEntryData() { | ||
return new BukkitScriptEntryData(new PlayerTag(event.getRegion().getRenter()), null); | ||
} | ||
|
||
@Override | ||
public ObjectTag getContext(String name) { | ||
if (name.equals("shop")) { | ||
return areaShop; | ||
} | ||
if (name.equals("extended")) { | ||
return new ElementTag(event.hasExtended()); | ||
} | ||
return super.getContext(name); | ||
} | ||
|
||
@EventHandler | ||
public void onAreaShopEvent(RentedRegionEvent event) { | ||
areaShop = new AreaShopTag(event.getRegion()); | ||
this.event = event; | ||
fire(event); | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
...in/java/com/denizenscript/depenizen/bukkit/events/areashop/AreaShopResoldScriptEvent.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,85 @@ | ||
package com.denizenscript.depenizen.bukkit.events.areashop; | ||
|
||
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.scripts.ScriptEntryData; | ||
import com.denizenscript.depenizen.bukkit.objects.areashop.AreaShopTag; | ||
import me.wiefferink.areashop.events.notify.ResoldRegionEvent; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
public class AreaShopResoldScriptEvent extends BukkitScriptEvent implements Listener { | ||
|
||
// <--[event] | ||
// @Events | ||
// areashop shop resold | ||
// areashop <shop> resold | ||
// | ||
// @Regex ^on areashop [^\s]+ resold$ | ||
// | ||
// @Triggers when an AreaShop is resold. | ||
// | ||
// @Context | ||
// <context.shop> returns the AreaShop that's being resold. | ||
// <context.seller> returns the player that has resold the shop. | ||
// | ||
// @Plugin Depenizen, AreaShop | ||
// | ||
// @Player Always (the buyer). | ||
// | ||
// @Group Depenizen | ||
// | ||
// --> | ||
|
||
public AreaShopResoldScriptEvent() { | ||
instance = this; | ||
} | ||
|
||
public static AreaShopResoldScriptEvent instance; | ||
public ResoldRegionEvent event; | ||
public AreaShopTag areaShop; | ||
|
||
@Override | ||
public boolean couldMatch(ScriptPath path) { | ||
return path.eventLower.startsWith("areashop") && path.eventArgLowerAt(2).equals("resold"); | ||
} | ||
|
||
@Override | ||
public boolean matches(ScriptPath path) { | ||
String shopName = path.eventArgLowerAt(2).replace("areashop@", ""); | ||
if (!shopName.equals("shop") && !areaShop.equals(AreaShopTag.valueOf(shopName))) { | ||
return false; | ||
} | ||
return super.matches(path); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "AreaShopResold"; | ||
} | ||
|
||
@Override | ||
public ScriptEntryData getScriptEntryData() { | ||
return new BukkitScriptEntryData(new PlayerTag(event.getRegion().getBuyer()), null); | ||
} | ||
|
||
@Override | ||
public ObjectTag getContext(String name) { | ||
if (name.equals("shop")) { | ||
return areaShop; | ||
} | ||
if (name.equals("seller")) { | ||
return new PlayerTag(event.getFromPlayer()); | ||
} | ||
return super.getContext(name); | ||
} | ||
|
||
@EventHandler | ||
public void onAreaShopEvent(ResoldRegionEvent event) { | ||
areaShop = new AreaShopTag(event.getRegion()); | ||
this.event = event; | ||
fire(event); | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
...main/java/com/denizenscript/depenizen/bukkit/events/areashop/AreaShopSoldScriptEvent.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.areashop; | ||
|
||
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.scripts.ScriptEntryData; | ||
import com.denizenscript.depenizen.bukkit.objects.areashop.AreaShopTag; | ||
import me.wiefferink.areashop.events.notify.SoldRegionEvent; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
public class AreaShopSoldScriptEvent extends BukkitScriptEvent implements Listener { | ||
|
||
// <--[event] | ||
// @Events | ||
// areashop shop sold | ||
// areashop <shop> sold | ||
// | ||
// @Regex ^on areashop [^\s]+ sold$ | ||
// | ||
// @Triggers when an AreaShop is resold. | ||
// | ||
// @Context | ||
// <context.shop> returns the AreaShop that's being sold. | ||
// | ||
// @Plugin Depenizen, AreaShop | ||
// | ||
// @Player Always (the old buyer). | ||
// | ||
// @Group Depenizen | ||
// | ||
// --> | ||
|
||
public AreaShopSoldScriptEvent() { | ||
instance = this; | ||
} | ||
|
||
public static AreaShopSoldScriptEvent instance; | ||
public SoldRegionEvent event; | ||
public AreaShopTag areaShop; | ||
|
||
@Override | ||
public boolean couldMatch(ScriptPath path) { | ||
return path.eventLower.startsWith("areashop") && path.eventArgLowerAt(2).equals("sold"); | ||
} | ||
|
||
@Override | ||
public boolean matches(ScriptPath path) { | ||
String shopName = path.eventArgLowerAt(2).replace("areashop@", ""); | ||
if (!shopName.equals("shop") && !areaShop.equals(AreaShopTag.valueOf(shopName))) { | ||
return false; | ||
} | ||
return super.matches(path); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "AreaShopSold"; | ||
} | ||
|
||
@Override | ||
public ScriptEntryData getScriptEntryData() { | ||
return new BukkitScriptEntryData(new PlayerTag(event.getOldBuyer()), null); | ||
} | ||
|
||
@Override | ||
public ObjectTag getContext(String name) { | ||
if (name.equals("shop")) { | ||
return areaShop; | ||
} | ||
return super.getContext(name); | ||
} | ||
|
||
@EventHandler | ||
public void onAreaShopEvent(SoldRegionEvent event) { | ||
areaShop = new AreaShopTag(event.getRegion()); | ||
this.event = event; | ||
fire(event); | ||
} | ||
} |