use of org.cubeengine.libcube.service.command.exception.PermissionDeniedException in project modules-extra by CubeEngine.
the class AuthCommands method clearPassword.
@Command(alias = "clearpw", desc = "Clears your password.")
public void clearPassword(CommandSource context, @Optional @Desc("* or a list of Players delimited by ,") PlayerList players) {
if (players == null) {
if (!(context instanceof Player)) {
throw new TooFewArgumentsException();
}
module.resetPassword(((Player) context).getUniqueId());
i18n.send(context, POSITIVE, "Your password has been reset!");
return;
}
if (players.isAll()) {
if (!context.hasPermission(module.perms().COMMAND_CLEARPASSWORD_ALL.getId())) {
throw new PermissionDeniedException(module.perms().COMMAND_CLEARPASSWORD_ALL);
}
module.resetAllPasswords();
i18n.send(context, POSITIVE, "All passwords reset!");
return;
}
if (!context.hasPermission(module.perms().COMMAND_CLEARPASSWORD_OTHER.getId())) {
throw new PermissionDeniedException(module.perms().COMMAND_CLEARPASSWORD_OTHER);
}
for (Player user : players.list()) {
module.resetPassword(user.getUniqueId());
i18n.send(context, POSITIVE, "{user}'s password has been reset!", user.getName());
}
}
use of org.cubeengine.libcube.service.command.exception.PermissionDeniedException in project modules-extra by CubeEngine.
the class MarketSignManager method setSign.
public void setSign(Location<World> loc, Player player) {
if (activeSigns.values().contains(loc)) {
i18n.send(ACTION_BAR, player, NEGATIVE, "Someone else is editing this sign!");
return;
}
MarketSignData data = loc.get(MarketSignData.class).get();
if (data.isAdminOwner()) {
if (!player.hasPermission(module.perms().EDIT_ADMIN.getId())) {
throw new PermissionDeniedException(module.perms().EDIT_ADMIN);
}
} else {
if (data.isOwner(player.getUniqueId())) {
if (!player.hasPermission(module.perms().EDIT_PLAYER_SELF.getId())) {
throw new PermissionDeniedException(module.perms().EDIT_PLAYER_SELF);
}
} else {
if (!player.hasPermission(module.perms().EDIT_PLAYER_OTHER.getId())) {
throw new PermissionDeniedException(module.perms().EDIT_PLAYER_OTHER);
}
}
}
Location<World> last = activeSigns.put(player.getUniqueId(), loc);
if (last != null) {
ImmutableMarketSignData prevData = last.get(MarketSignData.class).map(MarketSignData::asImmutable).orElse(previousSign.get(player.getUniqueId()));
previousSign.put(player.getUniqueId(), prevData);
updateSignText(prevData.asMutable(), last);
}
updateSignText(loc.get(MarketSignData.class).get(), loc);
i18n.send(ACTION_BAR, player, POSITIVE, "Changed active sign!");
}
use of org.cubeengine.libcube.service.command.exception.PermissionDeniedException in project modules-extra by CubeEngine.
the class EditModeCommand method copy.
@Restricted(Player.class)
@Command(desc = "Copies the settings from the previous sign")
public void copy(Player context) {
ImmutableMarketSignData data = manager.getPreviousData(context);
if (data == null) {
i18n.send(context, NEGATIVE, "No previous market sign");
return;
}
if (data.getOwner().equals(IMarketSignData.ADMIN_SIGN)) {
if (!context.hasPermission(module.perms().EDIT_ADMIN.getId())) {
throw new PermissionDeniedException(module.perms().EDIT_ADMIN);
}
} else {
if (!context.hasPermission(module.perms().EDIT_USE.getId())) {
throw new PermissionDeniedException(module.perms().EDIT_USE);
}
}
MarketSignData copy = data.asMutable();
if (!copy.isAdminOwner()) {
copy.setStock(0);
}
Location<World> loc = manager.updateData(copy, context);
manager.executeShowInfo(copy, context, loc);
}
use of org.cubeengine.libcube.service.command.exception.PermissionDeniedException in project modules-extra by CubeEngine.
the class EditModeCommand method player.
@Command(desc = "Changes the sign to an player-sign")
public void player(Player context) {
if (!context.hasPermission(module.perms().EDIT_PLAYER_SELF.getId())) {
throw new PermissionDeniedException(module.perms().EDIT_PLAYER_SELF);
}
MarketSignData data = manager.getCurrentData(context);
if (data == null) {
i18n.send(context, NEGATIVE, "No active sign!");
return;
}
if (data.isAdminOwner()) {
data.setSize(6);
}
data.setOwner(context.getUniqueId());
data.setStock(0);
Location<World> loc = manager.updateData(data, context);
manager.executeShowInfo(data, context, loc);
}
use of org.cubeengine.libcube.service.command.exception.PermissionDeniedException in project modules-extra by CubeEngine.
the class EditModeCommand method owner.
@Command(desc = "Changes the signs owner")
public void owner(Player context, User owner) {
if (!context.equals(owner)) {
if (!context.hasPermission(module.perms().EDIT_PLAYER_OTHER.getId())) {
throw new PermissionDeniedException(module.perms().EDIT_PLAYER_OTHER);
}
} else {
if (!context.hasPermission(module.perms().EDIT_PLAYER_SELF.getId())) {
throw new PermissionDeniedException(module.perms().EDIT_PLAYER_SELF);
}
}
MarketSignData data = manager.getCurrentData(context);
if (data == null) {
i18n.send(context, NEGATIVE, "No active sign!");
return;
}
data.setOwner(owner.getUniqueId());
Location<World> loc = manager.updateData(data, context);
manager.executeShowInfo(data, context, loc);
}
Aggregations