-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
3 changed files
with
86 additions
and
5 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
src/main/java/com/github/kory33/signvote/api/SignVoteAPI.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,38 @@ | ||
package com.github.kory33.signvote.api; | ||
|
||
import com.github.kory33.signvote.core.SignVote; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.block.BlockState; | ||
import org.bukkit.block.Sign; | ||
|
||
/** | ||
* An API of SignVote which may be openly accessed by addons. | ||
* <p> | ||
* Please note that you should only access the internals of SignVote plugin | ||
* only if the desired functionality is not provided by this class or its subclasses. | ||
* <p> | ||
* Internal access may damage the data structure of SignVote plugin, hence | ||
* manipulating SignVote's data should be done with a certain care. | ||
*/ | ||
public class SignVoteAPI { | ||
private final SignVote plugin; | ||
|
||
public SignVoteAPI(SignVote plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
/** | ||
* Checks if the given block is a SignVote's vote-point | ||
* @param block target block | ||
* @return true if the sign is a vote-point | ||
*/ | ||
public boolean isSignVoteSign(Block block) { | ||
BlockState blockState = block.getState(); | ||
if (!(blockState instanceof Sign)) { | ||
return false; | ||
} | ||
|
||
Sign sign = (Sign) blockState; | ||
return this.plugin.getVoteSessionManager().getVoteSession(sign).isPresent(); | ||
} | ||
} |
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