kiafumi/src/main/java/moe/oko/Kiafumi/model/Server.java

71 lines
2.2 KiB
Java
Raw Normal View History

2022-03-24 04:10:50 +00:00
package moe.oko.Kiafumi.model;
2022-03-26 05:04:24 +00:00
import javax.annotation.Nullable;
2022-03-24 04:28:51 +00:00
/**
* Server Class
* Used for in-memory data storage. Loaded from Database later.
*/
2022-03-24 04:10:50 +00:00
public class Server {
//Guild ID
2022-03-24 04:10:50 +00:00
private String id;
//Whether the welcome feature is enabled (Join/Leave Logs)
2022-03-24 04:10:50 +00:00
private boolean welcomeEnabled;
//If enabled, the channel for logs to be posted to.
2022-03-24 04:10:50 +00:00
private String welcomeChannel;
//The role to be assigned on join, if null ignored.
2022-03-26 05:04:24 +00:00
private String joinRole;
//TODO Whether the server has protections enabled
2022-03-26 05:04:24 +00:00
private boolean serverProtected;
//If the server has been modified in memory, for saving persistently.
private boolean modified;
/**
* Default constructor, used for new servers
* @param id - the guild id to have server constructed for.
*/
2022-03-26 05:04:24 +00:00
public Server(String id) {
this.id = id;
this.welcomeEnabled = false;
this.welcomeChannel = null;
this.joinRole = null;
this.serverProtected = false;
this.modified = false;
2022-03-26 05:04:24 +00:00
}
/**
* Database Constructor
* @param id - id of the server
* @param welcomeEnabled - is welcome enabled for the server
* @param welcomeChannel - channel for welcome messages, if enabled
* @param serverProtected - is the server under protection rules. (/archive, /stop, etc.)
*/
public Server(String id, boolean welcomeEnabled, @Nullable String welcomeChannel, @Nullable String joinRole, boolean serverProtected) {
this.id = id;
this.welcomeEnabled = welcomeEnabled;
this.welcomeChannel = welcomeChannel;
this.joinRole = joinRole;
this.serverProtected = serverProtected;
this.modified = false;
}
/**
* @return - the guild id the server is assigned to
*/
public String getId() { return id; }
/**
* Checks the modification of the server file in memory
* @return - whether the server settings have been modified
*/
public boolean isModified() {
return modified;
2022-03-26 05:04:24 +00:00
}
@Override
public String toString() {
return "Server{id=" + this.id + ",welcomeEnabled=" + welcomeEnabled + ",welcomeChannel="+welcomeChannel+
",joinrole=" + joinRole +",serverProtected="+serverProtected+"}";
}
2022-03-24 04:10:50 +00:00
}