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 {
|
2022-03-28 05:42:03 +00:00
|
|
|
//Guild ID
|
2022-03-24 04:10:50 +00:00
|
|
|
private String id;
|
2022-03-28 05:42:03 +00:00
|
|
|
//Whether the welcome feature is enabled (Join/Leave Logs)
|
2022-03-24 04:10:50 +00:00
|
|
|
private boolean welcomeEnabled;
|
2022-03-28 05:42:03 +00:00
|
|
|
//If enabled, the channel for logs to be posted to.
|
2022-03-24 04:10:50 +00:00
|
|
|
private String welcomeChannel;
|
2022-03-28 05:42:03 +00:00
|
|
|
//The role to be assigned on join, if null ignored.
|
2022-03-26 05:04:24 +00:00
|
|
|
private String joinRole;
|
2022-03-28 05:42:03 +00:00
|
|
|
//TODO Whether the server has protections enabled
|
2022-03-26 05:04:24 +00:00
|
|
|
private boolean serverProtected;
|
2022-03-28 05:42:03 +00:00
|
|
|
//If the server has been modified in memory, for saving persistently.
|
2022-03-27 05:53:00 +00:00
|
|
|
private boolean modified;
|
|
|
|
|
2022-03-28 05:42:03 +00:00
|
|
|
/**
|
|
|
|
* 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;
|
2022-03-27 05:53:00 +00:00
|
|
|
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;
|
2022-03-27 05:53:00 +00:00
|
|
|
this.modified = false;
|
|
|
|
}
|
|
|
|
|
2022-03-28 05:42:03 +00:00
|
|
|
/**
|
|
|
|
* @return - the guild id the server is assigned to
|
|
|
|
*/
|
2022-03-27 05:53:00 +00:00
|
|
|
public String getId() { return id; }
|
|
|
|
|
2022-03-28 05:42:03 +00:00
|
|
|
/**
|
|
|
|
* Checks the modification of the server file in memory
|
|
|
|
* @return - whether the server settings have been modified
|
|
|
|
*/
|
2022-03-27 05:53:00 +00:00
|
|
|
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
|
|
|
}
|