Added storage of pets in mysql. Going to have live while backend process is copying data over.

Updated ServerTypePage to resolve clicking issues with solo/team pages.
This commit is contained in:
Jonathan Williams 2015-08-07 02:22:13 -05:00
parent cba1c3bcca
commit e8c60e6e84
5 changed files with 40 additions and 8 deletions

View File

@ -82,8 +82,13 @@ public class PetTagPage extends ShopPageBase<CosmeticManager, CosmeticShop>
public void run()
{
PetChangeToken token = new PetChangeToken();
if (getClientManager().Get(getPlayer()) != null)
token.AccountId = getClientManager().Get(getPlayer()).getAccountId();
token.Name = getPlayer().getName();
token.PetType = _pet.GetPetType().toString();
token.PetId = _pet.GetPetType().ordinal();
token.PetName = _tagName;
PetToken petToken = new PetToken();

View File

@ -77,7 +77,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
_creatureModule = creatureModule;
_disguiseManager = disguiseManager;
_repository = new PetRepository(webAddress);
_repository = new PetRepository(plugin, webAddress);
_petFactory = new PetFactory(_repository);
_blockRestore = restore;
_donationManager = donationManager;

View File

@ -3,19 +3,26 @@ package mineplex.core.pet.repository;
import java.util.List;
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.database.DBPool;
import mineplex.core.database.RepositoryBase;
import mineplex.core.database.column.ColumnInt;
import mineplex.core.database.column.ColumnVarChar;
import mineplex.core.pet.repository.token.PetChangeToken;
import mineplex.core.pet.repository.token.PetExtraToken;
import mineplex.core.pet.repository.token.PetSalesToken;
import mineplex.core.server.remotecall.AsyncJsonWebCall;
import mineplex.core.server.remotecall.JsonWebCall;
public class PetRepository
public class PetRepository extends RepositoryBase
{
private String _webAddress;
public PetRepository(String webAddress)
public PetRepository(JavaPlugin plugin, String webAddress)
{
super(plugin, DBPool.ACCOUNT);
_webAddress = webAddress;
}
@ -37,5 +44,26 @@ public class PetRepository
public void UpdatePet(PetChangeToken token)
{
new AsyncJsonWebCall(_webAddress + "Pets/UpdatePet").Execute(token);
int rowsChanged = executeUpdate("UPDATE accountPets SET petName = ? WHERE petId = ? AND accountId = ?;", new ColumnVarChar("petName", 32, token.PetName)
, new ColumnInt("petId", token.PetId)
, new ColumnInt("accountId", token.AccountId));
if (rowsChanged < 1)
{
executeInsert("INSERT INTO accountPets(petName, petId, accountId) VALUES (?, ?, ?);", null, new ColumnVarChar("petName", 32, token.PetName)
, new ColumnInt("petId", token.PetId)
, new ColumnInt("accountId", token.AccountId));
}
}
@Override
protected void initialize()
{
}
@Override
protected void update()
{
}
}

View File

@ -2,6 +2,8 @@ package mineplex.core.pet.repository.token;
public class PetChangeToken
{
public int AccountId;
public int PetId;
public String Name;
public String PetName;
public String PetType;

View File

@ -80,14 +80,11 @@ public class ServerTypePage extends ShopPageBase<ServerManager, ServerNpcShop>
{
if (team)
{
//getPlugin().selectServer(player, _serverGroup.getTeamServerKey()); // TODO: Grab the team-key instead of regular game key
//getPlugin().getServerNPCShopByName(_serverGroup.getServerNpcName() + " 2").attemptShopOpen(player);
getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), _serverGroup.getServerNpcName(), player, _serverGroup.getTeamServerKey()));
getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), _serverGroup.getServerNpcName() + " Teams", player, _serverGroup.getTeamServerKey()));
}
else
{
//getPlugin().selectServer(player, _serverGroup.getPrefix());
getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), _serverGroup.getServerNpcName(), player, _serverGroup.getPrefix()));
getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), _serverGroup.getServerNpcName() + " Solo", player, _serverGroup.getPrefix()));
}
}
}