Add loading for EssentiaUserSettings
This commit is contained in:
parent
fe83919200
commit
cf0bcefd06
|
|
@ -2,6 +2,7 @@ package com.alttd.essentia.model;
|
||||||
|
|
||||||
import com.alttd.essentia.api.model.UserSettings;
|
import com.alttd.essentia.api.model.UserSettings;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class EssentiaUserSettings implements UserSettings {
|
public class EssentiaUserSettings implements UserSettings {
|
||||||
|
|
@ -16,6 +17,16 @@ public class EssentiaUserSettings implements UserSettings {
|
||||||
|
|
||||||
private boolean needsSaving;
|
private boolean needsSaving;
|
||||||
|
|
||||||
|
private EssentiaUserSettings(Builder builder) {
|
||||||
|
this.godMode = builder.godMode;;
|
||||||
|
this.flying = builder.flying;
|
||||||
|
this.flySpeed = builder.flySpeed;
|
||||||
|
this.walkSpeed = builder.walkSpeed;
|
||||||
|
this.pTime = builder.pTime;
|
||||||
|
this.pWeather = builder.pWeather;
|
||||||
|
this.allowTeleports = builder.allowTeleports;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void godMode(boolean godMode) {
|
public void godMode(boolean godMode) {
|
||||||
this.godMode = godMode;
|
this.godMode = godMode;
|
||||||
|
|
@ -33,4 +44,22 @@ public class EssentiaUserSettings implements UserSettings {
|
||||||
this.flying = flying;
|
this.flying = flying;
|
||||||
this.needsSaving = true;
|
this.needsSaving = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
public static class Builder {
|
||||||
|
|
||||||
|
// TODO - defaults?
|
||||||
|
protected boolean godMode;
|
||||||
|
protected boolean flying;
|
||||||
|
protected double flySpeed;
|
||||||
|
protected double walkSpeed;
|
||||||
|
protected boolean pTime;
|
||||||
|
protected boolean pWeather;
|
||||||
|
protected boolean allowTeleports;
|
||||||
|
|
||||||
|
public EssentiaUserSettings build() {
|
||||||
|
return new EssentiaUserSettings(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.alttd.essentia.EssentiaPlugin;
|
||||||
import com.alttd.essentia.configuration.Config;
|
import com.alttd.essentia.configuration.Config;
|
||||||
import com.alttd.essentia.api.model.Home;
|
import com.alttd.essentia.api.model.Home;
|
||||||
import com.alttd.essentia.model.EssentiaHome;
|
import com.alttd.essentia.model.EssentiaHome;
|
||||||
|
import com.alttd.essentia.model.EssentiaUserSettings;
|
||||||
import com.alttd.essentia.storage.StorageProvider;
|
import com.alttd.essentia.storage.StorageProvider;
|
||||||
import com.alttd.essentia.user.EssentiaUser;
|
import com.alttd.essentia.user.EssentiaUser;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
@ -137,7 +138,10 @@ public class SQLStorageProvider extends StorageProvider {
|
||||||
.backLocation(locationStringToLocation(resultSet.getString("BackLocation")))
|
.backLocation(locationStringToLocation(resultSet.getString("BackLocation")))
|
||||||
.deathLocation(locationStringToLocation(resultSet.getString("DeathLocation")))
|
.deathLocation(locationStringToLocation(resultSet.getString("DeathLocation")))
|
||||||
.homes(locationMapStringToLocationMap(resultSet.getString("locationMapToString")))
|
.homes(locationMapStringToLocationMap(resultSet.getString("locationMapToString")))
|
||||||
.allowTeleports(resultSet.getBoolean("TeleportToggled"))
|
.userSettings(new EssentiaUserSettings
|
||||||
|
.Builder()
|
||||||
|
//.allowTeleports(resultSet.getBoolean("TeleportToggled")) // FIXME
|
||||||
|
.build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.alttd.essentia.storage.yaml;
|
||||||
import com.alttd.essentia.EssentiaPlugin;
|
import com.alttd.essentia.EssentiaPlugin;
|
||||||
import com.alttd.essentia.api.model.Home;
|
import com.alttd.essentia.api.model.Home;
|
||||||
import com.alttd.essentia.model.EssentiaHome;
|
import com.alttd.essentia.model.EssentiaHome;
|
||||||
|
import com.alttd.essentia.model.EssentiaUserSettings;
|
||||||
import com.alttd.essentia.storage.StorageProvider;
|
import com.alttd.essentia.storage.StorageProvider;
|
||||||
import com.alttd.essentia.user.EssentiaUser;
|
import com.alttd.essentia.user.EssentiaUser;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
@ -38,7 +39,10 @@ public class YamlStorageProvider extends StorageProvider {
|
||||||
.backLocation(getStoredLocation(config,"teleports.back"))
|
.backLocation(getStoredLocation(config,"teleports.back"))
|
||||||
.deathLocation(getStoredLocation(config,"teleports.death"))
|
.deathLocation(getStoredLocation(config,"teleports.death"))
|
||||||
.homes(getHomeData(config))
|
.homes(getHomeData(config))
|
||||||
.allowTeleports(config.getBoolean("allow-teleports", true))
|
.userSettings(new EssentiaUserSettings
|
||||||
|
.Builder()
|
||||||
|
.allowTeleports(config.getBoolean("allow-teleports", true))
|
||||||
|
.build())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import com.alttd.essentia.api.model.UserSettings;
|
||||||
import com.alttd.essentia.api.request.Request;
|
import com.alttd.essentia.api.request.Request;
|
||||||
import com.alttd.essentia.api.user.User;
|
import com.alttd.essentia.api.user.User;
|
||||||
import com.alttd.essentia.model.EssentiaHome;
|
import com.alttd.essentia.model.EssentiaHome;
|
||||||
import com.alttd.essentia.model.EssentiaUserSettings;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
@ -133,7 +132,7 @@ public class EssentiaUser implements User {
|
||||||
protected Location backLocation = null;
|
protected Location backLocation = null;
|
||||||
protected Location deathLocation = null;
|
protected Location deathLocation = null;
|
||||||
protected Map<String, Home> homes = new HashMap<>();
|
protected Map<String, Home> homes = new HashMap<>();
|
||||||
protected EssentiaUserSettings userSettings = new EssentiaUserSettings();
|
protected UserSettings userSettings = null;
|
||||||
|
|
||||||
public Builder uuid(UUID uuid) {
|
public Builder uuid(UUID uuid) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
|
|
@ -155,8 +154,8 @@ public class EssentiaUser implements User {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder allowTeleports(boolean allowTeleports) {
|
public Builder userSettings(UserSettings userSettings) {
|
||||||
this.userSettings.allowTeleports(allowTeleports);
|
this.userSettings = userSettings;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user