-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #340 from steve4744/master
add ability to set a one-time fee for a course
- Loading branch information
Showing
9 changed files
with
111 additions
and
20 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
58 changes: 58 additions & 0 deletions
58
src/main/java/io/github/a5h73y/parkour/plugin/PermissionVault.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,58 @@ | ||
package io.github.a5h73y.parkour.plugin; | ||
|
||
import static org.bukkit.Bukkit.getServer; | ||
|
||
import org.bukkit.entity.Player; | ||
import org.bukkit.plugin.RegisteredServiceProvider; | ||
import io.github.a5h73y.parkour.Parkour; | ||
import io.github.a5h73y.parkour.utility.PluginUtils; | ||
import net.milkbowl.vault.permission.Permission; | ||
|
||
public class PermissionVault extends PluginWrapper { | ||
|
||
public PermissionVault(Parkour parkour) { | ||
super(parkour); | ||
} | ||
|
||
private Permission permission; | ||
private static final String COURSE_PERMISSION = "parkour.course."; | ||
|
||
@Override | ||
protected void initialise() { | ||
super.initialise(); | ||
|
||
if (isEnabled()) { | ||
RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class); | ||
|
||
if (rsp == null) { | ||
PluginUtils.log("[Permission] Failed to connect to Vault's Permission service.", 2); | ||
setEnabled(false); | ||
return; | ||
} | ||
|
||
permission = rsp.getProvider(); | ||
} | ||
} | ||
|
||
public Permission getPermissions() { | ||
return permission; | ||
} | ||
|
||
public boolean isPermissions() { | ||
return permission != null; | ||
} | ||
|
||
public boolean hasPaidOneTimeFee(Player player, String courseName) { | ||
return player.hasPermission(COURSE_PERMISSION + courseName); | ||
} | ||
|
||
public void setPaidOneTimeFee(Player player, String courseName) { | ||
permission.playerAdd(null, player, COURSE_PERMISSION + courseName); | ||
} | ||
|
||
@Override | ||
public String getPluginName() { | ||
return "Vault"; | ||
} | ||
|
||
} |
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