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
0049f61
commit cdbe1d4
Showing
6 changed files
with
101 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
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
13 changes: 13 additions & 0 deletions
13
src/main/java/com/denizenscript/depenizen/bukkit/bridges/MythicKeysBridge.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,13 @@ | ||
package com.denizenscript.depenizen.bukkit.bridges; | ||
|
||
import com.denizenscript.denizencore.events.ScriptEvent; | ||
import com.denizenscript.depenizen.bukkit.Bridge; | ||
import com.denizenscript.depenizen.bukkit.events.mythickeys.MythicKeysKeyPressScriptEvent; | ||
|
||
public class MythicKeysBridge extends Bridge { | ||
|
||
@Override | ||
public void init() { | ||
ScriptEvent.registerScriptEvent(MythicKeysKeyPressScriptEvent.class); | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
...a/com/denizenscript/depenizen/bukkit/events/mythickeys/MythicKeysKeyPressScriptEvent.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,78 @@ | ||
package com.denizenscript.depenizen.bukkit.events.mythickeys; | ||
|
||
import com.denizenscript.denizen.events.BukkitScriptEvent; | ||
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 eu.asangarin.mythickeys.api.MythicKeyPressEvent; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
public class MythicKeysKeyPressScriptEvent extends BukkitScriptEvent implements Listener { | ||
|
||
// <--[event] | ||
// @Events | ||
// mythickeys key pressed | ||
// | ||
// @Location true | ||
// | ||
// @Switch id:<id> to only process the event if the specific key ID was pressed. | ||
// | ||
// @Triggers when a key was pressed by a client running MythicKeys, if that key is in the MythicKeys config. | ||
// | ||
// @Context | ||
// <context.id> Returns the ID of the key pressed. | ||
// | ||
// @Player Always. | ||
// | ||
// @Plugin Depenizen, MythicKeys | ||
// | ||
// @Group Depenizen | ||
// | ||
// --> | ||
|
||
public MythicKeysKeyPressScriptEvent() { | ||
instance = this; | ||
registerCouldMatcher("mythickeys key pressed"); | ||
registerSwitches("id"); | ||
} | ||
|
||
public static MythicKeysKeyPressScriptEvent instance; | ||
public MythicKeyPressEvent event; | ||
|
||
@Override | ||
public boolean matches(ScriptPath path) { | ||
if (!runGenericSwitchCheck(path, "id", String.valueOf(event.getId()))) { | ||
return false; | ||
} | ||
if (!runInCheck(path, event.getPlayer().getLocation())) { | ||
return false; | ||
} | ||
return super.matches(path); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "MythicKeysKeyPressed"; | ||
} | ||
|
||
@Override | ||
public ScriptEntryData getScriptEntryData() { | ||
return new BukkitScriptEntryData(event.getPlayer()); | ||
} | ||
|
||
@Override | ||
public ObjectTag getContext(String name) { | ||
if (name.equals("id")) { | ||
return new ElementTag(event.getId()); | ||
} | ||
return super.getContext(name); | ||
} | ||
|
||
@EventHandler | ||
public void onKeyPress(MythicKeyPressEvent event) { | ||
this.event = event; | ||
fire(event); | ||
} | ||
} |
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