Skip to content

Commit

Permalink
Don't load from player.dat for online players
Browse files Browse the repository at this point in the history
Fixes lishid#40 and #5
  • Loading branch information
Jikoo committed Apr 11, 2016
1 parent fb48f6a commit e39ab10
Show file tree
Hide file tree
Showing 18 changed files with 43 additions and 36 deletions.
13 changes: 10 additions & 3 deletions src/main/java/com/lishid/openinv/internal/IPlayerDataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;

public interface IPlayerDataManager {
public Player loadPlayer(OfflinePlayer offline);
public abstract class IPlayerDataManager {
public final Player loadPlayer(OfflinePlayer offline) {
if (offline.isOnline()) {
return offline.getPlayer();
}
return this.loadOfflinePlayer(offline);
}

public String getPlayerDataID(OfflinePlayer player);
protected abstract Player loadOfflinePlayer(OfflinePlayer offline);

public abstract String getPlayerDataID(OfflinePlayer player);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@

import org.bukkit.craftbukkit.v1_4_5.CraftServer;

public class PlayerDataManager implements IPlayerDataManager {
public class PlayerDataManager extends IPlayerDataManager {

@Override
public Player loadPlayer(OfflinePlayer offline) {
public Player loadOfflinePlayer(OfflinePlayer offline) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();

// Create an entity to load the player data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@

import org.bukkit.craftbukkit.v1_4_6.CraftServer;

public class PlayerDataManager implements IPlayerDataManager {
public class PlayerDataManager extends IPlayerDataManager {

@Override
public Player loadPlayer(OfflinePlayer offline) {
public Player loadOfflinePlayer(OfflinePlayer offline) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();

// Create an entity to load the player data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
import org.bukkit.craftbukkit.v1_4_R1.CraftServer;


public class PlayerDataManager implements IPlayerDataManager {
public class PlayerDataManager extends IPlayerDataManager {

@Override
public Player loadPlayer(OfflinePlayer offline) {
public Player loadOfflinePlayer(OfflinePlayer offline) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();

// Create an entity to load the player data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@

import org.bukkit.craftbukkit.v1_5_R2.CraftServer;

public class PlayerDataManager implements IPlayerDataManager {
public class PlayerDataManager extends IPlayerDataManager {

@Override
public Player loadPlayer(OfflinePlayer offline) {
public Player loadOfflinePlayer(OfflinePlayer offline) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();

// Create an entity to load the player data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@

import org.bukkit.craftbukkit.v1_5_R3.CraftServer;

public class PlayerDataManager implements IPlayerDataManager {
public class PlayerDataManager extends IPlayerDataManager {

@Override
public Player loadPlayer(OfflinePlayer offline) {
public Player loadOfflinePlayer(OfflinePlayer offline) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();

// Create an entity to load the player data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@

import org.bukkit.craftbukkit.v1_6_R1.CraftServer;

public class PlayerDataManager implements IPlayerDataManager {
public class PlayerDataManager extends IPlayerDataManager {

@Override
public Player loadPlayer(OfflinePlayer offline) {
public Player loadOfflinePlayer(OfflinePlayer offline) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();

// Create an entity to load the player data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@

import org.bukkit.craftbukkit.v1_6_R2.CraftServer;

public class PlayerDataManager implements IPlayerDataManager {
public class PlayerDataManager extends IPlayerDataManager {

@Override
public Player loadPlayer(OfflinePlayer offline) {
public Player loadOfflinePlayer(OfflinePlayer offline) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();

// Create an entity to load the player data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@

import org.bukkit.craftbukkit.v1_6_R3.CraftServer;

public class PlayerDataManager implements IPlayerDataManager {
public class PlayerDataManager extends IPlayerDataManager {

@Override
public Player loadPlayer(OfflinePlayer offline) {
public Player loadOfflinePlayer(OfflinePlayer offline) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();

// Create an entity to load the player data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@

import org.bukkit.craftbukkit.v1_7_R1.CraftServer;

public class PlayerDataManager implements IPlayerDataManager {
public class PlayerDataManager extends IPlayerDataManager {

@Override
public Player loadPlayer(OfflinePlayer offline) {
public Player loadOfflinePlayer(OfflinePlayer offline) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();

GameProfile profile = new GameProfile(null, offline.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@

import org.bukkit.craftbukkit.v1_7_R2.CraftServer;

public class PlayerDataManager implements IPlayerDataManager {
public class PlayerDataManager extends IPlayerDataManager {

@Override
public Player loadPlayer(OfflinePlayer offline) {
public Player loadOfflinePlayer(OfflinePlayer offline) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();

GameProfile profile = new GameProfile(null, offline.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@

import org.bukkit.craftbukkit.v1_7_R3.CraftServer;

public class PlayerDataManager implements IPlayerDataManager {
public class PlayerDataManager extends IPlayerDataManager {

@Override
public Player loadPlayer(OfflinePlayer offline) {
public Player loadOfflinePlayer(OfflinePlayer offline) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();

GameProfile profile = new GameProfile(offline.getUniqueId(), offline.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@

import org.bukkit.craftbukkit.v1_7_R4.CraftServer;

public class PlayerDataManager implements IPlayerDataManager {
public class PlayerDataManager extends IPlayerDataManager {

@Override
public Player loadPlayer(OfflinePlayer offline) {
public Player loadOfflinePlayer(OfflinePlayer offline) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();

GameProfile profile = new GameProfile(offline.getUniqueId(), offline.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
//Volatile
import org.bukkit.craftbukkit.v1_8_R1.CraftServer;

public class PlayerDataManager implements IPlayerDataManager {
public class PlayerDataManager extends IPlayerDataManager {

@Override
public Player loadPlayer(OfflinePlayer offline) {
public Player loadOfflinePlayer(OfflinePlayer offline) {
GameProfile profile = new GameProfile(offline.getUniqueId(), offline.getName());
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
// Create an entity to load the player data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@

import org.bukkit.craftbukkit.v1_8_R2.CraftServer;

public class PlayerDataManager implements IPlayerDataManager {
public class PlayerDataManager extends IPlayerDataManager {

@Override
public Player loadPlayer(OfflinePlayer offline) {
public Player loadOfflinePlayer(OfflinePlayer offline) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();

GameProfile profile = new GameProfile(offline.getUniqueId(), offline.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
//Volatile
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;

public class PlayerDataManager implements IPlayerDataManager {
public class PlayerDataManager extends IPlayerDataManager {

@Override
public Player loadPlayer(OfflinePlayer offline) {
public Player loadOfflinePlayer(OfflinePlayer offline) {
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();

GameProfile profile = new GameProfile(offline.getUniqueId(), offline.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@

import org.bukkit.craftbukkit.v1_9_R1.CraftServer;

public class PlayerDataManager implements IPlayerDataManager {
public class PlayerDataManager extends IPlayerDataManager {

@Override
public Player loadPlayer(OfflinePlayer offline) {
public Player loadOfflinePlayer(OfflinePlayer offline) {
if (offline == null || !offline.hasPlayedBefore()) {
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: OpenInv
main: com.lishid.openinv.OpenInv
version: 2.3.0
version: 2.4.1
author: lishid
authors: [Jikoo]
description: >
Expand Down

0 comments on commit e39ab10

Please sign in to comment.