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
9b3d009
commit 2086ead
Showing
9 changed files
with
88 additions
and
15 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
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
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
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
78 changes: 78 additions & 0 deletions
78
...com/denizenscript/depenizen/bukkit/events/mythickeys/MythicKeysKeyReleaseScriptEvent.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.MythicKeyReleaseEvent; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
|
||
public class MythicKeysKeyReleaseScriptEvent extends BukkitScriptEvent implements Listener { | ||
|
||
// <--[event] | ||
// @Events | ||
// mythickeys key released | ||
// | ||
// @Location true | ||
// | ||
// @Switch id:<id> to only process the event if the key ID matches the given text matcher. | ||
// | ||
// @Triggers When a key stops being pressed by a client running MythicKeys, if that key is in the MythicKeys config. | ||
// | ||
// @Context | ||
// <context.id> Returns the ID of the key that was released according to the MythicKeys config, as a namespaced key. | ||
// | ||
// @Player Always. | ||
// | ||
// @Plugin Depenizen, MythicKeys | ||
// | ||
// @Group Depenizen | ||
// | ||
// --> | ||
|
||
public MythicKeysKeyReleaseScriptEvent() { | ||
instance = this; | ||
registerCouldMatcher("mythickeys key released"); | ||
registerSwitches("id"); | ||
} | ||
|
||
public static MythicKeysKeyReleaseScriptEvent instance; | ||
public MythicKeyReleaseEvent 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 "MythicKeysKeyReleased"; | ||
} | ||
|
||
@Override | ||
public ScriptEntryData getScriptEntryData() { | ||
return new BukkitScriptEntryData(event.getPlayer()); | ||
} | ||
|
||
@Override | ||
public ObjectTag getContext(String name) { | ||
switch (name) { | ||
case "id": return new ElementTag(event.getId().toString()); | ||
} | ||
return super.getContext(name); | ||
} | ||
|
||
@EventHandler | ||
public void onKeyRelease(MythicKeyReleaseEvent event) { | ||
this.event = event; | ||
fire(event); | ||
} | ||
} |