mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-07-02 12:56:40 +00:00
LuckPerms Integration (2/2)
This commit is contained in:
@ -1,24 +1,26 @@
|
||||
package me.totalfreedom.totalfreedommod.player;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
import me.totalfreedom.totalfreedommod.api.ShopItem;
|
||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
|
||||
public class PlayerData
|
||||
{
|
||||
private UUID uuid;
|
||||
private final List<String> ips = Lists.newArrayList();
|
||||
private final List<String> notes = Lists.newArrayList();
|
||||
private String tag = null;
|
||||
private UUID uuid;
|
||||
private Component tag = Component.empty();
|
||||
private String discordID = null;
|
||||
private Boolean masterBuilder = false;
|
||||
|
||||
@ -48,7 +50,7 @@ public class PlayerData
|
||||
ips.addAll(FUtil.stringToList(resultSet.getString("ips")));
|
||||
notes.clear();
|
||||
notes.addAll(FUtil.stringToList(resultSet.getString("notes")));
|
||||
tag = resultSet.getString("tag");
|
||||
tag = LegacyComponentSerializer.legacyAmpersand().deserialize(resultSet.getString("tag"));
|
||||
discordID = resultSet.getString("discord_id");
|
||||
masterBuilder = resultSet.getBoolean("master_builder");
|
||||
rideMode = RideMode.valueOf(resultSet.getString("ride_mode").toUpperCase());
|
||||
@ -59,8 +61,7 @@ public class PlayerData
|
||||
displayDiscord = resultSet.getBoolean("display_discord");
|
||||
loginMessage = resultSet.getString("login_message");
|
||||
inspect = resultSet.getBoolean("inspect");
|
||||
}
|
||||
catch (SQLException e)
|
||||
} catch (SQLException e)
|
||||
{
|
||||
FLog.severe("Failed to load player: " + e.getMessage());
|
||||
}
|
||||
@ -81,7 +82,7 @@ public class PlayerData
|
||||
"- Coins: " + coins + "\n" +
|
||||
"- Total Votes: " + totalVotes + "\n" +
|
||||
"- Display Discord: " + displayDiscord + "\n" +
|
||||
"- Tag: " + FUtil.colorize(tag) + ChatColor.GRAY + "\n" +
|
||||
"- Tag: " + tag.toString() + ChatColor.GRAY + "\n" +
|
||||
"- Ride Mode: " + rideMode.name() + "\n" +
|
||||
"- Login Message: " + loginMessage;
|
||||
}
|
||||
@ -141,8 +142,7 @@ public class PlayerData
|
||||
try
|
||||
{
|
||||
notes.remove(id);
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
} catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -186,22 +186,21 @@ public class PlayerData
|
||||
|
||||
public Map<String, Object> toSQLStorable()
|
||||
{
|
||||
return new HashMap<String, Object>()
|
||||
{{
|
||||
put("uuid", uuid.toString());
|
||||
put("ips", FUtil.listToString(ips));
|
||||
put("notes", FUtil.listToString(notes));
|
||||
put("tag", tag);
|
||||
put("discord_id", discordID);
|
||||
put("master_builder", masterBuilder);
|
||||
put("ride_mode", rideMode.name());
|
||||
put("coins", coins);
|
||||
put("items", FUtil.listToString(items));
|
||||
put("total_votes", totalVotes);
|
||||
put("display_discord", displayDiscord);
|
||||
put("login_message", loginMessage);
|
||||
put("inspect", inspect);
|
||||
}};
|
||||
Map<String, Object> objectMap = new HashMap<>();
|
||||
objectMap.put("uuid", uuid.toString());
|
||||
objectMap.put("ips", FUtil.listToString(ips));
|
||||
objectMap.put("notes", FUtil.listToString(notes));
|
||||
objectMap.put("tag", tag.toString());
|
||||
objectMap.put("discord_id", discordID);
|
||||
objectMap.put("master_builder", masterBuilder);
|
||||
objectMap.put("ride_mode", rideMode.name());
|
||||
objectMap.put("coins", coins);
|
||||
objectMap.put("items", FUtil.listToString(items));
|
||||
objectMap.put("total_votes", totalVotes);
|
||||
objectMap.put("display_discord", displayDiscord);
|
||||
objectMap.put("login_message", loginMessage);
|
||||
objectMap.put("inspect", inspect);
|
||||
return objectMap;
|
||||
}
|
||||
|
||||
public boolean doesDisplayDiscord()
|
||||
@ -219,12 +218,12 @@ public class PlayerData
|
||||
return Bukkit.getOfflinePlayer(uuid).getName();
|
||||
}
|
||||
|
||||
public String getTag()
|
||||
public Component getTag()
|
||||
{
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void setTag(String tag)
|
||||
public void setTag(Component tag)
|
||||
{
|
||||
this.tag = tag;
|
||||
}
|
||||
|
Reference in New Issue
Block a user