Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
1 parent
c55c6b8
commit bd7a8e3
Showing
9 changed files
with
605 additions
and
0 deletions.
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
Binary file not shown.
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
48 changes: 48 additions & 0 deletions
48
src/main/java/com/denizenscript/depenizen/bukkit/bridges/BigDoorsBridge.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,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); | ||
}); | ||
|
||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
...va/com/denizenscript/depenizen/bukkit/events/bigdoors/BigDoorsDoorTogglesScriptEvent.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,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); | ||
} | ||
} |
Oops, something went wrong.