Add optional owner snowflake & name to licenses
This commit is contained in:
parent
7276615298
commit
2685bed581
@ -39,6 +39,22 @@ public class License {
|
|||||||
*/
|
*/
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Discord snowflake of the owner of this license.
|
||||||
|
* <p>
|
||||||
|
* If this is -1, the license is not owned by anyone.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
private long ownerSnowflake;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Discord name of the owner of this license.
|
||||||
|
* <p>
|
||||||
|
* If this is null, the license is not owned by anyone.
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
private String ownerName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The amount of uses this license has.
|
* The amount of uses this license has.
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package me.braydon.license.service;
|
package me.braydon.license.service;
|
||||||
|
|
||||||
import jakarta.annotation.PostConstruct;
|
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import me.braydon.license.common.MiscUtils;
|
import me.braydon.license.common.MiscUtils;
|
||||||
@ -54,37 +53,29 @@ public final class LicenseService {
|
|||||||
this.discordService = discordService;
|
this.discordService = discordService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostConstruct
|
|
||||||
public void onInitialize() {
|
|
||||||
// TODO: remove this and make it either
|
|
||||||
// a test, or a route to gen a license
|
|
||||||
|
|
||||||
// String key = RandomUtils.generateLicenseKey();
|
|
||||||
// log.info(create(key,
|
|
||||||
// "CloudSpigot",
|
|
||||||
// "Testing " + Math.random(), Integer.MAX_VALUE, Integer.MAX_VALUE).toString());
|
|
||||||
// System.out.println("key = " + key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new license key.
|
* Create a new license key.
|
||||||
*
|
*
|
||||||
* @param key the key of the license
|
* @param key the key of the license
|
||||||
* @param product the product the license is for
|
* @param product the product the license is for
|
||||||
* @param description the optional description of the license
|
* @param description the optional description of the license
|
||||||
* @param ipLimit the IP limit of the license
|
* @param ownerSnowflake the optional owner snowflake of the license
|
||||||
* @param hwidLimit the HWID limit of the license
|
* @param ownerName the optional owner name of the license
|
||||||
* @param duration the duration of the license, -1 for permanent
|
* @param ipLimit the IP limit of the license
|
||||||
|
* @param hwidLimit the HWID limit of the license
|
||||||
|
* @param duration the duration of the license, -1 for permanent
|
||||||
* @return the created license
|
* @return the created license
|
||||||
* @see License for license
|
* @see License for license
|
||||||
*/
|
*/
|
||||||
public License create(@NonNull String key, @NonNull String product, String description,
|
public License create(@NonNull String key, @NonNull String product, String description, long ownerSnowflake,
|
||||||
int ipLimit, int hwidLimit, long duration) {
|
String ownerName, int ipLimit, int hwidLimit, long duration) {
|
||||||
// Create the new license
|
// Create the new license
|
||||||
License license = new License();
|
License license = new License();
|
||||||
license.setKey(BCrypt.hashpw(key, licensesSalt)); // Hash the key
|
license.setKey(BCrypt.hashpw(key, licensesSalt)); // Hash the key
|
||||||
license.setProduct(product); // Use the given product
|
license.setProduct(product); // Use the given product
|
||||||
license.setDescription(description); // Use the given description, if any
|
license.setDescription(description); // Use the given description, if any
|
||||||
|
license.setOwnerSnowflake(ownerSnowflake);
|
||||||
|
license.setOwnerName(ownerName);
|
||||||
license.setIps(new HashSet<>());
|
license.setIps(new HashSet<>());
|
||||||
license.setHwids(new HashSet<>());
|
license.setHwids(new HashSet<>());
|
||||||
license.setIpLimit(ipLimit); // Use the given IP limit
|
license.setIpLimit(ipLimit); // Use the given IP limit
|
||||||
@ -136,7 +127,11 @@ public final class LicenseService {
|
|||||||
true
|
true
|
||||||
)
|
)
|
||||||
.addField("Owner ID",
|
.addField("Owner ID",
|
||||||
"504147739131641857",
|
license.getOwnerSnowflake() <= 0L ? "N/A" : String.valueOf(license.getOwnerSnowflake()),
|
||||||
|
true
|
||||||
|
)
|
||||||
|
.addField("Owner Name",
|
||||||
|
license.getOwnerName() == null ? "N/A" : license.getOwnerName(),
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
.addField("Expires",
|
.addField("Expires",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user