Skip to content

Commit

Permalink
Grant perms
Browse files Browse the repository at this point in the history
  • Loading branch information
xdnw committed Feb 28, 2025
1 parent bfa834d commit 8881724
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public String grantCity(
"Escrow",
"Policy/Project cost reduction"
})
@RolePermission(Roles.ECON)
@RolePermission(Roles.MEMBER)
@IsAlliance
public String grantProject(
@Me IMessageIO io, @Me GuildDB db, @Me DBNation me, @Me User author,
Expand Down Expand Up @@ -177,6 +177,9 @@ public String grantProject(
@Switch("b") boolean bypass_checks,
@Switch("f") boolean force
) throws IOException, GeneralSecurityException {
if (!Roles.ECON.has(author, db.getGuild()) && (force || receivers.size() > 1 || receivers.iterator().next().getId() != me.getId())) {
throw new IllegalArgumentException("Missing role: " + Roles.ECON.toDiscordRoleNameElseInstructions(db.getGuild()));
}
return Grant.generateCommandLogic(io, db, me, author, receivers, onlySendMissingFunds, depositsAccount, useAllianceBank, useOffshoreAccount, taxAccount, existingTaxAccount, expire, decay, ignore, convertToMoney, escrow_mode, bypass_checks, ping_role, ping_when_sent, force,
(receiver, grant) -> {
if (receiver.hasProject(project)) {
Expand All @@ -202,7 +205,7 @@ public String grantProject(
"Escrow",
"Policy/Project cost reduction"
})
@RolePermission(Roles.ECON)
@RolePermission(Roles.MEMBER)
@IsAlliance
public String grantInfra(
@Me IMessageIO io, @Me GuildDB db, @Me DBNation me, @Me User author,
Expand Down Expand Up @@ -237,6 +240,9 @@ public String grantInfra(
@Switch("f") boolean force

) throws IOException, GeneralSecurityException {
if (!Roles.ECON.has(author, db.getGuild()) && (force || receivers.size() > 1 || receivers.iterator().next().getId() != me.getId())) {
throw new IllegalArgumentException("Missing role: " + Roles.ECON.toDiscordRoleNameElseInstructions(db.getGuild()));
}
return Grant.generateCommandLogic(io, db, me, author, receivers, onlySendMissingFunds, depositsAccount, useAllianceBank, useOffshoreAccount, taxAccount, existingTaxAccount, expire, decay, ignore, convertToMoney, escrow_mode, bypass_checks, ping_role, ping_when_sent, force,
(receiver, grant) -> {
double cost;
Expand Down Expand Up @@ -278,7 +284,7 @@ public String grantInfra(
"Escrow",
"Policy/Project cost reduction"
})
@RolePermission(Roles.ECON)
@RolePermission(Roles.MEMBER)
@IsAlliance
public String grantLand(
@Me IMessageIO io, @Me GuildDB db, @Me DBNation me, @Me User author,
Expand Down Expand Up @@ -310,6 +316,9 @@ public String grantLand(
@Switch("b") boolean bypass_checks,
@Switch("f") boolean force
) throws IOException, GeneralSecurityException {
if (!Roles.ECON.has(author, db.getGuild()) && (force || receivers.size() > 1 || receivers.iterator().next().getId() != me.getId())) {
throw new IllegalArgumentException("Missing role: " + Roles.ECON.toDiscordRoleNameElseInstructions(db.getGuild()));
}
return Grant.generateCommandLogic(io, db, me, author, receivers, onlySendMissingFunds, depositsAccount, useAllianceBank, useOffshoreAccount, taxAccount, existingTaxAccount, expire, decay, ignore, convertToMoney, escrow_mode, bypass_checks, ping_role, ping_when_sent, force,
(receiver, grant) -> {
double cost = receiver.getBuyLandCost(to_land,
Expand Down Expand Up @@ -340,7 +349,7 @@ public String grantLand(
"Note options",
"Escrow"
})
@RolePermission(Roles.ECON)
@RolePermission(Roles.MEMBER)
@IsAlliance
public String grantUnit(
@Me IMessageIO io, @Me GuildDB db, @Me DBNation me, @Me User author,
Expand All @@ -367,6 +376,9 @@ public String grantUnit(
@Switch("b") boolean bypass_checks,
@Switch("f") boolean force
) throws IOException, GeneralSecurityException {
if (!Roles.ECON.has(author, db.getGuild()) && (force || receivers.size() > 1 || receivers.iterator().next().getId() != me.getId())) {
throw new IllegalArgumentException("Missing role: " + Roles.ECON.toDiscordRoleNameElseInstructions(db.getGuild()));
}
return Grant.generateCommandLogic(io, db, me, author, receivers, onlySendMissingFunds, depositsAccount, useAllianceBank, useOffshoreAccount, taxAccount, existingTaxAccount, expire, decay, ignore, convertToMoney, escrow_mode, bypass_checks, ping_role, ping_when_sent, force,
(receiver, grant) -> {
Map<MilitaryUnit, Long> unitsToGrant = new HashMap<>();
Expand Down Expand Up @@ -401,7 +413,7 @@ public String grantUnit(
"Note options",
"Escrow",
})
@RolePermission(Roles.ECON)
@RolePermission(Roles.MEMBER)
@IsAlliance
public String grantMMR(
@Me IMessageIO io, @Me GuildDB db, @Me DBNation me, @Me User author,
Expand All @@ -426,6 +438,9 @@ public String grantMMR(
@Switch("b") boolean bypass_checks,
@Switch("f") boolean force
) throws IOException, GeneralSecurityException {
if (!Roles.ECON.has(author, db.getGuild()) && (force || receivers.size() > 1 || receivers.iterator().next().getId() != me.getId())) {
throw new IllegalArgumentException("Missing role: " + Roles.ECON.toDiscordRoleNameElseInstructions(db.getGuild()));
}
return Grant.generateCommandLogic(io, db, me, author, receivers, onlySendMissingFunds, depositsAccount, useAllianceBank, useOffshoreAccount, taxAccount, existingTaxAccount, expire, decay, ignore, convertToMoney, escrow_mode, bypass_checks, ping_role, ping_when_sent, force,
(receiver, grant) -> {
int cities = receiver.getCities();
Expand Down Expand Up @@ -463,7 +478,7 @@ public String grantMMR(
"Note options",
"Escrow"
})
@RolePermission(Roles.ECON)
@RolePermission(Roles.MEMBER)
@IsAlliance
public String grantConsumption(
@Me IMessageIO io, @Me GuildDB db, @Me DBNation me, @Me User author,
Expand Down Expand Up @@ -494,6 +509,9 @@ public String grantConsumption(
@Switch("b") boolean bypass_checks,
@Switch("f") boolean force
) throws IOException, GeneralSecurityException {
if (!Roles.ECON.has(author, db.getGuild()) && (force || receivers.size() > 1 || receivers.iterator().next().getId() != me.getId())) {
throw new IllegalArgumentException("Missing role: " + Roles.ECON.toDiscordRoleNameElseInstructions(db.getGuild()));
}
return Grant.generateCommandLogic(io, db, me, author, receivers, onlySendMissingFunds, depositsAccount, useAllianceBank, useOffshoreAccount, taxAccount, existingTaxAccount, expire, decay, ignore, convertToMoney, escrow_mode, bypass_checks, ping_role, ping_when_sent, force,
(receiver, grant) -> {
int cities = receiver.getCities();
Expand Down Expand Up @@ -541,7 +559,7 @@ public String grantConsumption(
"Note options",
"Escrow"
})
@RolePermission(Roles.ECON)
@RolePermission(Roles.MEMBER)
@IsAlliance
public String grantBuild(
@Me IMessageIO io, @Me GuildDB db, @Me DBNation me, @Me User author,
Expand Down Expand Up @@ -572,6 +590,9 @@ public String grantBuild(
@Switch("b") boolean bypass_checks,
@Switch("f") boolean force
) throws IOException, GeneralSecurityException {
if (!Roles.ECON.has(author, db.getGuild()) && (force || receivers.size() > 1 || receivers.iterator().next().getId() != me.getId())) {
throw new IllegalArgumentException("Missing role: " + Roles.ECON.toDiscordRoleNameElseInstructions(db.getGuild()));
}
if (city_ids != null) {
if (receivers.size() > 1) {
throw new IllegalArgumentException("Cannot specify `city_ids` and multiple receivers (max 1)");
Expand Down Expand Up @@ -659,7 +680,7 @@ public String grantBuild(
"Note options",
"Escrow"
})
@RolePermission(Roles.ECON)
@RolePermission(Roles.MEMBER)
@IsAlliance
public String grantWarchest(
@Me IMessageIO io, @Me GuildDB db, @Me DBNation me, @Me User author,
Expand All @@ -683,6 +704,9 @@ public String grantWarchest(
@Switch("b") boolean bypass_checks,
@Switch("f") boolean force
) throws IOException, GeneralSecurityException {
if (!Roles.ECON.has(author, db.getGuild()) && (force || receivers.size() > 1 || receivers.iterator().next().getId() != me.getId())) {
throw new IllegalArgumentException("Missing role: " + Roles.ECON.toDiscordRoleNameElseInstructions(db.getGuild()));
}
return Grant.generateCommandLogic(io, db, me, author, receivers, onlySendMissingFunds, depositsAccount, useAllianceBank, useOffshoreAccount, taxAccount, existingTaxAccount, expire, decay, ignore, convertToMoney, escrow_mode, bypass_checks, ping_role, ping_when_sent, force,
(receiver, grant) -> {
int cities = receiver.getCities();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static Map<OffshoreInstance.TransferStatus, Integer> count(Collection<Tra
}

public static String toFileString(Collection<TransferResult> list) {
return "Receiver\tStatus\nNote\nMessage" +
return "Receiver\tStatus\tNote\tMessage\n" +
list.stream().map(f ->
f.getReceiver().getName() + "\t" +
f.getStatus().name() + "\t" +
Expand Down

0 comments on commit 8881724

Please sign in to comment.