-
-
Notifications
You must be signed in to change notification settings - Fork 108
Add configurable requirements for blocks #342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
f65409c
Added "blocks:" node to config.yml
Fly1337 a9ac7d3
Added loading mechanism for blocks to RequirementManager
Fly1337 0e5f716
Added reloading support for the block requirements
Fly1337 cab2dac
Added BlockRequirement for holding block-requirement data
Fly1337 9c72e31
Added superclass for future requirement nodes
Fly1337 a6344aa
Added requirement nodes
Fly1337 048533e
Added logic for checking block requirements
Fly1337 36f9a7a
Changed block requirements storage to a List
Fly1337 49aee4a
Added check for empty messages for block requirements
Fly1337 bb75f2c
Corrected the loading algorithm for block requirements
Fly1337 24e819c
Simplified and standardized code as request in PR:342
Fly1337 90e32eb
Adventure support and option to disable block requirements
Fly1337 22edcbf
Fix config consistency
Fly1337 8469a1b
Fix config consistency
Fly1337 5d4699d
Merge remote-tracking branch 'origin/blocks' into blocks
Fly1337 a017c95
Fix config consistency again
Fly1337 13f9065
Added empty default list to requirement block config
Fly1337 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
36 changes: 36 additions & 0 deletions
36
bukkit/src/main/java/dev/aurelium/auraskills/bukkit/requirement/blocks/BlockRequirement.java
This file contains hidden or 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,36 @@ | ||
package dev.aurelium.auraskills.bukkit.requirement.blocks; | ||
|
||
import org.bukkit.Material; | ||
|
||
import java.util.LinkedList; | ||
|
||
public class BlockRequirement { | ||
|
||
private final Material material; | ||
private final boolean checksPlace; | ||
private final boolean checksBreak; | ||
private final LinkedList<RequirementNode> nodes; | ||
Archy-X marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
public BlockRequirement(Material material, boolean checksPlace, boolean checksBreak, LinkedList<RequirementNode> nodes) { | ||
this.material = material; | ||
this.checksPlace = checksPlace; | ||
this.checksBreak = checksBreak; | ||
this.nodes = nodes; | ||
} | ||
|
||
public Material getMaterial() { | ||
return material; | ||
} | ||
|
||
public boolean checksPlacing() { | ||
return checksPlace; | ||
} | ||
|
||
public boolean checksBreaking() { | ||
return checksBreak; | ||
} | ||
|
||
public LinkedList<RequirementNode> getNodes() { | ||
return nodes; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...it/src/main/java/dev/aurelium/auraskills/bukkit/requirement/blocks/ExcludedWorldNode.java
This file contains hidden or 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,31 @@ | ||
package dev.aurelium.auraskills.bukkit.requirement.blocks; | ||
|
||
import dev.aurelium.auraskills.bukkit.AuraSkills; | ||
import org.bukkit.entity.Player; | ||
|
||
public class ExcludedWorldNode extends RequirementNode { | ||
|
||
private final String[] worlds; | ||
private final String message; | ||
|
||
public ExcludedWorldNode(AuraSkills plugin, String[] worlds, String message) { | ||
super(plugin); | ||
this.worlds = worlds; | ||
this.message = message; | ||
} | ||
|
||
@Override | ||
public boolean check(Player player) { | ||
for (String world : worlds) { | ||
if (player.getWorld().getName().equalsIgnoreCase(world)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getDenyMessage() { | ||
return message; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
bukkit/src/main/java/dev/aurelium/auraskills/bukkit/requirement/blocks/PermissionNode.java
This file contains hidden or 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,24 @@ | ||
package dev.aurelium.auraskills.bukkit.requirement.blocks; | ||
|
||
import dev.aurelium.auraskills.bukkit.AuraSkills; | ||
import org.bukkit.entity.Player; | ||
|
||
public class PermissionNode extends RequirementNode { | ||
|
||
private final String permission; | ||
private final String message; | ||
|
||
public PermissionNode(AuraSkills plugin, String permission, String message) { | ||
super(plugin); | ||
this.permission = permission; | ||
this.message = message; | ||
} | ||
|
||
public boolean check(Player player) { | ||
Archy-X marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return player.hasPermission(permission); | ||
} | ||
|
||
public String getDenyMessage() { | ||
return message; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
bukkit/src/main/java/dev/aurelium/auraskills/bukkit/requirement/blocks/RequirementNode.java
This file contains hidden or 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,16 @@ | ||
package dev.aurelium.auraskills.bukkit.requirement.blocks; | ||
|
||
import dev.aurelium.auraskills.bukkit.AuraSkills; | ||
import org.bukkit.entity.Player; | ||
|
||
public abstract class RequirementNode { | ||
|
||
protected AuraSkills plugin; | ||
|
||
public RequirementNode(AuraSkills plugin) { | ||
Archy-X marked this conversation as resolved.
Show resolved
Hide resolved
|
||
this.plugin = plugin; | ||
} | ||
|
||
public abstract String getDenyMessage(); | ||
public abstract boolean check(Player player); | ||
} |
27 changes: 27 additions & 0 deletions
27
bukkit/src/main/java/dev/aurelium/auraskills/bukkit/requirement/blocks/SkillNode.java
This file contains hidden or 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,27 @@ | ||
package dev.aurelium.auraskills.bukkit.requirement.blocks; | ||
|
||
import dev.aurelium.auraskills.api.skill.Skill; | ||
import dev.aurelium.auraskills.bukkit.AuraSkills; | ||
import org.bukkit.entity.Player; | ||
|
||
public class SkillNode extends RequirementNode { | ||
|
||
private final Skill skill; | ||
private final int level; | ||
private final String message; | ||
|
||
public SkillNode(AuraSkills plugin, Skill skill, int level, String message) { | ||
super(plugin); | ||
this.skill = skill; | ||
this.level = level; | ||
this.message = message; | ||
} | ||
|
||
public boolean check(Player player) { | ||
Archy-X marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return plugin.getUser(player).getSkillLevel(skill) >= level; | ||
} | ||
|
||
public String getDenyMessage() { | ||
return message; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
bukkit/src/main/java/dev/aurelium/auraskills/bukkit/requirement/blocks/StatNode.java
This file contains hidden or 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,27 @@ | ||
package dev.aurelium.auraskills.bukkit.requirement.blocks; | ||
|
||
import dev.aurelium.auraskills.api.stat.Stat; | ||
import dev.aurelium.auraskills.bukkit.AuraSkills; | ||
import org.bukkit.entity.Player; | ||
|
||
public class StatNode extends RequirementNode { | ||
|
||
private final Stat stat; | ||
private final int value; | ||
private final String message; | ||
|
||
public StatNode(AuraSkills plugin, Stat stat, int value, String message) { | ||
super(plugin); | ||
this.stat = stat; | ||
this.value = value; | ||
this.message = message; | ||
} | ||
|
||
public boolean check(Player player) { | ||
Archy-X marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return plugin.getUser(player).getStatLevel(stat) >= value; | ||
} | ||
|
||
public String getDenyMessage() { | ||
return message; | ||
} | ||
} |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.