Archived
We made it to release 1.0
This commit is contained in:
@@ -20,12 +20,16 @@ public class CommandPlaytime implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
|
||||
if(sender instanceof Player){
|
||||
Player player = (Player) sender;
|
||||
if(args.length > 0){
|
||||
Player mentioned = Bukkit.getPlayer(args[0]);
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix + "&a"+args[0]+"'s current playtime is: &7"+Integer.toString(plugin.db.getPlayer(mentioned.getUniqueId()).getPlaytime()/3600)+" Hours"));
|
||||
if(player.hasPermission("playtimerewards.pt") || player.hasPermission("playtimerewards.user")) {
|
||||
if(args.length > 0){
|
||||
Player mentioned = Bukkit.getPlayer(args[0]);
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix + "&a"+args[0]+"'s current playtime is: &7"+Integer.toString(plugin.db.getPlayer(mentioned.getUniqueId()).getPlaytime()/3600)+" Hours"));
|
||||
|
||||
}else{
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix + "&aYour current playtime is: &7"+Integer.toString(plugin.db.getPlayer(player.getUniqueId()).getPlaytime()/3600)+" Hours"));
|
||||
}
|
||||
}else{
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix + "&aYour current playtime is: &7"+Integer.toString(plugin.db.getPlayer(player.getUniqueId()).getPlaytime()/3600)+" Hours"));
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+"&c You do not have permission to use this command"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-7
@@ -22,14 +22,19 @@ public class CommandPlaytimeLeaderboard implements CommandExecutor {
|
||||
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
int i = 0;
|
||||
for (PlayerData pl : plugin.db.getSortedPlayerlist()){
|
||||
if(i<5){
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+"&a"+pl.getDisplayName()+"&8| "+Integer.toString(pl.getPlaytime()/3600)));
|
||||
i++;
|
||||
if(player.hasPermission("playtimerewards.ptleader") || player.hasPermission("playtimerewards.user")) {
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+"&8-------- &7Leaderboard &8--------"));
|
||||
int i = 0;
|
||||
for (PlayerData pl : plugin.db.getSortedPlayerlist()){
|
||||
if(i<9){
|
||||
if((pl.getPlaytime()/3600) > 0){
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+"&a"+pl.getDisplayName()+"&8 : "+" &7"+Integer.toString(pl.getPlaytime()/3600))+" Hours");
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}else{
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+"&c You do not have permission to use this command"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,13 @@ public class CommandPluginInfo implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+"&8[&6Playtime Rewards&7+&8]"));
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+"This plugin was developed by: &aAstrid (O_dude)"));
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+"Current Plugin Version: &70.01a"));
|
||||
if(player.hasPermission("playtimerewards.ptinfo") || player.hasPermission("playtimerewards.user")){
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+"&8[&6Playtime Rewards&7+&8]"));
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+"This plugin was developed by: &aAstrid (O_dude)"));
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+"Current Plugin Version: &7"+plugin.getDescription().getVersion()));
|
||||
}else{
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+"&c You do not have permission to use this command"));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -20,14 +20,16 @@ public class CommandSeen implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
|
||||
if(sender instanceof Player){
|
||||
Player player = (Player) sender;
|
||||
if(player.hasPermission("playtimerewards.ptseen") || player.hasPermission("playtimerewards.admin")) {
|
||||
String pName = args[0];
|
||||
Player mentioned = Bukkit.getPlayer(pName);
|
||||
|
||||
String pName = args[0];
|
||||
Player mentioned = Bukkit.getPlayer(pName);
|
||||
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+"&8--------&7 "+mentioned.getDisplayName()+" &8--------"));
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+"&Playtime: &7"+Integer.toString(plugin.db.getPlayer(mentioned.getUniqueId()).getPlaytime()/3600)+" Hours"));
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+"&aLogoff Location (X,Y,Z): &7"+plugin.config.getSavedX(mentioned.getUniqueId())+" "+plugin.config.getSavedY(mentioned.getUniqueId())+" "+plugin.config.getSavedZ(mentioned.getUniqueId())));
|
||||
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+"&8--------&7 "+mentioned.getDisplayName()+" &8--------"));
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+"&Playtime: &7"+Integer.toString(plugin.db.getPlayer(mentioned.getUniqueId()).getPlaytime()/3600)+" Hours"));
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+"&aLogoff Location (X,Y,Z): &7"+plugin.config.getSavedX(mentioned.getUniqueId())+" "+plugin.config.getSavedY(mentioned.getUniqueId())+" "+plugin.config.getSavedZ(mentioned.getUniqueId())));
|
||||
}else{
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+"&c You do not have permission to use this command"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,12 +2,16 @@ package dev.astridlabs.playtimerewardsplus.Commands;
|
||||
|
||||
import dev.astridlabs.playtimerewardsplus.DataTypes.PlayerData;
|
||||
import dev.astridlabs.playtimerewardsplus.Plugin;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Debug implements CommandExecutor {
|
||||
private Plugin plugin;
|
||||
private String DebugPrefix = "&7[&cDEBUG MODE&7] ";
|
||||
@@ -20,6 +24,8 @@ public class Debug implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
|
||||
if(sender instanceof Player){
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(!player.hasPermission("playtimerewards.debug")) player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+"&c You do not have permission to use this command"));
|
||||
if(args[0].equals("time")){
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+DebugPrefix + "&aUser playtime in seconds is: "+this.plugin.db.getPlayer(player.getUniqueId()).getPlaytime()));
|
||||
}
|
||||
@@ -35,8 +41,20 @@ public class Debug implements CommandExecutor {
|
||||
plugin.config.savePlayers();
|
||||
|
||||
}
|
||||
|
||||
if(args[0].equals("rawdata")){
|
||||
List<PlayerData> playerDataList = plugin.db.getSortedPlayerlist();
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+DebugPrefix + "&aPlayer UUID: &7"+ player.getUniqueId()));
|
||||
|
||||
for(PlayerData p : playerDataList){
|
||||
if(player.getUniqueId().toString().equals(p.getUuid().toString())){//FIXME: This is never called, meaning somehow the UUID's are not compatable with eachother
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+DebugPrefix + "&aYou are in the Database!"));
|
||||
}
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+DebugPrefix + "&aPlayer UUID: &7"+ p.getUuid()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package dev.astridlabs.playtimerewardsplus.Events;
|
||||
|
||||
import dev.astridlabs.playtimerewardsplus.Plugin;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
@@ -17,7 +19,13 @@ public class PlayerJoin implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
event.setJoinMessage("Welcome, " + event.getPlayer().getName() + "!");
|
||||
if(plugin.config.isWelcomeMesageEnabled()){
|
||||
if(plugin.db.playerExists(event.getPlayer().getUniqueId())){
|
||||
event.setJoinMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+plugin.config.getWelcomeBackMessage(event.getPlayer())));
|
||||
}else{
|
||||
event.setJoinMessage(ChatColor.translateAlternateColorCodes('&', plugin.PluginChatPrefix+plugin.config.getFirstTimeWelcomeMessage(event.getPlayer())));
|
||||
}
|
||||
}
|
||||
plugin.db.createPlayer(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package dev.astridlabs.playtimerewardsplus;
|
||||
|
||||
import dev.astridlabs.playtimerewardsplus.DataTypes.PlayerData;
|
||||
import dev.astridlabs.playtimerewardsplus.Plugin;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
|
||||
@@ -39,9 +39,11 @@ public class Plugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
|
||||
//FIXME: This does not actually load the players
|
||||
db.loadPlayers();
|
||||
|
||||
PlaceholderChatPrefix = getConfig().getString("Config.PlaceholderChatPrefix")+" ";
|
||||
PluginChatPrefix = getConfig().getString("Config.PluginChatPrefix")+" ";
|
||||
PlaceholderChatPrefix = getConfig().getString("Config.PlaceholderChatPrefix")+" ";
|
||||
PluginChatPrefix = getConfig().getString("Config.PluginChatPrefix")+" ";
|
||||
//Initialize Events
|
||||
Bukkit.getPluginManager().registerEvents(new PlayerJoin(this), this); // This fires the event and allows any listener to listen to the event
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.UUID;
|
||||
|
||||
public class PlayerData {
|
||||
|
||||
private int Playtime = 0;
|
||||
private int Playtime;
|
||||
private UUID uuid;
|
||||
private String DisplayName;
|
||||
|
||||
@@ -23,9 +23,10 @@ public class PlayerData {
|
||||
|
||||
private List<String> RepetitiveUnlocks = new ArrayList<String>();
|
||||
|
||||
public PlayerData(UUID uuid, String DisplayName){
|
||||
public PlayerData(UUID uuid, String DisplayName, Integer playtime){
|
||||
this.uuid = uuid;
|
||||
this.DisplayName = DisplayName;
|
||||
this.Playtime = playtime;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user