Skip to content

Commit

Permalink
Add Big Doors support. (#337)
Browse files Browse the repository at this point in the history
* Add Big Doors support.

* Fix a meta copy-pasta error

* Acknowledge and fix monkey's comments.

* Whooopppsss

* Another whoopsie

* Replace-all fix.

* IDK why this period got removed when I copy-pasted.

* Changes to monkey spec

* Update BigDoorsDoorTag.java

* Update BigDoorsDoorTag.java
  • Loading branch information
Fortifier42 committed Sep 2, 2020
1 parent c55c6b8 commit bd7a8e3
Show file tree
Hide file tree
Showing 9 changed files with 605 additions and 0 deletions.
1 change: 1 addition & 0 deletions Docs/BukkitPlugins.md
Expand Up @@ -3,6 +3,7 @@ Supported Plugins: (And the sources we acquired Jar files from.)

- AreaShop (https://www.spigotmc.org/resources/areashop.2991/)
- ASkyBlock (https://www.spigotmc.org/resources/a-skyblock.1220/)
- BigDoors (https://www.spigotmc.org/resources/big-doors.58669)
- BossShopPro (https://www.spigotmc.org/resources/bossshop-powerful-and-playerfriendly-chest-gui-shop-menu-plugin.222/)
- CrackShot (https://www.spigotmc.org/resources/crackshot-guns.48301/)
- EffectLib (https://dev.bukkit.org/projects/effectlib)
Expand Down
Binary file added lib/BigDoors.jar
Binary file not shown.
8 changes: 8 additions & 0 deletions pom.xml
Expand Up @@ -334,6 +334,14 @@
<scope>system</scope>
<systemPath>${basedir}/lib/CrackShot.jar</systemPath>
</dependency>
<dependency>
<groupId>nl.pim16aap2</groupId>
<artifactId>bigDoors</artifactId>
<version>0.1.8.25</version>
<type>jar</type>
<scope>system</scope>
<systemPath>${basedir}/lib/BigDoors.jar</systemPath>
</dependency>
</dependencies>

<build>
Expand Down
Expand Up @@ -97,6 +97,7 @@ public void registerCoreBridges() {
// Yes it needs to be `new MyBridge()` not `MyBridge::new` - this is due to an error in the Java runtime.
registerBridge("AreaShop", () -> new AreaShopBridge());
registerBridge("ASkyBlock", () -> new ASkyBlockBridge());
registerBridge("BigDoors", () -> new BigDoorsBridge());
registerBridge("BossShopPro", () -> new BossShopBridge());
registerBridge("CrackShot", () -> new CrackShotBridge());
registerBridge("EffectLib", () -> new EffectLibBridge());
Expand Down
@@ -0,0 +1,48 @@
package com.denizenscript.depenizen.bukkit.bridges;

import com.denizenscript.denizen.objects.PlayerTag;
import com.denizenscript.denizen.objects.WorldTag;
import com.denizenscript.denizencore.events.ScriptEvent;
import com.denizenscript.denizencore.objects.ObjectFetcher;
import com.denizenscript.denizencore.objects.properties.PropertyParser;
import com.denizenscript.denizencore.tags.TagManager;
import com.denizenscript.depenizen.bukkit.Bridge;
import com.denizenscript.depenizen.bukkit.events.bigdoors.BigDoorsDoorTogglesScriptEvent;
import com.denizenscript.depenizen.bukkit.objects.bigdoors.BigDoorsDoorTag;
import com.denizenscript.depenizen.bukkit.properties.bigdoors.BigDoorsPlayerProperties;
import com.denizenscript.depenizen.bukkit.properties.bigdoors.BigDoorsWorldProperties;
import nl.pim16aap2.bigDoors.BigDoors;
import nl.pim16aap2.bigDoors.Commander;
import org.bukkit.Bukkit;

public class BigDoorsBridge extends Bridge {

public static BigDoors bigDoors;
public static Commander commander;

@Override
public void init() {
bigDoors = (BigDoors) Bukkit.getPluginManager().getPlugin("BigDoors");
commander = bigDoors.getCommander();
ObjectFetcher.registerWithObjectFetcher(BigDoorsDoorTag.class, BigDoorsDoorTag.tagProcessor);
PropertyParser.registerProperty(BigDoorsWorldProperties.class, WorldTag.class);
PropertyParser.registerProperty(BigDoorsPlayerProperties.class, PlayerTag.class);
ScriptEvent.registerScriptEvent(new BigDoorsDoorTogglesScriptEvent());

// <--[tag]
// @attribute <bigdoor[<door>]>
// @returns BigDoorsDoorTag
// @plugin Depenizen, Big Doors
// @description
// Returns the door for the value.
// -->
TagManager.registerTagHandler("bigdoor", (attribute) -> {
if (!attribute.hasContext(1)) {
attribute.echoError("Big Doors door tag base must have input.");
return null;
}
return BigDoorsDoorTag.valueOf(attribute.getContext(1), attribute.context);
});

}
}
@@ -0,0 +1,99 @@
package com.denizenscript.depenizen.bukkit.events.bigdoors;

import com.denizenscript.denizen.events.BukkitScriptEvent;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.objects.core.ElementTag;
import com.denizenscript.depenizen.bukkit.objects.bigdoors.BigDoorsDoorTag;
import nl.pim16aap2.bigDoors.Door;
import nl.pim16aap2.bigDoors.events.DoorEventToggle;
import nl.pim16aap2.bigDoors.events.DoorEventTogglePrepare;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

public class BigDoorsDoorTogglesScriptEvent extends BukkitScriptEvent implements Listener {

// <--[event]
// @Events
// bigdoors door [toggles|opens|closes]
//
// @Regex ^on bigdoors door (toggles|opens|closes)$
//
// @Cancellable true
//
// @Triggers when a Big Doors door toggles, opens, or closes.
//
// @Context
// <context.door> returns the Big Doors door being toggled.
// <context.state> returns the Big Doors open state.
//
// @Plugin Depenizen, Big Doors
//
// @Switch door:<id> to only process the event if the door matches the input.
//
// @Group Depenizen
//
// -->

public BigDoorsDoorTogglesScriptEvent() {
instance = this;
}

public static BigDoorsDoorTogglesScriptEvent instance;
public DoorEventTogglePrepare event;
public Door door;
public DoorEventToggle.ToggleType toggleType;

@Override
public boolean couldMatch(ScriptPath path) {
if (!path.eventLower.startsWith("bigdoors door")) {
return false;
}
return true;
}

@Override
public boolean matches(ScriptPath path) {
String cmd = path.eventArgLowerAt(2);
if (cmd.equals("opens")) {
if (toggleType != DoorEventToggle.ToggleType.OPEN) {
return false;
}
}
else if (cmd.equals("closes")) {
if (toggleType != DoorEventToggle.ToggleType.CLOSE) {
return false;
}
}
else if (!cmd.equals("toggles")) {
return false;
}
if (!runGenericSwitchCheck(path, "door", String.valueOf(door.getDoorUID()))) {
return false;
}
return super.matches(path);
}

@Override
public String getName() {
return "BigDoorsDoorToggles";
}

@Override
public ObjectTag getContext(String name) {
if (name.equals("door")) {
return new BigDoorsDoorTag(door);
}
else if (name.equals("state")) {
return new ElementTag(toggleType.toString());
}
return super.getContext(name);
}

@EventHandler
public void onBigDoorsDoorToggles(DoorEventTogglePrepare event) {
this.event = event;
this.toggleType = event.getToggleType();
this.door = event.getDoor();
fire(event);
}
}

0 comments on commit bd7a8e3

Please sign in to comment.