-
Notifications
You must be signed in to change notification settings - Fork 49
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
46 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
29 changes: 29 additions & 0 deletions
29
src/main/java/com/extendedclip/deluxemenus/requirement/BooleanRequirement.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,29 @@ | ||
package com.extendedclip.deluxemenus.requirement; | ||
|
||
import com.extendedclip.deluxemenus.menu.MenuHolder; | ||
|
||
public class BooleanRequirement extends Requirement { | ||
|
||
private final String bool; | ||
private final boolean invert; | ||
|
||
public BooleanRequirement(String bool, boolean invert) { | ||
this.bool = bool; | ||
this.invert = invert; | ||
} | ||
|
||
@Override | ||
public boolean evaluate(MenuHolder holder) { | ||
String check = holder.setPlaceholdersAndArguments(bool); | ||
try { | ||
boolean bool = Boolean.parseBoolean(check); | ||
if (invert) { | ||
return !bool; | ||
} else { | ||
return bool; | ||
} | ||
} catch (Exception e) { | ||
return false; | ||
} | ||
} | ||
} |
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