Archived
We made it to release 1.0
This commit is contained in:
@@ -7,6 +7,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -29,11 +30,16 @@ public class ConfigController {
|
||||
|
||||
public void savePlayers(){
|
||||
for (PlayerData player : plugin.db.playerList) {
|
||||
customConfig.set("data."+player.getUuid()+".playtime", player.getPlaytime());
|
||||
customConfig.set("data."+player.getUuid()+".displayName", player.getDisplayName());
|
||||
customConfig.set("data."+player.getUuid()+".lastLocation.X", player.getCurrentLocation().getBlockX());
|
||||
customConfig.set("data."+player.getUuid()+".lastLocation.Y", player.getCurrentLocation().getBlockY());
|
||||
customConfig.set("data."+player.getUuid()+".lastLocation.Z", player.getCurrentLocation().getBlockZ());
|
||||
if(player.getCurrentLocation() == null){
|
||||
customConfig.set("data."+player.getUuid()+".playtime", player.getPlaytime());
|
||||
customConfig.set("data."+player.getUuid()+".displayName", player.getDisplayName());
|
||||
}else{
|
||||
customConfig.set("data."+player.getUuid()+".playtime", player.getPlaytime());
|
||||
customConfig.set("data."+player.getUuid()+".displayName", player.getDisplayName());
|
||||
customConfig.set("data."+player.getUuid()+".lastLocation.X", player.getCurrentLocation().getBlockX());
|
||||
customConfig.set("data."+player.getUuid()+".lastLocation.Y", player.getCurrentLocation().getBlockY());
|
||||
customConfig.set("data."+player.getUuid()+".lastLocation.Z", player.getCurrentLocation().getBlockZ());
|
||||
}
|
||||
}
|
||||
try {
|
||||
customConfig.save(customConfigFile);
|
||||
@@ -61,7 +67,30 @@ public class ConfigController {
|
||||
|
||||
}
|
||||
|
||||
public List<PlayerData> getPlayersFromConfig(){
|
||||
List<PlayerData> returnList = new ArrayList<PlayerData>();
|
||||
|
||||
if (!customConfig.getConfigurationSection("data").getKeys(false).isEmpty()) {
|
||||
customConfig.getConfigurationSection("data").getKeys(false).forEach(str -> {
|
||||
plugin.db.CreatePlayerRaw(new PlayerData(UUID.fromString(str), customConfig.getString("data."+str+".displayName"), customConfig.getInt("data."+str+".playtime")));
|
||||
});
|
||||
}
|
||||
|
||||
return returnList;
|
||||
}
|
||||
|
||||
public String getWelcomeBackMessage(Player player){
|
||||
return customConfig.getString("Config.WelcomeMessage.WelcomeBackMessage").replace("%player%", player.getDisplayName());
|
||||
}
|
||||
|
||||
public String getFirstTimeWelcomeMessage(Player player){
|
||||
return customConfig.getString("Config.WelcomeMessage.FirstTimeWelcomeMessage").replace("%player%", player.getDisplayName());
|
||||
|
||||
}
|
||||
|
||||
public boolean isWelcomeMesageEnabled(){
|
||||
return customConfig.getBoolean("Config.WelcomeMessage.Override");
|
||||
}
|
||||
|
||||
public List<Reward> getRewards(){
|
||||
List<Reward> returnList = new ArrayList<Reward>();
|
||||
|
||||
@@ -26,13 +26,19 @@ public class PlayerDatabase {
|
||||
PlayerData returnedPlayer = null;
|
||||
|
||||
for (PlayerData player : playerList) {
|
||||
if(player.getUuid() == uuid){
|
||||
if(player.getUuid().toString().equals(uuid.toString())){
|
||||
returnedPlayer = player;
|
||||
}
|
||||
}
|
||||
return returnedPlayer;
|
||||
}
|
||||
|
||||
public void loadPlayers(){
|
||||
for(PlayerData player : plugin.config.getPlayersFromConfig()){
|
||||
playerList.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
class Sortbyroll implements Comparator<PlayerData>
|
||||
{
|
||||
// Used for sorting in ascending order of
|
||||
@@ -71,10 +77,27 @@ public class PlayerDatabase {
|
||||
player.setLastLocation(lastLocation);
|
||||
}
|
||||
|
||||
public boolean playerExists(UUID uuid){
|
||||
boolean returnState = false;
|
||||
|
||||
public PlayerData createPlayer(Player player){
|
||||
playerList.add(new PlayerData(player.getUniqueId(), player.getDisplayName()));
|
||||
return getPlayer(player.getUniqueId());
|
||||
for (PlayerData player : playerList) {
|
||||
if(player.getUuid().toString().equals(uuid.toString())){
|
||||
returnState = true;
|
||||
}
|
||||
}
|
||||
|
||||
return returnState;
|
||||
}
|
||||
|
||||
public void createPlayer(Player player){
|
||||
if(playerExists(player.getUniqueId()) == false){
|
||||
playerList.add(new PlayerData(player.getUniqueId(), player.getDisplayName(), 0));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
public void CreatePlayerRaw(PlayerData playerData){
|
||||
playerList.add(playerData);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user