Archived
Added Player Database
This commit is contained in:
BIN
Binary file not shown.
@@ -0,0 +1,54 @@
|
||||
// PlayerDatabase.java
|
||||
// - A database to keep track of players within the plugin
|
||||
//
|
||||
// (c) Owen Rummage 2020
|
||||
|
||||
package dev.astridlabs.playtimerewardsplus.Controllers;
|
||||
|
||||
import dev.astridlabs.playtimerewardsplus.DataTypes.PlayerData;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerDatabase {
|
||||
public List<PlayerData> playerList = new ArrayList<PlayerData>();
|
||||
|
||||
public PlayerData getPlayer(UUID uuid){
|
||||
PlayerData returnedPlayer = null;
|
||||
|
||||
for (PlayerData player : playerList) {
|
||||
if(player.getUuid() == uuid){
|
||||
returnedPlayer = player;
|
||||
}
|
||||
}
|
||||
return returnedPlayer;
|
||||
}
|
||||
|
||||
|
||||
public void updatePlayerDisplayName(UUID uuid, String displayName){
|
||||
PlayerData player = getPlayer(uuid);
|
||||
player.setDisplayName(displayName);
|
||||
}
|
||||
public void updatePlayerPlaytime(UUID uuid, Integer playtime){
|
||||
PlayerData player = getPlayer(uuid);
|
||||
player.setPlaytime(playtime);
|
||||
}
|
||||
public void updateCurrentLocation(UUID uuid, Location currentLocation){
|
||||
PlayerData player = getPlayer(uuid);
|
||||
player.setCurrentLocation(currentLocation);
|
||||
}
|
||||
public void updateLastLocation(UUID uuid, Location lastLocation){
|
||||
PlayerData player = getPlayer(uuid);
|
||||
player.setLastLocation(lastLocation);
|
||||
}
|
||||
|
||||
|
||||
public PlayerData createPlayer(Player player){
|
||||
playerList.add(new PlayerData(player.getUniqueId(), player.getDisplayName()));
|
||||
return getPlayer(player.getUniqueId());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,16 @@
|
||||
package dev.astridlabs.playtimerewardsplus;
|
||||
|
||||
public class Plugin {
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Plugin extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable(){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable(){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
// PlayerData.java
|
||||
// - This file is the main definition of all the data tracked by the plugin that is not already in the Player object inhibited by org.bukkit.player
|
||||
//
|
||||
// (c) Owen Rummage 2020
|
||||
|
||||
package dev.astridlabs.playtimerewardsplus.DataTypes;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerData {
|
||||
|
||||
private Integer Playtime;
|
||||
private UUID uuid;
|
||||
private String DisplayName;
|
||||
|
||||
private Location CurrentLocation;
|
||||
private Location LastLocation;
|
||||
|
||||
public PlayerData(UUID uuid, String DisplayName){
|
||||
this.uuid = uuid;
|
||||
this.DisplayName = DisplayName;
|
||||
|
||||
}
|
||||
|
||||
//Getters and Setters
|
||||
public Integer getPlaytime() {
|
||||
return Playtime;
|
||||
}
|
||||
public void setPlaytime(Integer playtime) {
|
||||
Playtime = playtime;
|
||||
}
|
||||
public void setUuid(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
public void setDisplayName(String displayName) {
|
||||
DisplayName = displayName;
|
||||
}
|
||||
public String getDisplayName() {
|
||||
return DisplayName;
|
||||
}
|
||||
public Location getCurrentLocation() {
|
||||
return CurrentLocation;
|
||||
}
|
||||
public void setCurrentLocation(Location currentLocation) {
|
||||
this.CurrentLocation = currentLocation;
|
||||
}
|
||||
public Location getLastLocation() {
|
||||
return LastLocation;
|
||||
}
|
||||
public void setLastLocation(Location lastLocation) {
|
||||
this.LastLocation = lastLocation;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user