Added Coins to donation.

Fixed order of gadgets, mounts, pets, morphs, particles.
Fixed display of active pet in Menu
Fixed coins purchase for most items.

Added Coins reward for ENjinTranslator.
Added Coin transactions.
This commit is contained in:
Jonathan Williams 2014-08-08 02:05:58 -05:00
parent 57cf3e4da6
commit 9f2a83c956
26 changed files with 436 additions and 277 deletions

View File

@ -212,4 +212,34 @@ public class DonationManager extends MiniPlugin
//Clean
_gemQueue.clear();
}
public void RewardCoins(final Callback<Boolean> callback, final String caller, final String name, final int amount)
{
RewardCoins(callback, caller, name, amount, true);
}
public void RewardCoins(final Callback<Boolean> callback, final String caller, final String name, final int amount, final boolean updateTotal)
{
_repository.rewardCoins(new Callback<Boolean>()
{
public void run(Boolean success)
{
if (success)
{
if (updateTotal)
{
Donor donor = Get(name);
if (donor != null)
{
donor.addCoins(amount);
}
}
if (callback != null)
callback.run(true);
}
}
}, caller, name, amount);
}
}

View File

@ -133,4 +133,9 @@ public class Donor
{
return _coins;
}
public void addCoins(int amount)
{
_coins += amount;
}
}

View File

@ -46,4 +46,13 @@ public class DonationRepository
token.Amount = greenGems;
new AsyncJsonWebCall(_webAddress + "PlayerAccount/GemReward").Execute(Boolean.class, callback, token);
}
public void rewardCoins(Callback<Boolean> callback, String giver, String name, int coins)
{
GemRewardToken token = new GemRewardToken();
token.Source = giver;
token.Name = name;
token.Amount = coins;
new AsyncJsonWebCall(_webAddress + "PlayerAccount/CoinReward").Execute(Boolean.class, callback, token);
}
}

View File

@ -1,6 +1,7 @@
package mineplex.core.gadget;
import java.util.HashSet;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -41,7 +42,7 @@ public class GadgetManager extends MiniPlugin
private DisguiseManager _disguiseManager;
private BlockRestore _blockRestore;
private NautHashMap<GadgetType, HashSet<Gadget>> _gadgets;
private NautHashMap<GadgetType, List<Gadget>> _gadgets;
private NautHashMap<Player, Long> _lastMove = new NautHashMap<Player, Long>();
private NautHashMap<Player, NautHashMap<GadgetType, Gadget>> _playerActiveGadgetMap = new NautHashMap<Player, NautHashMap<GadgetType, Gadget>>();
@ -64,7 +65,7 @@ public class GadgetManager extends MiniPlugin
private void CreateGadgets()
{
_gadgets = new NautHashMap<GadgetType, HashSet<Gadget>>();
_gadgets = new NautHashMap<GadgetType, List<Gadget>>();
// Items
addGadget(new ItemPaintballGun(this));
@ -80,18 +81,18 @@ public class GadgetManager extends MiniPlugin
addGadget(new MorphChicken(this));
// Particles
addGadget(new ParticleGreen(this));
addGadget(new ParticleFoot(this));
addGadget(new ParticleEnchant(this));
addGadget(new ParticleFireRings(this));
addGadget(new ParticleRain(this));
addGadget(new ParticleHelix(this));
addGadget(new ParticleEnchant(this));
addGadget(new ParticleGreen(this));
addGadget(new ParticleFoot(this));
}
private void addGadget(Gadget gadget)
{
if (!_gadgets.containsKey(gadget.getGadgetType()))
_gadgets.put(gadget.getGadgetType(), new HashSet<Gadget>());
_gadgets.put(gadget.getGadgetType(), new ArrayList<Gadget>());
_gadgets.get(gadget.getGadgetType()).add(gadget);
}
@ -111,7 +112,7 @@ public class GadgetManager extends MiniPlugin
}
}
public HashSet<Gadget> getGadgets(GadgetType gadgetType)
public List<Gadget> getGadgets(GadgetType gadgetType)
{
return _gadgets.get(gadgetType);
}

View File

@ -20,6 +20,7 @@ import mineplex.core.inventory.ui.button.ActivateGadgetButton;
import mineplex.core.inventory.ui.button.DeactivateGadgetButton;
import mineplex.core.inventory.ui.button.GadgetButton;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.item.SingleButton;
import mineplex.core.shop.page.ConfirmationPage;
import mineplex.core.shop.page.ShopPageBase;
@ -48,6 +49,15 @@ public class GadgetPage extends ShopPageBase<InventoryManager, InventoryShop>
if (slot == 26)
slot = 28;
}
AddButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[] { }, 1, false), new SingleButton()
{
@Override
public void Clicked(Player player)
{
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, player));
}
});
}
protected void addGadget(Gadget gadget, int slot)

View File

@ -65,7 +65,7 @@ public class Menu extends ShopPageBase<InventoryManager, InventoryShop>
if (Plugin.getPetManager().hasActivePet(Player.getName()))
{
AddButton(40, new ShopItem(Material.MONSTER_EGG, (byte)Plugin.getPetManager().getActivePet(Player.getName()).getType().getTypeId(), "Deactivate " + Plugin.getPetManager().getActivePet(Player.getName()).getCustomName(), new String[] {}, 1, false, false), new DeactivatePetButton(this, Plugin.getPetManager()));
AddButton(40, new ShopItem(Material.MONSTER_EGG, (byte)Plugin.getPetManager().getActivePet(Player.getName()).getType().getTypeId(), F.item(Plugin.getPetManager().getActivePet(Player.getName()).getCustomName()), new String[] {}, 1, false, false), new DeactivatePetButton(this, Plugin.getPetManager()));
}
if (Plugin.getMountManager().getActive(Player) != null)

View File

@ -1,13 +1,17 @@
package mineplex.core.inventory.ui.page;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.inventory.ui.InventoryShop;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.item.SingleButton;
public class MorphPage extends GadgetPage
{
@ -33,5 +37,14 @@ public class MorphPage extends GadgetPage
if (slot == 26)
slot = 28;
}
AddButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[] { }, 1, false), new SingleButton()
{
@Override
public void Clicked(Player player)
{
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, player));
}
});
}
}

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
@ -17,6 +18,7 @@ import mineplex.core.inventory.ui.button.DeactivateMountButton;
import mineplex.core.inventory.ui.button.MountButton;
import mineplex.core.mount.Mount;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.item.SingleButton;
import mineplex.core.shop.page.ConfirmationPage;
import mineplex.core.shop.page.ShopPageBase;
@ -47,9 +49,9 @@ public class MountPage extends ShopPageBase<InventoryManager, InventoryShop>
{
List<String> itemLore = new ArrayList<String>();
if (mount.GetCost(CurrencyType.Gems) != -1)
if (mount.GetCost(CurrencyType.Coins) != -1)
{
itemLore.add(C.cYellow + mount.GetCost(CurrencyType.Gems) + " Gems");
itemLore.add(C.cYellow + mount.GetCost(CurrencyType.Coins) + " Coins");
}
itemLore.add(C.cBlack);
@ -68,11 +70,20 @@ public class MountPage extends ShopPageBase<InventoryManager, InventoryShop>
}
else
{
if (mount.GetCost(CurrencyType.Gems) != -1 && DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Gems) >= mount.GetCost(CurrencyType.Gems))
if (mount.GetCost(CurrencyType.Coins) != -1 && DonationManager.Get(Player.getName()).GetBalance(CurrencyType.Coins) >= mount.GetCost(CurrencyType.Coins))
AddButton(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), "Purchase " + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, false, false), new MountButton(mount, this));
else
setItem(slot, new ShopItem(mount.GetDisplayMaterial(), mount.GetDisplayData(), "Purchase " + mount.GetName(), itemLore.toArray(new String[itemLore.size()]), 1, true, false));
}
AddButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[] { }, 1, false), new SingleButton()
{
@Override
public void Clicked(Player player)
{
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, player));
}
});
}
public void purchaseMount(final Player player, final Mount<?> _mount)
@ -83,7 +94,7 @@ public class MountPage extends ShopPageBase<InventoryManager, InventoryShop>
{
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, player));
}
}, null, _mount, CurrencyType.Gems, Player));
}, null, _mount, CurrencyType.Coins, Player));
}
public void activateMount(Player player, Mount<?> _mount)

View File

@ -1,14 +1,18 @@
package mineplex.core.inventory.ui.page;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.inventory.ui.InventoryShop;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.item.SingleButton;
public class ParticlePage extends GadgetPage
{
@ -34,5 +38,14 @@ public class ParticlePage extends GadgetPage
if (slot == 26)
slot = 28;
}
AddButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[] { }, 1, false), new SingleButton()
{
@Override
public void Clicked(Player player)
{
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, player));
}
});
}
}

View File

@ -28,6 +28,7 @@ import mineplex.core.inventory.ui.button.RenamePetButton;
import mineplex.core.pet.Pet;
import mineplex.core.pet.PetExtra;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.item.SingleButton;
import mineplex.core.shop.page.AnvilContainer;
import mineplex.core.shop.page.ShopPageBase;
@ -52,7 +53,7 @@ public class PetPage extends ShopPageBase<InventoryManager, InventoryShop>
{
List<String> itemLore = new ArrayList<String>();
itemLore.add(C.cYellow + pet.GetCost(CurrencyType.Gems) + " Coins");
itemLore.add(C.cYellow + pet.GetCost(CurrencyType.Coins) + " Coins");
itemLore.add(C.cBlack);
if (DonationManager.Get(Player.getName()).OwnsUnknownPackage(pet.GetPetName()))
@ -99,6 +100,15 @@ public class PetPage extends ShopPageBase<InventoryManager, InventoryShop>
slot++;
}
AddButton(4, new ShopItem(Material.BED, C.cGray + " \u21FD Go Back", new String[] { }, 1, false), new SingleButton()
{
@Override
public void Clicked(Player player)
{
Shop.OpenPageForPlayer(Player, new Menu(Plugin, Shop, ClientManager, DonationManager, player));
}
});
}
public void purchasePet(final Player player, final Pet pet)

View File

@ -100,7 +100,7 @@ public class PetTagPage extends ShopPageBase<InventoryManager, InventoryShop>
Player.closeInventory();
}
}, null, _petPurchase ? _pet : tag, CurrencyType.Gems, Player));
}, null, _petPurchase ? _pet : tag, CurrencyType.Coins, Player));
}
public void SetTagName(String tagName)

View File

@ -20,9 +20,9 @@ public abstract class Mount<T> extends SalesPackageBase implements Listener
public MountManager Manager;
public Mount(MountManager manager, String name, Material material, byte displayData, String[] description, int gems)
public Mount(MountManager manager, String name, Material material, byte displayData, String[] description, int coins)
{
super(name, material, displayData, description, gems);
super(name, material, displayData, description, coins);
Manager = manager;
}

View File

@ -1,6 +1,7 @@
package mineplex.core.mount;
import java.util.HashSet;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Horse;
@ -26,7 +27,7 @@ public class MountManager extends MiniPlugin
private DonationManager _donationManager;
private BlockRestore _blockRestore;
private HashSet<Mount<?>> _types;
private List<Mount<?>> _types;
private NautHashMap<Player, Mount<?>> _playerActiveMountMap = new NautHashMap<Player, Mount<?>>();
public MountManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, BlockRestore blockRestore)
@ -42,7 +43,7 @@ public class MountManager extends MiniPlugin
private void CreateGadgets()
{
_types = new HashSet<Mount<?>>();
_types = new ArrayList<Mount<?>>();
_types.add(new Undead(this));
_types.add(new Frost(this));
@ -50,7 +51,7 @@ public class MountManager extends MiniPlugin
_types.add(new Dragon(this));
}
public HashSet<Mount<?>> getMounts()
public List<Mount<?>> getMounts()
{
return _types;
}

View File

@ -20,7 +20,7 @@ public class Pet extends SalesPackageBase
_name = name;
_petType = petType;
CurrencyCostMap.put(CurrencyType.Gems, cost);
CurrencyCostMap.put(CurrencyType.Coins, cost);
KnownPackage = false;
}

View File

@ -35,7 +35,7 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack
this(name, material, (byte)0, description, -1);
}
public SalesPackageBase(String name, Material material, byte displayData, String[] description, int gems)
public SalesPackageBase(String name, Material material, byte displayData, String[] description, int coins)
{
CurrencyCostMap = new NautHashMap<CurrencyType, Integer>();
@ -45,7 +45,7 @@ public abstract class SalesPackageBase implements ICurrencyPackage, IDisplayPack
_displayMaterial = material;
_displayData = displayData;
CurrencyCostMap.put(CurrencyType.Gems, gems);
CurrencyCostMap.put(CurrencyType.Coins, coins);
}
public abstract void Sold(Player player, CurrencyType currencyType);

View File

@ -15,11 +15,11 @@ import mineplex.core.database.column.ColumnVarChar;
public class StatsRepository extends RepositoryBase
{
private static String CREATE_STAT_TABLE = "CREATE TABLE IF NOT EXISTS stats (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(100), PRIMARY KEY (id), INDEX nameIndex (name));";
private static String CREATE_STAT_TABLE = "CREATE TABLE IF NOT EXISTS stats (id INT NOT NULL AUTO_INCREMENT, name VARCHAR(100), PRIMARY KEY (id), UNIQUE INDEX nameIndex (name));";
private static String CREATE_STAT_RELATION_TABLE = "CREATE TABLE IF NOT EXISTS accountStats (id INT NOT NULL AUTO_INCREMENT, accountId INT NOT NULL, statId INT NOT NULL, value INT NOT NULL, PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id), FOREIGN KEY (statId) REFERENCES stats(id), UNIQUE INDEX accountStatIndex (accountId, statId));";
private static String RETRIEVE_PLAYER_STATS = "SELECT stats.name, value FROM accountStats INNER JOIN stats ON stats.id = accountStats.statId INNER JOIN accounts ON accountStats.accountId = accounts.id WHERE accounts.uuid = ?;";
private static String INSERT_PLAYER_STAT = "INSERT INTO accountStats (accountId, statId, value) SELECT accounts.id, ?, ? FROM accounts WHERE accounts.uuid = ? ON DUPLICATE KEY UPDATE value=VALUES(value);";
private static String INSERT_PLAYER_STAT = "INSERT INTO accountStats (accountId, statId, value) SELECT accounts.id, ?, ? FROM accounts WHERE accounts.uuid = ? ON DUPLICATE KEY UPDATE value= value + VALUES(value);";
private static String RETRIEVE_STATS = "SELECT id, name FROM stats;";
private static String INSERT_STAT = "INSERT INTO stats (name) VALUES (?);";

View File

@ -23,6 +23,8 @@ public class HubClient
private int _lastGemCount = 0;
private int _lastCoinCount = 0;
public HubClient(String name)
{
ScoreboardString = " Welcome " + name + ", to the Mineplex Network!";
@ -131,4 +133,14 @@ public class HubClient
return display;
}
public void SetLastCoinCount(int coins)
{
_lastCoinCount = coins;
}
public int GetLastCoinCount()
{
return _lastCoinCount;
}
}

View File

@ -721,6 +721,18 @@ public class HubManager extends MiniClientPlugin<HubClient>
//Space
obj.getScore(" ").setScore(line--);
obj.getScore(C.cYellow + C.Bold + "Coins").setScore(line--);
// Remove Old
player.getScoreboard().resetScores(Get(player.getName()).GetLastCoinCount() + "");
// Add New
obj.getScore(GetDonation().Get(player.getName()).getCoins() + "").setScore(line--);
Get(player.getName()).SetLastCoinCount(GetDonation().Get(player.getName()).getCoins());
//Space
obj.getScore(" ").setScore(line--);
/*
//News
obj.getScore(C.cGray + C.Bold + "Latest News")).setScore(line--);
@ -735,7 +747,7 @@ public class HubManager extends MiniClientPlugin<HubClient>
obj.getScore(Get(player).BestPig).setScore(line--);
//Space
obj.getScore(" ").setScore(line--);
obj.getScore(" ").setScore(line--);
//Display Rank
if (GetClients().Get(player).GetRank().Has(Rank.HERO))
@ -763,33 +775,10 @@ public class HubManager extends MiniClientPlugin<HubClient>
//Space
obj.getScore(" ").setScore(line--);
//Display Staff
obj.getScore(C.cGold + C.Bold + "Online Staff").setScore(line--);
String staff = "";
for (Player other : UtilServer.getPlayers())
{
Rank rank = GetClients().Get(other).GetRank();
if (!rank.Has(Rank.HELPER))
continue;
staff += other.getName() + " ";
}
if (staff.length() == 0)
staff = "None";
player.getScoreboard().resetScores(Get(player).GetStaffText(false));
Get(player).StaffString = staff;
obj.getScore(Get(player).GetStaffText(true)).setScore(line--);
//Space
obj.getScore(" ").setScore(line--);
//Website
obj.getScore(C.cYellow + C.Bold + "Website").setScore(line--);
obj.getScore("www.mineplex.com").setScore(line--);
obj.getScore("----------------").setScore(line--);
}
}

View File

@ -69,6 +69,7 @@
<Compile Include="Model\Account\MacAddress.cs" />
<Compile Include="Model\Account\RemovedPunishment.cs" />
<Compile Include="Model\Sales\AccountTransaction.cs" />
<Compile Include="Model\Sales\CoinTransaction.cs" />
<Compile Include="Model\Sales\GemTransaction.cs" />
<Compile Include="Model\Server\GameServer\CaptureThePig\Stats\CaptureThePigGameStatsToken.cs" />
<Compile Include="Model\Server\GameServer\CaptureThePig\Stats\CaptureThePigPlayerStatsToken.cs" />

View File

@ -0,0 +1,13 @@
namespace LOC.Core.Model.Sales
{
public class CoinTransaction
{
public int CoinTransactionId { get; set; }
public Account.Account Account { get; set; }
public string Source { get; set; }
public int Amount { get; set; }
}
}

View File

@ -43,6 +43,7 @@ namespace LOC.Website.Common.Contexts
public DbSet<CaptureThePigPlayerStats> CaptureThePigPlayerStats { get; set; }
public DbSet<GemTransaction> GemTransactions { get; set; }
public DbSet<CoinTransaction> CoinTransactions { get; set; }
public DbSet<MineKart> MineKarts { get; set; }

View File

@ -220,6 +220,37 @@
return true;
}
public bool CoinReward(GemRewardToken token)
{
using (var repository = _repositoryFactory.CreateRepository())
{
var account = repository.Where<Account>(x => x.Name == token.Name).FirstOrDefault();
account.LoadNavigationProperties(repository.Context);
if (account == null)
return false;
account.Coins += token.Amount;
if (!token.Source.Contains("Earned") && !token.Source.Contains("Tutorial") && !token.Source.Contains("Parkour"))
{
var coinTransaction = new CoinTransaction
{
Source = token.Source,
Account = account,
Amount = token.Amount
};
repository.Add<CoinTransaction>(coinTransaction);
}
repository.Edit(account);
repository.CommitChanges();
}
return true;
}
public void AddTask(UpdateTaskToken token)
{
using (var repository = _repositoryFactory.CreateRepository())

View File

@ -36,5 +36,7 @@
void AddTask(UpdateTaskToken token);
void UpdateAccountUUIDs(List<AccountNameToken> tokens);
bool CoinReward(GemRewardToken token);
}
}

View File

@ -153,6 +153,13 @@
return Content(json, "application/json");
}
[HttpPost]
public ActionResult CoinReward(GemRewardToken token)
{
var json = JsonConvert.SerializeObject(_accountAdministrator.CoinReward(token));
return Content(json, "application/json");
}
[HttpPost]
public ActionResult RankUpdate(RankUpdateToken token)
{

File diff suppressed because it is too large Load Diff

Binary file not shown.