Commons/src/main/java/eu/univento/commons/player/settings/PlayerSettings.java

142 lines
3.2 KiB
Java
Raw Normal View History

2016-08-02 23:53:40 +02:00
package eu.univento.commons.player.settings;
import eu.univento.commons.player.DatabasePlayer;
2017-04-07 17:10:36 +02:00
import io.vertx.core.json.JsonObject;
2016-08-02 23:53:40 +02:00
/**
* @author joethei
2017-04-07 17:10:36 +02:00
* @version 1.1
2016-08-02 23:53:40 +02:00
*/
public class PlayerSettings {
private DatabasePlayer player;
2017-04-07 17:10:36 +02:00
private JsonObject json;
2016-08-02 23:53:40 +02:00
2017-04-07 17:10:36 +02:00
public PlayerSettings(DatabasePlayer player, JsonObject json) {
2016-08-02 23:53:40 +02:00
this.player = player;
2017-04-07 17:10:36 +02:00
this.json = json;
2016-08-02 23:53:40 +02:00
}
public String getPlayerVisibility() {
2017-04-07 17:10:36 +02:00
return json.getString("playerVisibility");
2016-08-02 23:53:40 +02:00
}
public boolean hasInventoryAnimationEnabled() {
2017-04-07 17:10:36 +02:00
return json.getBoolean("inventoryAnimation");
2016-08-02 23:53:40 +02:00
}
public boolean hasTeleportAnimationEnabled() {
2017-04-07 17:10:36 +02:00
return json.getBoolean("teleportAnimation");
2016-08-02 23:53:40 +02:00
}
public boolean hasPartyRequestsEnabled() {
2017-04-07 17:10:36 +02:00
return json.getBoolean("partyRequests");
2016-08-02 23:53:40 +02:00
}
public boolean hasFriendRequestsEnabled() {
2017-04-07 17:10:36 +02:00
return json.getBoolean("friendRequests");
2016-08-02 23:53:40 +02:00
}
public boolean hasFriendJumpEnabled() {
2017-04-07 17:10:36 +02:00
return json.getBoolean("friendJump");
2016-08-02 23:53:40 +02:00
}
public boolean hasChatSoundsEnabled() {
2017-04-07 17:10:36 +02:00
return json.getBoolean("chatSounds");
2016-08-02 23:53:40 +02:00
}
public boolean hasEffectsEnabled() {
2017-04-07 17:10:36 +02:00
return json.getBoolean("effects");
2016-08-02 23:53:40 +02:00
}
public boolean hasStoryModeEnabled() {
2017-04-07 17:10:36 +02:00
return json.getBoolean("storyMode");
2016-08-02 23:53:40 +02:00
}
public String getLanguage() {
2017-04-07 17:10:36 +02:00
return json.getString("language");
2016-08-02 23:53:40 +02:00
}
public boolean hasTsMoveEnabled() {
2017-04-07 17:10:36 +02:00
return json.getBoolean("tsMove");
2016-08-02 23:53:40 +02:00
}
public boolean hasScoreboardEnabled() {
2017-04-07 17:10:36 +02:00
return json.getBoolean("scoreboard");
}
public boolean isNicked() {
return json.getBoolean("nicked");
2016-08-02 23:53:40 +02:00
}
public void setPlayerVisibility(String visibility) {
2017-04-07 17:10:36 +02:00
json.put("playerVisibility", visibility);
update();
2016-08-02 23:53:40 +02:00
}
public void setInventoryAnimation(boolean animation) {
2017-04-07 17:10:36 +02:00
json.put("inventoryAnimation", animation);
update();
2016-08-02 23:53:40 +02:00
}
public void setTeleportAnimation(boolean animation) {
2017-04-07 17:10:36 +02:00
json.put("teleportAnimation", animation);
update();
2016-08-02 23:53:40 +02:00
}
public void setPartyRequests(boolean requests) {
2017-04-07 17:10:36 +02:00
json.put("partyRequests", requests);
update();
2016-08-02 23:53:40 +02:00
}
public void setFriendRequests(boolean requests) {
2017-04-07 17:10:36 +02:00
json.put("friendRequests", requests);
update();
2016-08-02 23:53:40 +02:00
}
public void setFriendJump(boolean jump) {
2017-04-07 17:10:36 +02:00
json.put("friendJump", jump);
update();
2016-08-02 23:53:40 +02:00
}
public void setChatSounds(boolean sounds) {
2017-04-07 17:10:36 +02:00
json.put("chatSounds", sounds);
update();
2016-08-02 23:53:40 +02:00
}
public void setEffects(boolean effects) {
2017-04-07 17:10:36 +02:00
json.put("effects", effects);
update();
2016-08-02 23:53:40 +02:00
}
public void setStoryMode(boolean storyMode) {
2017-04-07 17:10:36 +02:00
json.put("storyMode", storyMode);
update();
2016-08-02 23:53:40 +02:00
}
public void setLanguage(String language) {
2017-04-07 17:10:36 +02:00
json.put("language", language);
update();
2016-08-02 23:53:40 +02:00
}
public void setTsMove(boolean tsMove) {
2017-04-07 17:10:36 +02:00
json.put("tsMove", tsMove);
update();
2016-08-02 23:53:40 +02:00
}
public void setScoreboard(boolean scoreboard) {
2017-04-07 17:10:36 +02:00
json.put("scoreboard", scoreboard);
update();
2016-08-02 23:53:40 +02:00
}
public void setNickStatus(boolean nicked) {
2017-04-07 17:10:36 +02:00
json.put("nicked", nicked);update();
update();
2016-08-02 23:53:40 +02:00
}
2017-04-07 17:10:36 +02:00
private void update() {
player.setInDatabase("Settings", json);
2016-08-02 23:53:40 +02:00
}
}