mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-12-01 15:04:09 +01:00
Now saving the Locale in the new config
This commit is contained in:
parent
322acbc636
commit
7031e9e58b
@ -298,7 +298,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag
|
||||
// Setup & Load our Configuration files.
|
||||
loadConfigs();
|
||||
try {
|
||||
this.messageProvider.setLocale(new Locale(multiverseConfig.getString("locale", "en")));
|
||||
this.messageProvider.setLocale(this.config.getLocale());
|
||||
} catch (IllegalArgumentException e) {
|
||||
this.log(Level.SEVERE, e.getMessage());
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
|
@ -1,10 +1,12 @@
|
||||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
|
||||
import com.onarandombox.MultiverseCore.configuration.LocaleSerializor;
|
||||
|
||||
import me.main__.util.SerializationConfig.NoSuchPropertyException;
|
||||
import me.main__.util.SerializationConfig.Property;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@ -60,6 +62,8 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
private volatile String firstspawnworld;
|
||||
@Property
|
||||
private volatile int teleportcooldown;
|
||||
@Property(serializor = LocaleSerializor.class)
|
||||
private volatile Locale locale;
|
||||
|
||||
public MultiverseCoreConfiguration() {
|
||||
super();
|
||||
@ -273,4 +277,14 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
||||
public boolean getUseAsyncChat() {
|
||||
return this.useasyncchat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocale(Locale locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.onarandombox.MultiverseCore.api;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
|
||||
/**
|
||||
@ -145,4 +147,16 @@ public interface MultiverseCoreConfig extends ConfigurationSerializable {
|
||||
* @return useasyncchat.
|
||||
*/
|
||||
boolean getUseAsyncChat();
|
||||
|
||||
/**
|
||||
* Sets the locale.
|
||||
* @param locale The new value.
|
||||
*/
|
||||
void setLocale(Locale locale);
|
||||
|
||||
/**
|
||||
* Gets the locale.
|
||||
* @return locale
|
||||
*/
|
||||
Locale getLocale();
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
package com.onarandombox.MultiverseCore.configuration;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import me.main__.util.SerializationConfig.IllegalPropertyValueException;
|
||||
import me.main__.util.SerializationConfig.Serializor;
|
||||
|
||||
public class LocaleSerializor implements Serializor<Locale, String> {
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Locale deserialize(String arg0, Class<Locale> arg1) throws IllegalPropertyValueException {
|
||||
return new Locale(arg0);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public String serialize(Locale arg0) {
|
||||
return arg0.getLanguage();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user