Fix default message loading, because default values are ignored by .getKeys()

This commit is contained in:
games647
2018-04-05 17:33:32 +02:00
parent 352c72df64
commit f476c091bb
7 changed files with 39 additions and 24 deletions

View File

@ -3,7 +3,7 @@
Checks if a Minecraft player has a paid account (premium). If so, they can skip offline authentication (auth plugins).
So they don't need to enter passwords. This is also called auto login (auto-login).
### Features:
## Features
* Detect paid accounts from others
* Automatically login paid accounts (premium)
@ -36,18 +36,21 @@ https://ci.codemc.org/job/Games647/job/FastLogin/changes
***
### Commands:
## Commands
/premium [player] Label the invoker or the argument as paid account
/cracked [player] Label the invoker or the argument as cracked account
### Permissions:
## Permissions
fastlogin.bukkit.command.premium
fastlogin.bukkit.command.cracked
fastlogin.command.premium.other
fastlogin.command.cracked.other
fastlogin.command.import
### Requirements:
## Requirements
* Plugin:
* [ProtocolLib](https://www.spigotmc.org/resources/protocollib.1997/) or
* [ProtocolSupport](https://www.spigotmc.org/resources/protocolsupport.7201/)
@ -56,7 +59,7 @@ https://ci.codemc.org/job/Games647/job/FastLogin/changes
* Run Spigot and/or BungeeCord/Waterfall in offline mode (see server.properties or config.yml)
* An auth plugin. Supported plugins
#### Bukkit/Spigot/Paper
### Bukkit/Spigot/Paper
* [AuthMe (5.X)](https://dev.bukkit.org/bukkit-plugins/authme-reloaded/)
* [xAuth](https://dev.bukkit.org/bukkit-plugins/xauth/)
@ -66,21 +69,21 @@ https://ci.codemc.org/job/Games647/job/FastLogin/changes
* [LoginSecurity](https://dev.bukkit.org/bukkit-plugins/loginsecurity/)
* [UltraAuth](https://dev.bukkit.org/bukkit-plugins/ultraauth-aa/)
#### BungeeCord/Waterfall
### BungeeCord/Waterfall
* [BungeeAuth](https://www.spigotmc.org/resources/bungeeauth.493/)
***
### How to install
## How to install
#### Bukkit/Spigot/Paper
### Bukkit/Spigot/Paper
1. Download and install ProtocolLib/ProtocolSupport
2. Download and install FastLogin (or FastLoginBukkit for newer versions)
3. Set your server in offline mode by setting the value onlinemode in your server.properties to false
#### BungeeCord/Waterfall
### BungeeCord/Waterfall
1. Activate BungeeCord in the Spigot configuration
2. Restart your server

View File

@ -130,7 +130,7 @@
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.8.4</version>
<version>2.8.5</version>
<scope>provided</scope>
<optional>true</optional>
<exclusions>

View File

@ -1,6 +1,6 @@
package com.github.games647.fastlogin.bukkit;
import com.github.games647.craftapi.model.skin.SkinProperty;
import com.github.games647.craftapi.model.skin.Property;
import com.github.games647.fastlogin.core.StoredProfile;
import com.github.games647.fastlogin.core.shared.LoginSession;
@ -20,7 +20,7 @@ public class BukkitLoginSession extends LoginSession {
private boolean verified;
private SkinProperty skinProperty;
private Property skinProperty;
public BukkitLoginSession(String username, String serverId, byte[] verifyToken, boolean registered
, StoredProfile profile) {
@ -54,7 +54,7 @@ public class BukkitLoginSession extends LoginSession {
/**
* @return premium skin if available
*/
public synchronized Optional<SkinProperty> getSkin() {
public synchronized Optional<Property> getSkin() {
return Optional.ofNullable(skinProperty);
}
@ -62,7 +62,7 @@ public class BukkitLoginSession extends LoginSession {
* Sets the premium skin property which was retrieved by the session server
* @param skinProperty premium skin
*/
public synchronized void setSkinProperty(SkinProperty skinProperty) {
public synchronized void setSkinProperty(Property skinProperty) {
this.skinProperty = skinProperty;
}

View File

@ -6,7 +6,7 @@ import com.comphenix.protocol.reflect.accessors.MethodAccessor;
import com.comphenix.protocol.utility.MinecraftReflection;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
import com.comphenix.protocol.wrappers.WrappedSignedProperty;
import com.github.games647.craftapi.model.skin.SkinProperty;
import com.github.games647.craftapi.model.skin.Property;
import com.github.games647.fastlogin.bukkit.BukkitLoginSession;
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
@ -54,14 +54,14 @@ public class SkinApplyListener implements Listener {
private void applySkin(Player player, String skinData, String signature) {
WrappedGameProfile gameProfile = WrappedGameProfile.fromPlayer(player);
WrappedSignedProperty skin = WrappedSignedProperty.fromValues(SkinProperty.TEXTURE_KEY, skinData, signature);
WrappedSignedProperty skin = WrappedSignedProperty.fromValues(Property.TEXTURE_KEY, skinData, signature);
try {
gameProfile.getProperties().put(SkinProperty.TEXTURE_KEY, skin);
gameProfile.getProperties().put(Property.TEXTURE_KEY, skin);
} catch (ClassCastException castException) {
//Cauldron, MCPC, Thermos, ...
Object map = GET_PROPERTIES.invoke(gameProfile.getHandle());
try {
MethodUtils.invokeMethod(map, "put", new Object[]{SkinProperty.TEXTURE_KEY, skin.getHandle()});
MethodUtils.invokeMethod(map, "put", new Object[]{Property.TEXTURE_KEY, skin.getHandle()});
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
plugin.getLog().error("Error setting premium skin of: {}", player, ex);
}

View File

@ -9,7 +9,7 @@ import com.comphenix.protocol.reflect.FuzzyReflection;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
import com.github.games647.craftapi.model.auth.Verification;
import com.github.games647.craftapi.model.skin.SkinProperty;
import com.github.games647.craftapi.model.skin.Property;
import com.github.games647.craftapi.resolver.MojangResolver;
import com.github.games647.fastlogin.bukkit.BukkitLoginSession;
import com.github.games647.fastlogin.bukkit.EncryptionUtil;
@ -108,7 +108,7 @@ public class VerifyResponseTask implements Runnable {
if (response.isPresent()) {
plugin.getLog().info("GameProfile {} has a verified premium account", username);
SkinProperty[] properties = response.get().getProperties();
Property[] properties = response.get().getProperties();
if (properties.length > 0) {
session.setSkinProperty(properties[0]);
}

View File

@ -33,7 +33,7 @@
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.7.8</version>
<version>3.0.0</version>
</dependency>
<!--Logging framework implements slf4j which is required by hikari-->

View File

@ -11,6 +11,7 @@ import com.google.common.net.HostAndPort;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Proxy;
@ -103,15 +104,26 @@ public class FastLoginCore<P extends C, C, T extends PlatformPlugin<C>> {
}
private Configuration loadFile(String fileName) throws IOException {
Configuration defaults;
ConfigurationProvider configProvider = ConfigurationProvider.getProvider(YamlConfiguration.class);
Configuration defaults;
try (InputStream defaultStream = getClass().getClassLoader().getResourceAsStream(fileName)) {
defaults = configProvider.load(defaultStream);
}
Path file = plugin.getPluginFolder().resolve(fileName);
return configProvider.load(Files.newBufferedReader(file), defaults);
Configuration config;
try (Reader reader = Files.newBufferedReader(file)) {
config = configProvider.load(reader);
}
//explicitly add keys here, because Configuration.getKeys doesn't return the keys from the default configuration
for (String key : defaults.getKeys()) {
config.set(key, defaults.get(key));
}
return config;
}
public MojangResolver getResolver() {