Skip to content
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

Adds permissions support to homebukkit #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -21,7 +21,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St

if (player == null) {
return true;
} else if ((player != sender) && (!sender.isOp())) {
} else if ((player != sender) && (!player.hasPermission("homebukkit.home.other"))) {
sender.sendMessage(ChatColor.RED + "You don't have permission to go to other players homes");
return true;
} else if (!(sender instanceof Player)) {
Expand All @@ -32,7 +32,10 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}

String name = args[0];

if(player.hasPermission("homebukkit.home.self")){
player.sendMessage("you dont have permission to go to your home");
return true;
}
Home home = plugin.getDatabase().find(Home.class).where().ieq("name", name).ieq("playerName", player.getName()).findUnique();

if (home == null) {
Expand Down
Expand Up @@ -32,6 +32,9 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
sender.sendMessage("That player has no homes!");
}
} else {
if(sender == player && player.hasPermission("homebukkit.list.self") ){


String result = "";

for (Home home : homes) {
Expand All @@ -44,6 +47,26 @@ public boolean onCommand(CommandSender sender, Command command, String label, St

sender.sendMessage("All home(s): " + result);
}
else if(sender != player && player.hasPermission("homebukkit.list.other")){
String result = "";

for (Home home : homes) {
if (result.length() > 0) {
result += ", ";
}

result += home.getName();
}

sender.sendMessage("All home(s): " + result);
}
else if(sender == player &&! player.hasPermission("homebukkit.list.self")){
player.sendMessage("you dont have permission to list your own homes!");
}
else if(sender != player &&! player.hasPermission("homebukkit.list.other")){
player.sendMessage("you dont have permission to list other peoples homes!");
}
}

return true;
}
Expand Down
Expand Up @@ -21,7 +21,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St

if (player == null) {
return true;
} else if ((player != sender) && (!sender.isOp())) {
} else if ((player != sender) && (!sender.hasPermission("homebukkit.set.other"))) {
sender.sendMessage(ChatColor.RED + "You don't have permission to set other players homes");
return true;
} else if (!(sender instanceof Player)) {
Expand All @@ -32,7 +32,10 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
}

String name = args[0];

if(!player.hasPermission("homebukkit.set.self")){
player.sendMessage("You dont have permission to set your home");
return true;
}
Home home = plugin.getDatabase().find(Home.class).where().ieq("name", name).ieq("playerName", player.getName()).findUnique();

if (home == null) {
Expand Down
39 changes: 38 additions & 1 deletion src/main/resources/plugin.yml
Expand Up @@ -21,4 +21,41 @@ commands:
gohome:
aliases: [home]
description: Goes to a home
usage: /<command> <name> [player]
usage: /<command> <name> [player]
permissions:
homebukkit.set:
description: allows the player to set homes
children:
homebukkit.set.self: true
homebukkit.set.other: true
homebukkit.set.self:
description: Allows the player to set their own home
homebukkit.set.other:
description: Allows the player to set other peoples homes
homebukkit.list:
description: Allows the player to list theirs and other players homes
children:
homebukkit.list.self:true
homebukkit.list.other:true
homebukkit.list.self:
description: Allows the player to list their homes
homebukkit.list.other:
description: Allows the player to list others homes
homebukkit.home:
description: allows the player to teleport to his/others homes
chidren:
homebukkit.set.self:true
homebukkit.set.other:true
homebukkit.home.self:
description: Allows the player to teleport to their home
homebukkit.home.other:
description: Allows the player to teleport to other players home

homebukkit.*:
description: Gives all permissions for HomeBukkit
default: op
children:
homebukkit.set: true
homebukkit.list: true
homebukkit.home: true