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:
parent
cba1c3bcca
commit
e8c60e6e84
@ -82,8 +82,13 @@ public class PetTagPage extends ShopPageBase<CosmeticManager, CosmeticShop>
|
|||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
PetChangeToken token = new PetChangeToken();
|
PetChangeToken token = new PetChangeToken();
|
||||||
|
|
||||||
|
if (getClientManager().Get(getPlayer()) != null)
|
||||||
|
token.AccountId = getClientManager().Get(getPlayer()).getAccountId();
|
||||||
|
|
||||||
token.Name = getPlayer().getName();
|
token.Name = getPlayer().getName();
|
||||||
token.PetType = _pet.GetPetType().toString();
|
token.PetType = _pet.GetPetType().toString();
|
||||||
|
token.PetId = _pet.GetPetType().ordinal();
|
||||||
token.PetName = _tagName;
|
token.PetName = _tagName;
|
||||||
|
|
||||||
PetToken petToken = new PetToken();
|
PetToken petToken = new PetToken();
|
||||||
|
@ -77,7 +77,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
|
|||||||
|
|
||||||
_creatureModule = creatureModule;
|
_creatureModule = creatureModule;
|
||||||
_disguiseManager = disguiseManager;
|
_disguiseManager = disguiseManager;
|
||||||
_repository = new PetRepository(webAddress);
|
_repository = new PetRepository(plugin, webAddress);
|
||||||
_petFactory = new PetFactory(_repository);
|
_petFactory = new PetFactory(_repository);
|
||||||
_blockRestore = restore;
|
_blockRestore = restore;
|
||||||
_donationManager = donationManager;
|
_donationManager = donationManager;
|
||||||
|
@ -3,19 +3,26 @@ package mineplex.core.pet.repository;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.craftbukkit.libs.com.google.gson.reflect.TypeToken;
|
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.PetChangeToken;
|
||||||
import mineplex.core.pet.repository.token.PetExtraToken;
|
import mineplex.core.pet.repository.token.PetExtraToken;
|
||||||
import mineplex.core.pet.repository.token.PetSalesToken;
|
import mineplex.core.pet.repository.token.PetSalesToken;
|
||||||
import mineplex.core.server.remotecall.AsyncJsonWebCall;
|
import mineplex.core.server.remotecall.AsyncJsonWebCall;
|
||||||
import mineplex.core.server.remotecall.JsonWebCall;
|
import mineplex.core.server.remotecall.JsonWebCall;
|
||||||
|
|
||||||
public class PetRepository
|
public class PetRepository extends RepositoryBase
|
||||||
{
|
{
|
||||||
private String _webAddress;
|
private String _webAddress;
|
||||||
|
|
||||||
public PetRepository(String webAddress)
|
public PetRepository(JavaPlugin plugin, String webAddress)
|
||||||
{
|
{
|
||||||
|
super(plugin, DBPool.ACCOUNT);
|
||||||
|
|
||||||
_webAddress = webAddress;
|
_webAddress = webAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,5 +44,26 @@ public class PetRepository
|
|||||||
public void UpdatePet(PetChangeToken token)
|
public void UpdatePet(PetChangeToken token)
|
||||||
{
|
{
|
||||||
new AsyncJsonWebCall(_webAddress + "Pets/UpdatePet").Execute(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()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@ package mineplex.core.pet.repository.token;
|
|||||||
|
|
||||||
public class PetChangeToken
|
public class PetChangeToken
|
||||||
{
|
{
|
||||||
|
public int AccountId;
|
||||||
|
public int PetId;
|
||||||
public String Name;
|
public String Name;
|
||||||
public String PetName;
|
public String PetName;
|
||||||
public String PetType;
|
public String PetType;
|
||||||
|
@ -80,14 +80,11 @@ public class ServerTypePage extends ShopPageBase<ServerManager, ServerNpcShop>
|
|||||||
{
|
{
|
||||||
if (team)
|
if (team)
|
||||||
{
|
{
|
||||||
//getPlugin().selectServer(player, _serverGroup.getTeamServerKey()); // TODO: Grab the team-key instead of regular game key
|
getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), _serverGroup.getServerNpcName() + " Teams", player, _serverGroup.getTeamServerKey()));
|
||||||
//getPlugin().getServerNPCShopByName(_serverGroup.getServerNpcName() + " 2").attemptShopOpen(player);
|
|
||||||
getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), _serverGroup.getServerNpcName(), player, _serverGroup.getTeamServerKey()));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//getPlugin().selectServer(player, _serverGroup.getPrefix());
|
getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), _serverGroup.getServerNpcName() + " Solo", player, _serverGroup.getPrefix()));
|
||||||
getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), _serverGroup.getServerNpcName(), player, _serverGroup.getPrefix()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user