Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EXPERIMENTAL] Add "player swaps items" event for #1329
Should be replaced whenever Spigot adds an event
- Loading branch information
Showing
3 changed files
with
68 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
52 changes: 52 additions & 0 deletions
52
src/main/java/net/aufdemrand/denizen/events/player/PlayerSwapsItemsScriptEvent.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,52 @@ | ||
package net.aufdemrand.denizen.events.player; | ||
|
||
import net.aufdemrand.denizen.BukkitScriptEntryData; | ||
import net.aufdemrand.denizen.events.BukkitScriptEvent; | ||
import net.aufdemrand.denizen.objects.dPlayer; | ||
import net.aufdemrand.denizencore.scripts.ScriptEntryData; | ||
import net.aufdemrand.denizencore.scripts.containers.ScriptContainer; | ||
import net.aufdemrand.denizencore.utilities.CoreUtilities; | ||
|
||
public class PlayerSwapsItemsScriptEvent extends BukkitScriptEvent { | ||
|
||
// <--[event] | ||
// @Events | ||
// player swaps items | ||
// | ||
// @Regex ^on player swaps items$ | ||
// | ||
// @Warning This event is a prototype and may change drastically in the future. | ||
// | ||
// @Cancellable true | ||
// | ||
// @Triggers when a player swaps the items in their main and offhand. | ||
// | ||
// --> | ||
|
||
public PlayerSwapsItemsScriptEvent() { | ||
instance = this; | ||
} | ||
|
||
public static PlayerSwapsItemsScriptEvent instance; | ||
public dPlayer player; | ||
|
||
@Override | ||
public boolean couldMatch(ScriptContainer scriptContainer, String s) { | ||
return CoreUtilities.toLowerCase(s).startsWith("player swaps items"); | ||
} | ||
|
||
@Override | ||
public boolean matches(ScriptContainer scriptContainer, String s) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "PlayerSwapsItems"; | ||
} | ||
|
||
@Override | ||
public ScriptEntryData getScriptEntryData() { | ||
return new BukkitScriptEntryData(player, null); | ||
} | ||
} |
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