Skip to content

Commit 4912898

Browse files
committed
Fix permissions... Add admin perms instead of relying on OP
1 parent 9946509 commit 4912898

File tree

13 files changed

+23
-14
lines changed

13 files changed

+23
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Waypoints Plugin for Minecraft (Paper)
1616
## Permissions:
1717

1818
- **zoink.waypoints**: Allow the user to use the personal waypoints.
19-
- Server Operator for some commands.
19+
- **zoink.waypoints.admin**: Allow admins to configure/setup plugin through `wconfig` or `wsetup`
2020

2121
## Config.yml
2222
### For Lazy People

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>zoink.jule</groupId>
88
<artifactId>Waypoints</artifactId>
9-
<version>1.4.1</version>
9+
<version>1.4.2</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Waypoints</name>

src/main/java/zoink/jule/waypoints/Commands/WConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.bukkit.configuration.file.FileConfiguration;
88
import org.bukkit.entity.Player;
99
import org.jetbrains.annotations.NotNull;
10+
import zoink.jule.waypoints.Utils.Permissions;
1011
import zoink.jule.waypoints.Waypoints;
1112

1213
import java.io.File;
@@ -26,7 +27,7 @@ public WConfig(Waypoints plugin) {
2627
public boolean onCommand(@NotNull CommandSender cmdSender, @NotNull Command cmd, @NotNull String label, String[] args) {
2728
if(!(cmdSender instanceof Player)) {
2829
return true;
29-
} else if(!cmdSender.isOp()) {
30+
} else if(!cmdSender.hasPermission(Permissions.ADMIN.permission)) {
3031
sendMessage((Player)cmdSender, "<red>You are not a server operator!</red>");
3132
return true;
3233
}

src/main/java/zoink/jule/waypoints/Commands/WDelete.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public boolean onCommand(@NotNull CommandSender cmdSender, @NotNull Command cmd,
2020
return true;
2121

2222
Player player = (Player)cmdSender;
23-
checkPermissions(player);
23+
if(!checkPermissions(player)) return false;
2424

2525
if (args.length < 1) {
2626
sendMessage(player, "<red>No name given!</red>");

src/main/java/zoink/jule/waypoints/Commands/WHome.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public boolean onCommand(@NotNull CommandSender cmdSender, @NotNull Command cmd,
1919
Player player = (Player)cmdSender;
2020
Location playerSpawn;
2121

22-
checkPermissions(player);
22+
if(!checkPermissions(player)) return false;
2323

2424
if (args.length > 1) {
2525
sendMessage(player, "<red>This command does not accept arguments!</red>");

src/main/java/zoink/jule/waypoints/Commands/WList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public boolean onCommand(@NotNull CommandSender cmdSender, @NotNull Command cmd,
3030
plugin.reloadConfig();
3131
Player player = (Player) cmdSender;
3232
FileConfiguration config = plugin.getConfig();
33-
checkPermissions(player);
33+
if(!checkPermissions(player)) return false;
3434

3535
File waypointFile = new File("waypoints/" + player.getUniqueId() + ".yml");
3636
FileConfiguration waypoints = YamlConfiguration.loadConfiguration(waypointFile);

src/main/java/zoink/jule/waypoints/Commands/WSave.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public boolean onCommand(@NotNull CommandSender cmdSender, @NotNull Command cmd,
3030
return true;
3131

3232
Player player = (Player) cmdSender;
33-
checkPermissions(player);
33+
if(!checkPermissions(player)) return false;
3434

3535
if (args.length < 1) {
3636
sendMessage(player, "<red>No name given!</red>");

src/main/java/zoink/jule/waypoints/Commands/WSetup.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.bukkit.configuration.file.FileConfiguration;
1111
import org.bukkit.entity.Player;
1212
import org.jetbrains.annotations.NotNull;
13+
import zoink.jule.waypoints.Utils.Permissions;
1314
import zoink.jule.waypoints.Waypoints;
1415

1516
import java.io.File;
@@ -31,7 +32,7 @@ public WSetup(Waypoints plugin) {
3132
public boolean onCommand(@NotNull CommandSender cmdSender, @NotNull Command cmd, @NotNull String label, String[] args) {
3233
if(!(cmdSender instanceof Player)) {
3334
return true;
34-
} else if(!cmdSender.isOp()) {
35+
} else if(!cmdSender.hasPermission(Permissions.ADMIN.permission)) {
3536
sendMessage((Player)cmdSender, "<red>You are not a server operator!</red>");
3637
return true;
3738
}

src/main/java/zoink/jule/waypoints/Commands/WSpawn.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
import zoink.jule.waypoints.Utils.TeleportUtils;
1313
import zoink.jule.waypoints.Waypoints;
1414
import java.util.Objects;
15-
import static zoink.jule.waypoints.Waypoints.CHAT_PREFIX;
16-
import static zoink.jule.waypoints.Waypoints.sendMessage;
15+
16+
import static zoink.jule.waypoints.Waypoints.*;
1717

1818
public class WSpawn implements CommandExecutor {
1919
private final Waypoints plugin;
@@ -27,11 +27,14 @@ public boolean onCommand(@NotNull CommandSender cmdSender, @NotNull Command cmd,
2727
if (!(cmdSender instanceof Player))
2828
return true;
2929

30+
3031
plugin.reloadConfig();
3132
FileConfiguration config = plugin.getConfig();
3233
Player player = (Player)cmdSender;
3334
World world = Bukkit.getWorld(Objects.requireNonNull(config.getString("spawn.world")));
3435

36+
if(!checkPermissions(player)) return false;
37+
3538
if (!config.getBoolean("spawn.enabled")) {
3639
sendMessage(player, "<red>This command is not enabled on this server!</red>");
3740
return true;

src/main/java/zoink/jule/waypoints/Commands/WTp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public boolean onCommand(@NotNull CommandSender cmdSender, @NotNull Command cmd,
3232
Player player = (Player)cmdSender;
3333
World world;
3434

35-
checkPermissions(player);
35+
if(!checkPermissions(player)) return false;
3636

3737
if (args.length < 1) {
3838
sendMessage(player, "<red>No name given!</red>");

0 commit comments

Comments
 (0)