Merge branch 'master' of ssh://dev.mineplex.com:7999/min/mineplex
This commit is contained in:
commit
8e7b5ac6fe
@ -1,123 +0,0 @@
|
||||
package me.chiss.Core.ClientData;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import nautilus.minecraft.core.webserver.token.Account.AccountToken;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.server.IRepository;
|
||||
|
||||
public class ClientAcc extends ClientDataBase<AccountToken>
|
||||
{
|
||||
private long _playTime = 0;
|
||||
|
||||
private long _loginLast = 0;
|
||||
private int _loginCount = 0;
|
||||
|
||||
private String _ip = "Unknown";
|
||||
private String _mac = "Unknown";
|
||||
|
||||
private HashSet<String> _listIP = new HashSet<String>();
|
||||
private HashSet<String> _listMAC = new HashSet<String>();
|
||||
|
||||
private HashSet<String> _aliasIP = new HashSet<String>();
|
||||
private HashSet<String> _aliasMAC = new HashSet<String>();
|
||||
|
||||
public ClientAcc(CoreClient client, IRepository repository)
|
||||
{
|
||||
super(client, "Account", repository);
|
||||
}
|
||||
|
||||
public ClientAcc(CoreClient client, IRepository repository, AccountToken token)
|
||||
{
|
||||
super(client, "Account", repository, token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Load()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void LoadToken(AccountToken token)
|
||||
{
|
||||
_playTime = token.TotalPlayingTime;
|
||||
_loginLast = token.LastLogin;
|
||||
_loginCount = token.LoginCount;
|
||||
|
||||
_listIP = new HashSet<String>();
|
||||
_listMAC = new HashSet<String>();
|
||||
|
||||
_aliasIP = new HashSet<String>();
|
||||
_aliasMAC = new HashSet<String>();
|
||||
|
||||
_listIP.addAll(token.IpAddresses);
|
||||
_listMAC.addAll(token.MacAddresses);
|
||||
_aliasIP.addAll(token.IpAliases);
|
||||
_aliasMAC.addAll(token.MacAliases);
|
||||
}
|
||||
|
||||
public void SetIP(String ip)
|
||||
{
|
||||
_ip = ip;
|
||||
}
|
||||
|
||||
public String GetIP()
|
||||
{
|
||||
return _ip;
|
||||
}
|
||||
|
||||
public void SetMac(String mac)
|
||||
{
|
||||
_mac = mac;
|
||||
}
|
||||
|
||||
public String GetMac()
|
||||
{
|
||||
return _mac;
|
||||
}
|
||||
|
||||
public long GetPlayTime()
|
||||
{
|
||||
return _playTime;
|
||||
}
|
||||
|
||||
public long GetLoginLast()
|
||||
{
|
||||
if (_loginLast == 0)
|
||||
_loginLast = System.currentTimeMillis();
|
||||
|
||||
return _loginLast;
|
||||
}
|
||||
|
||||
public void SetLoginLast(long loginLast)
|
||||
{
|
||||
_loginLast = loginLast;
|
||||
}
|
||||
|
||||
public int GetLoginCount()
|
||||
{
|
||||
return _loginCount;
|
||||
}
|
||||
|
||||
public HashSet<String> GetListIP()
|
||||
{
|
||||
return _listIP;
|
||||
}
|
||||
|
||||
public HashSet<String> GetListMAC()
|
||||
{
|
||||
return _listMAC;
|
||||
}
|
||||
|
||||
public HashSet<String> GetAliasIP()
|
||||
{
|
||||
return _aliasIP;
|
||||
}
|
||||
|
||||
public HashSet<String> GetAliasMAC()
|
||||
{
|
||||
return _aliasMAC;
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
package me.chiss.Core.ClientData;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.server.IRepository;
|
||||
import mineplex.minecraft.punish.Tokens.PunishToken;
|
||||
|
||||
public class ClientBan extends ClientDataBase<PunishToken>
|
||||
{
|
||||
private PunishToken _activeBan;
|
||||
|
||||
public ClientBan(CoreClient client, IRepository repository)
|
||||
{
|
||||
super(client, "Ban", repository);
|
||||
//_bans = new LinkedList<ClientBanEntry>();
|
||||
}
|
||||
|
||||
public ClientBan(CoreClient client, IRepository repository, PunishToken banToken)
|
||||
{
|
||||
super(client, "Ban", repository, banToken);
|
||||
//_bans = new LinkedList<ClientBanEntry>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Load()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void LoadToken(PunishToken banToken)
|
||||
{
|
||||
_activeBan = banToken;
|
||||
}
|
||||
|
||||
public boolean IsBanned()
|
||||
{
|
||||
return _activeBan != null;
|
||||
}
|
||||
|
||||
public ClientBanEntry GetBan()
|
||||
{
|
||||
/*
|
||||
for (ClientBanEntry cur : _bans)
|
||||
if (cur.Active())
|
||||
return cur;
|
||||
|
||||
*/
|
||||
return null;
|
||||
}
|
||||
|
||||
public String Reason()
|
||||
{
|
||||
String reason = "Unknown";
|
||||
|
||||
if (_activeBan != null)
|
||||
{
|
||||
//reason = C.consoleBody + _activeBan.Reason + C.consoleFill + " - " + C.consoleBody + "Remaining : " + C.cGreen + UtilTime.convertString((long)(_activeBan.Hours * 3600000), 1, TimeUnit.FIT) + ".";
|
||||
}
|
||||
|
||||
return "Banned > " + reason;
|
||||
}
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
package me.chiss.Core.ClientData;
|
||||
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
|
||||
public class ClientBanEntry
|
||||
{
|
||||
public ClientBan _ban;
|
||||
public ClientBanEntry(ClientBan ban, String admin, Rank rank, String reason,
|
||||
long banTime, long banDuration, boolean alias, String ip, String mac)
|
||||
{
|
||||
_ban = ban;
|
||||
|
||||
_admin = admin;
|
||||
_rank = rank;
|
||||
_reason = reason;
|
||||
_banTime = banTime;
|
||||
_banDuration = banDuration;
|
||||
_aliasBan = alias;
|
||||
_ip = ip;
|
||||
_mac = mac;
|
||||
}
|
||||
|
||||
private boolean _unbanned = false;
|
||||
|
||||
private String _admin = "";
|
||||
private Rank _rank = Rank.ALL;
|
||||
private String _reason = "";
|
||||
|
||||
private long _banTime = 0;
|
||||
private long _banDuration = 0;
|
||||
|
||||
private boolean _aliasBan = false;
|
||||
private String _ip = "";
|
||||
private String _mac = "";
|
||||
|
||||
public boolean Active()
|
||||
{
|
||||
if (_unbanned)
|
||||
return false;
|
||||
|
||||
if (_banDuration == 0)
|
||||
return true;
|
||||
|
||||
return UtilTime.elapsed(_banTime, _banDuration);
|
||||
}
|
||||
|
||||
public boolean Alias()
|
||||
{
|
||||
return _aliasBan;
|
||||
}
|
||||
|
||||
public long Remaining()
|
||||
{
|
||||
return _banDuration - (System.currentTimeMillis() - _banTime);
|
||||
}
|
||||
|
||||
public String GetAdmin() {
|
||||
return _admin;
|
||||
}
|
||||
|
||||
public String GetReason() {
|
||||
return _reason;
|
||||
}
|
||||
|
||||
public long GetBanTime() {
|
||||
return _banTime;
|
||||
}
|
||||
|
||||
public long GetBanDuration() {
|
||||
return _banDuration;
|
||||
}
|
||||
|
||||
public boolean IsAliasBan() {
|
||||
return _aliasBan;
|
||||
}
|
||||
|
||||
public String GetIP() {
|
||||
return _ip;
|
||||
}
|
||||
|
||||
public String GetMac() {
|
||||
return _mac;
|
||||
}
|
||||
|
||||
public Rank GetRank() {
|
||||
return _rank;
|
||||
}
|
||||
|
||||
public boolean GetUnbanned() {
|
||||
return _unbanned;
|
||||
}
|
||||
|
||||
public void SetUnbanned(boolean _unbanned) {
|
||||
this._unbanned = _unbanned;
|
||||
}
|
||||
|
||||
public String RemainingString()
|
||||
{
|
||||
return UtilTime.convertString(Remaining(), 1, TimeUnit.FIT) + " Remaining";
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package me.chiss.Core.ClientData;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.server.IRepository;
|
||||
|
||||
public class ClientCondition extends ClientDataBase<String>
|
||||
{
|
||||
private HashMap<PotionEffectType, ClientConditionEntry> _conditions;
|
||||
|
||||
public ClientCondition(CoreClient client, IRepository repository)
|
||||
{
|
||||
super(client, "Condition", repository);
|
||||
}
|
||||
|
||||
public ClientCondition(CoreClient client, IRepository repository, String token)
|
||||
{
|
||||
super(client, "Condition", repository, token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Load()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void LoadToken(String token)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public HashMap<PotionEffectType, ClientConditionEntry> get_conditions() {
|
||||
return _conditions;
|
||||
}
|
||||
|
||||
public void set_conditions(HashMap<PotionEffectType, ClientConditionEntry> _conditions) {
|
||||
this._conditions = _conditions;
|
||||
}
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package me.chiss.Core.ClientData;
|
||||
|
||||
public class ClientConditionEntry {
|
||||
|
||||
}
|
@ -1,443 +0,0 @@
|
||||
package me.chiss.Core.ClientData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import nautilus.minecraft.core.webserver.token.Account.DonorToken;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.chiss.Core.Class.IPvpClass;
|
||||
import mineplex.core.CurrencyType;
|
||||
import mineplex.core.Rank;
|
||||
import mineplex.core.server.IRepository;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.minecraft.account.CoreClient;
|
||||
import mineplex.minecraft.game.classcombat.Class.repository.token.CustomBuildToken;
|
||||
import mineplex.minecraft.game.classcombat.Class.repository.token.SlotToken;
|
||||
import me.chiss.Core.Pet.repository.token.PetToken;
|
||||
import me.chiss.Core.Skill.ISkill;
|
||||
import me.chiss.Core.Skill.ISkill.SkillType;
|
||||
|
||||
public class ClientDonor
|
||||
{
|
||||
private DonationRepository
|
||||
private int _blueGems;
|
||||
private int _greenGems;
|
||||
private boolean _donated;
|
||||
private List<Integer> _salesPackagesOwned;
|
||||
|
||||
public ClientDonor(CoreClient client, IRepository repository)
|
||||
{
|
||||
super(client, "Donor", repository);
|
||||
}
|
||||
|
||||
public ClientDonor(CoreClient client, IRepository repository, DonorToken token)
|
||||
{
|
||||
super(client, "Donor", repository, token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Load()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void LoadToken(DonorToken token)
|
||||
{
|
||||
int creditChange = token.BlueGems - _blueGems;
|
||||
int pointChange = token.GreenGems - _greenGems;
|
||||
_blueGems = token.BlueGems;
|
||||
_greenGems = token.GreenGems;
|
||||
_donated = token.Donated;
|
||||
|
||||
_salesPackagesOwned = token.SalesPackages;
|
||||
|
||||
|
||||
|
||||
_customBuilds = new NautHashMap<IPvpClass, HashMap<Integer, CustomBuildToken>>();
|
||||
_activeCustomBuilds = new NautHashMap<IPvpClass, CustomBuildToken>();
|
||||
|
||||
if (Client.Manager().Classes() != null && Client.Manager.Skills() != null)
|
||||
{
|
||||
for (IPvpClass pvpClass : Client.Manager().Classes().GetAllClasses())
|
||||
{
|
||||
_customBuilds.put(pvpClass, new HashMap<Integer, CustomBuildToken>());
|
||||
}
|
||||
|
||||
for (CustomBuildToken buildToken : token.CustomBuilds)
|
||||
{
|
||||
IPvpClass pvpClass = Client.Manager().Classes().GetClass(buildToken.PvpClassId);
|
||||
|
||||
int skillTokenCount = buildToken.SkillTokensBalance;
|
||||
|
||||
Entry<ISkill, Integer> swordSkill = Client.Manager.Skills().GetSkillBySalesPackageId(buildToken.SwordSkillId);
|
||||
Entry<ISkill, Integer> axeSkill = Client.Manager.Skills().GetSkillBySalesPackageId(buildToken.AxeSkillId);
|
||||
Entry<ISkill, Integer> bowSkill = Client.Manager.Skills().GetSkillBySalesPackageId(buildToken.BowSkillId);
|
||||
Entry<ISkill, Integer> classPassiveASkill = Client.Manager.Skills().GetSkillBySalesPackageId(buildToken.ClassPassiveASkillId);
|
||||
Entry<ISkill, Integer> classPassiveBSkill = Client.Manager.Skills().GetSkillBySalesPackageId(buildToken.ClassPassiveBSkillId);
|
||||
Entry<ISkill, Integer> globalPassiveA = Client.Manager.Skills().GetSkillBySalesPackageId(buildToken.GlobalPassiveASkillId);
|
||||
Entry<ISkill, Integer> globalPassiveB = Client.Manager.Skills().GetSkillBySalesPackageId(buildToken.GlobalPassiveBSkillId);
|
||||
Entry<ISkill, Integer> globalPassiveC = Client.Manager.Skills().GetSkillBySalesPackageId(buildToken.GlobalPassiveCSkillId);
|
||||
|
||||
if (buildToken.SwordSkillId != -1 && (swordSkill == null || swordSkill.getKey().GetSkillType() != SkillType.Sword
|
||||
|| (!swordSkill.getKey().IsFree(swordSkill.getValue()) && !Owns(buildToken.SwordSkillId) && !Client.Rank().Has(Rank.DIAMOND, false))))
|
||||
continue;
|
||||
if (buildToken.AxeSkillId != -1 && (axeSkill == null || axeSkill.getKey().GetSkillType() != SkillType.Axe
|
||||
|| (!axeSkill.getKey().IsFree(axeSkill.getValue()) && !Owns(buildToken.AxeSkillId) && !Client.Rank().Has(Rank.DIAMOND, false))))
|
||||
continue;
|
||||
if (buildToken.BowSkillId != -1 && (bowSkill == null || bowSkill.getKey().GetSkillType() != SkillType.Bow
|
||||
|| (!bowSkill.getKey().IsFree(bowSkill.getValue()) && !Owns(buildToken.BowSkillId) && !Client.Rank().Has(Rank.DIAMOND, false))))
|
||||
continue;
|
||||
if (buildToken.ClassPassiveASkillId != -1 && (classPassiveASkill == null || classPassiveASkill.getKey().GetSkillType() != SkillType.PassiveA
|
||||
|| (!classPassiveASkill.getKey().IsFree(classPassiveASkill.getValue()) && !Owns(buildToken.ClassPassiveASkillId) && !Client.Rank().Has(Rank.DIAMOND, false))))
|
||||
continue;
|
||||
if (buildToken.ClassPassiveBSkillId != -1 && (classPassiveBSkill == null || classPassiveBSkill.getKey().GetSkillType() != SkillType.PassiveB
|
||||
|| (!classPassiveBSkill.getKey().IsFree(classPassiveBSkill.getValue()) && !Owns(buildToken.ClassPassiveBSkillId) && !Client.Rank().Has(Rank.DIAMOND, false))))
|
||||
continue;
|
||||
if (buildToken.GlobalPassiveASkillId != -1 && (globalPassiveA == null || globalPassiveA.getKey().GetSkillType() != SkillType.PassiveC
|
||||
|| (!globalPassiveA.getKey().IsFree(globalPassiveA.getValue()) && !Owns(buildToken.GlobalPassiveASkillId) && !Client.Rank().Has(Rank.DIAMOND, false))))
|
||||
continue;
|
||||
if (buildToken.GlobalPassiveBSkillId != -1 && (globalPassiveB == null || globalPassiveB.getKey().GetSkillType() != SkillType.PassiveD
|
||||
|| (!globalPassiveB.getKey().IsFree(globalPassiveB.getValue()) && !Owns(buildToken.GlobalPassiveBSkillId) && !Client.Rank().Has(Rank.DIAMOND, false))))
|
||||
continue;
|
||||
if (buildToken.GlobalPassiveCSkillId != -1 && (globalPassiveC == null || globalPassiveC.getKey().GetSkillType() != SkillType.PassiveE
|
||||
|| (!globalPassiveC.getKey().IsFree(globalPassiveC.getValue()) && !Owns(buildToken.GlobalPassiveCSkillId) && !Client.Rank().Has(Rank.DIAMOND, false))))
|
||||
continue;
|
||||
|
||||
if (buildToken.SwordSkillId != -1)
|
||||
skillTokenCount += swordSkill.getKey().GetTokenCost() * swordSkill.getValue();
|
||||
|
||||
if (buildToken.AxeSkillId != -1)
|
||||
skillTokenCount += axeSkill.getKey().GetTokenCost() * axeSkill.getValue();
|
||||
|
||||
if (buildToken.BowSkillId != -1)
|
||||
skillTokenCount += bowSkill.getKey().GetTokenCost() * bowSkill.getValue();
|
||||
|
||||
if (buildToken.ClassPassiveASkillId != -1)
|
||||
skillTokenCount += classPassiveASkill.getKey().GetTokenCost() * classPassiveASkill.getValue();
|
||||
|
||||
if (buildToken.ClassPassiveBSkillId != -1)
|
||||
skillTokenCount += classPassiveBSkill.getKey().GetTokenCost() * classPassiveBSkill.getValue();
|
||||
|
||||
if (buildToken.GlobalPassiveASkillId != -1)
|
||||
skillTokenCount += globalPassiveA.getKey().GetTokenCost() * globalPassiveA.getValue();
|
||||
|
||||
if (buildToken.GlobalPassiveBSkillId != -1)
|
||||
skillTokenCount += globalPassiveB.getKey().GetTokenCost() * globalPassiveB.getValue();
|
||||
|
||||
if (buildToken.GlobalPassiveCSkillId != -1)
|
||||
skillTokenCount += globalPassiveC.getKey().GetTokenCost() * globalPassiveC.getValue();
|
||||
|
||||
if (skillTokenCount <= 120)
|
||||
{
|
||||
_customBuilds.get(pvpClass).put(buildToken.CustomBuildNumber, buildToken);
|
||||
|
||||
if (buildToken.Active)
|
||||
{
|
||||
_activeCustomBuilds.put(pvpClass, buildToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Client.GetPlayer() != null)
|
||||
{
|
||||
if (creditChange > 0)
|
||||
{
|
||||
Client.GetPlayer().sendMessage(C.cGray + "You've received " + C.cAqua + pointChange + C.cGray + " credits. Thanks for donating!");
|
||||
}
|
||||
else if (creditChange < 0)
|
||||
{
|
||||
Client.GetPlayer().sendMessage(C.cGray + "Your credit balance is now : " + C.cAqua + pointChange + C.cGray + ".");
|
||||
}
|
||||
|
||||
if (pointChange > 0)
|
||||
{
|
||||
Client.GetPlayer().sendMessage(C.cGray + "You've received " + C.cGreen + pointChange + C.cGray + " points. Thanks for playing!");
|
||||
}
|
||||
else if (pointChange < 0)
|
||||
{
|
||||
Client.GetPlayer().sendMessage(C.cGray + "Your point balance is now : " + C.cGreen + pointChange + C.cGray + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int GetBlueGems()
|
||||
{
|
||||
return _blueGems;
|
||||
}
|
||||
|
||||
public int GetGreenGems()
|
||||
{
|
||||
return _greenGems;
|
||||
}
|
||||
|
||||
public void AddPoints(int points)
|
||||
{
|
||||
_greenGems += points;
|
||||
}
|
||||
|
||||
public List<Integer> GetSalesPackagesOwned()
|
||||
{
|
||||
return _salesPackagesOwned;
|
||||
}
|
||||
|
||||
public HashMap<Integer, CustomBuildToken> GetCustomBuilds(IPvpClass pvpClass)
|
||||
{
|
||||
return _customBuilds.get(pvpClass);
|
||||
}
|
||||
|
||||
public void PurchaseItem(int cost)
|
||||
{
|
||||
_itemTokens -= cost;
|
||||
}
|
||||
|
||||
public void PurchaseSkill(int cost)
|
||||
{
|
||||
_skillTokens -= cost;
|
||||
}
|
||||
|
||||
public void ReturnSkill(int cost)
|
||||
{
|
||||
_skillTokens += cost;
|
||||
}
|
||||
|
||||
public void ReturnItem(int cost)
|
||||
{
|
||||
_itemTokens += cost;
|
||||
}
|
||||
|
||||
public void SetCredits(int credits)
|
||||
{
|
||||
_blueGems = credits;
|
||||
}
|
||||
|
||||
public void DeductCost(int cost, CurrencyType currencyType, boolean premium)
|
||||
{
|
||||
switch (currencyType)
|
||||
{
|
||||
case Coins:
|
||||
Client.Game().SetEconomyBalance(Client.Game().GetEconomyBalance() - cost);
|
||||
break;
|
||||
case Gems:
|
||||
if (premium)
|
||||
_blueGems -= cost;
|
||||
else
|
||||
_greenGems -= cost;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean Owns(Integer salesPackageId)
|
||||
{
|
||||
return salesPackageId == -1 || _salesPackagesOwned.contains(salesPackageId);
|
||||
}
|
||||
|
||||
public void SetTokens(int skillTokens, int itemTokens)
|
||||
{
|
||||
_skillTokens = skillTokens;
|
||||
_itemTokens = itemTokens;
|
||||
}
|
||||
|
||||
public void SetDefaultTokens(int skillTokens, int itemTokens)
|
||||
{
|
||||
_defaultSkillTokens = skillTokens;
|
||||
_defaultItemTokens = itemTokens;
|
||||
}
|
||||
|
||||
public int GetSkillTokens()
|
||||
{
|
||||
return _skillTokens;
|
||||
}
|
||||
|
||||
public int GetItemTokens()
|
||||
{
|
||||
return _itemTokens;
|
||||
}
|
||||
|
||||
public void ResetItemTokens()
|
||||
{
|
||||
_itemTokens = _defaultItemTokens;
|
||||
}
|
||||
|
||||
public void ResetSkillTokens()
|
||||
{
|
||||
_skillTokens = _defaultSkillTokens;
|
||||
}
|
||||
|
||||
public void AddSalesPackagesOwned(int salesPackageId)
|
||||
{
|
||||
_salesPackagesOwned.add(salesPackageId);
|
||||
}
|
||||
|
||||
public void SetItemTokens(int itemTokens)
|
||||
{
|
||||
_itemTokens = itemTokens;
|
||||
}
|
||||
|
||||
public void SetSkillTokens(int skillTokens)
|
||||
{
|
||||
_skillTokens = skillTokens;
|
||||
}
|
||||
|
||||
public void SetPoints(int points)
|
||||
{
|
||||
_greenGems = points;
|
||||
}
|
||||
|
||||
public boolean HasDonated()
|
||||
{
|
||||
return _donated;
|
||||
}
|
||||
|
||||
public void SaveActiveCustomBuild(boolean saveItems)
|
||||
{
|
||||
if (Client == null || Client.Class().GetGameClass() == null)
|
||||
return;
|
||||
|
||||
_savingCustomBuild.PvpClassId = Client.Class().GetGameClass().GetSalesPackageId();
|
||||
_savingCustomBuild.PlayerName = Client.GetPlayerName();
|
||||
_savingCustomBuild.SkillTokensBalance = _skillTokens;
|
||||
_savingCustomBuild.ItemTokensBalance = _itemTokens;
|
||||
|
||||
ISkill swordSkill = Client.Class().GetSkillByType(SkillType.Sword);
|
||||
|
||||
if (swordSkill != null)
|
||||
_savingCustomBuild.SwordSkillId = swordSkill.GetSalesPackageId(Client.Class().GetSkillLevel(swordSkill));
|
||||
else
|
||||
_savingCustomBuild.SwordSkillId = -1;
|
||||
|
||||
ISkill axeSkill = Client.Class().GetSkillByType(SkillType.Axe);
|
||||
|
||||
if (axeSkill != null)
|
||||
_savingCustomBuild.AxeSkillId = axeSkill.GetSalesPackageId(Client.Class().GetSkillLevel(axeSkill));
|
||||
else
|
||||
_savingCustomBuild.AxeSkillId = -1;
|
||||
|
||||
ISkill bowSkill = Client.Class().GetSkillByType(SkillType.Bow);
|
||||
|
||||
if (bowSkill != null)
|
||||
_savingCustomBuild.BowSkillId = bowSkill.GetSalesPackageId(Client.Class().GetSkillLevel(bowSkill));
|
||||
else
|
||||
_savingCustomBuild.BowSkillId = -1;
|
||||
|
||||
ISkill passiveASkill = Client.Class().GetSkillByType(SkillType.PassiveA);
|
||||
|
||||
if (passiveASkill != null)
|
||||
_savingCustomBuild.ClassPassiveASkillId = passiveASkill.GetSalesPackageId(Client.Class().GetSkillLevel(passiveASkill));
|
||||
else
|
||||
_savingCustomBuild.ClassPassiveASkillId = -1;
|
||||
|
||||
ISkill passiveBSkill = Client.Class().GetSkillByType(SkillType.PassiveB);
|
||||
|
||||
if (passiveBSkill != null)
|
||||
_savingCustomBuild.ClassPassiveBSkillId = passiveBSkill.GetSalesPackageId(Client.Class().GetSkillLevel(passiveBSkill));
|
||||
else
|
||||
_savingCustomBuild.ClassPassiveBSkillId = -1;
|
||||
|
||||
ISkill passiveCSkill = Client.Class().GetSkillByType(SkillType.PassiveC);
|
||||
|
||||
if (passiveCSkill != null)
|
||||
_savingCustomBuild.GlobalPassiveASkillId = passiveCSkill.GetSalesPackageId(Client.Class().GetSkillLevel(passiveCSkill));
|
||||
else
|
||||
_savingCustomBuild.GlobalPassiveASkillId = -1;
|
||||
|
||||
ISkill passiveDSkill = Client.Class().GetSkillByType(SkillType.PassiveD);
|
||||
|
||||
if (passiveDSkill != null)
|
||||
_savingCustomBuild.GlobalPassiveBSkillId = passiveDSkill.GetSalesPackageId(Client.Class().GetSkillLevel(passiveDSkill));
|
||||
else
|
||||
_savingCustomBuild.GlobalPassiveBSkillId = -1;
|
||||
|
||||
ISkill passiveESkill = Client.Class().GetSkillByType(SkillType.PassiveE);
|
||||
|
||||
if (passiveESkill != null)
|
||||
_savingCustomBuild.GlobalPassiveCSkillId = passiveESkill.GetSalesPackageId(Client.Class().GetSkillLevel(passiveESkill));
|
||||
else
|
||||
_savingCustomBuild.GlobalPassiveCSkillId = -1;
|
||||
|
||||
_savingCustomBuild.Slots = new ArrayList<SlotToken>(9);
|
||||
|
||||
if (saveItems)
|
||||
{
|
||||
for (int i=0; i < 9; i++)
|
||||
{
|
||||
SlotToken slotToken = new SlotToken();
|
||||
ItemStack itemStack = Client.Class().GetInventory().getItem(i);
|
||||
slotToken.Material = itemStack == null ? org.bukkit.Material.AIR.toString() : itemStack.getType().toString();
|
||||
slotToken.Amount = itemStack == null ? 1 : itemStack.getAmount();
|
||||
|
||||
_savingCustomBuild.Slots.add(slotToken);
|
||||
}
|
||||
}
|
||||
|
||||
Repository.SaveCustomBuild(_savingCustomBuild);
|
||||
_savingCustomBuild = null;
|
||||
}
|
||||
|
||||
public void SetSavingCustomBuild(int i, IPvpClass pvpClass, CustomBuildToken customBuild)
|
||||
{
|
||||
_savingCustomBuild = customBuild;
|
||||
_savingCustomBuild.CustomBuildNumber = i;
|
||||
_customBuilds.get(pvpClass).put(i, _savingCustomBuild);
|
||||
}
|
||||
|
||||
public void SetActiveCustomBuild(int i, IPvpClass pvpClass, CustomBuildToken customBuild)
|
||||
{
|
||||
customBuild.Active = true;
|
||||
_activeCustomBuilds.put(pvpClass, customBuild);
|
||||
}
|
||||
|
||||
public CustomBuildToken GetActiveCustomBuild(IPvpClass pvpClass)
|
||||
{
|
||||
return _activeCustomBuilds.get(pvpClass);
|
||||
}
|
||||
|
||||
public CustomBuildToken GetSavingCustomBuild()
|
||||
{
|
||||
return _savingCustomBuild;
|
||||
}
|
||||
|
||||
public boolean IsSavingCustomBuild()
|
||||
{
|
||||
return _savingCustomBuild != null;
|
||||
}
|
||||
|
||||
public NautHashMap<EntityType, String> GetPets()
|
||||
{
|
||||
return _pets;
|
||||
}
|
||||
|
||||
public Integer GetPetNameTagCount()
|
||||
{
|
||||
return _petNameTagCount;
|
||||
}
|
||||
|
||||
public void SetPetNameTagCount(int count)
|
||||
{
|
||||
_petNameTagCount = count;
|
||||
}
|
||||
|
||||
public int GetBalance(CurrencyType currencyType, boolean premium)
|
||||
{
|
||||
switch (currencyType)
|
||||
{
|
||||
case Coins:
|
||||
return Client.Game().GetEconomyBalance();
|
||||
case Gems:
|
||||
return premium ? _blueGems : (_greenGems + _blueGems);
|
||||
case Tokens:
|
||||
return 0;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,282 +0,0 @@
|
||||
package me.chiss.Core.ClientData;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.HashMap;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
|
||||
public class ClientGame extends ClientDataBase<Object>
|
||||
{
|
||||
private String _lastTo = null;
|
||||
private String _lastAdminTo = null;
|
||||
private String _lastSentMessage = "";
|
||||
private String _lastReceivedMessage = "";
|
||||
|
||||
private String _lastChat = "";
|
||||
private boolean _unfilteredChat;
|
||||
|
||||
private boolean _cloaked = false;
|
||||
private long _cloakEnd = 0;
|
||||
|
||||
private HashMap<String, Long> _recharge = new HashMap<String, Long>();
|
||||
|
||||
private double _energy = 0;
|
||||
|
||||
private int _economyBalance;
|
||||
|
||||
private long _lastPPH = 0;
|
||||
|
||||
public ClientGame(CoreClient client)
|
||||
{
|
||||
super(client, "Game", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Load()
|
||||
{
|
||||
_economyBalance = 0;
|
||||
LoadEconomyBalance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void LoadToken(Object token)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public String GetLastTo() {
|
||||
return _lastTo;
|
||||
}
|
||||
|
||||
public void SetLastTo(String _lastTo) {
|
||||
this._lastTo = _lastTo;
|
||||
}
|
||||
|
||||
public String GetLastAdminTo() {
|
||||
return _lastAdminTo;
|
||||
}
|
||||
|
||||
public void SetLastAdminTo(String _lastAdminTo) {
|
||||
this._lastAdminTo = _lastAdminTo;
|
||||
}
|
||||
|
||||
public String GetLastSentMessage() {
|
||||
return _lastSentMessage;
|
||||
}
|
||||
|
||||
public void SetLastSentMessage(String _lastSentMessage) {
|
||||
this._lastSentMessage = _lastSentMessage;
|
||||
}
|
||||
|
||||
public String GetLastReceivedMessage() {
|
||||
return _lastReceivedMessage;
|
||||
}
|
||||
|
||||
public void SetLastReceivedMessage(String _lastReceivedMessage) {
|
||||
this._lastReceivedMessage = _lastReceivedMessage;
|
||||
}
|
||||
|
||||
public boolean IsCloaked() {
|
||||
return _cloaked;
|
||||
}
|
||||
|
||||
public void SetCloaked(boolean _cloaked) {
|
||||
this._cloaked = _cloaked;
|
||||
}
|
||||
|
||||
public long GetCloakEnd() {
|
||||
return _cloakEnd;
|
||||
}
|
||||
|
||||
public void SetCloakEnd(long _cloakEnd) {
|
||||
this._cloakEnd = _cloakEnd;
|
||||
}
|
||||
|
||||
public HashMap<String, Long> GetRecharge() {
|
||||
return _recharge;
|
||||
}
|
||||
|
||||
public void SetRecharge(HashMap<String, Long> _recharge) {
|
||||
this._recharge = _recharge;
|
||||
}
|
||||
|
||||
public double GetEnergy() {
|
||||
return _energy;
|
||||
}
|
||||
|
||||
public void SetEnergy(double _energy) {
|
||||
this._energy = _energy;
|
||||
}
|
||||
|
||||
public String GetLastChat() {
|
||||
return _lastChat;
|
||||
}
|
||||
|
||||
public void SetLastChat(String _lastChat) {
|
||||
this._lastChat = _lastChat;
|
||||
}
|
||||
|
||||
public int GetEconomyBalance()
|
||||
{
|
||||
return _economyBalance;
|
||||
}
|
||||
|
||||
public void SetEconomyBalance(int economyBalance)
|
||||
{
|
||||
_economyBalance = economyBalance;
|
||||
SaveEconomyBalance();
|
||||
}
|
||||
|
||||
public void ModifyEconomyBalance(int mod)
|
||||
{
|
||||
_economyBalance += mod;
|
||||
SaveEconomyBalance();
|
||||
}
|
||||
|
||||
public void LoadEconomyBalance()
|
||||
{
|
||||
FileInputStream fstream = null;
|
||||
DataInputStream in = null;
|
||||
BufferedReader br = null;
|
||||
|
||||
try
|
||||
{
|
||||
fstream = new FileInputStream("economy/" + Client.GetPlayerName() + ".dat");
|
||||
in = new DataInputStream(fstream);
|
||||
br = new BufferedReader(new InputStreamReader(in));
|
||||
String strLine = br.readLine();
|
||||
|
||||
try
|
||||
{
|
||||
_economyBalance = Integer.parseInt(strLine);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("Invalid Balance: " + Client.GetPlayerName());
|
||||
_economyBalance = 0;
|
||||
SaveEconomyBalance();
|
||||
}
|
||||
|
||||
in.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_economyBalance = 0;
|
||||
SaveEconomyBalance();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (br != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
br.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (in != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
in.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (fstream != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
fstream.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveEconomyBalance()
|
||||
{
|
||||
FileWriter fstream = null;
|
||||
BufferedWriter out = null;
|
||||
|
||||
try
|
||||
{
|
||||
File file = new File("economy/");
|
||||
file.mkdirs();
|
||||
|
||||
fstream = new FileWriter("economy/" + Client.GetPlayerName() + ".dat");
|
||||
out = new BufferedWriter(fstream);
|
||||
|
||||
out.write("" + _economyBalance);
|
||||
|
||||
out.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("Balance Save Error: " + e.getMessage());
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (out != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
out.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (fstream != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
fstream.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetFilterChat(boolean filterChat)
|
||||
{
|
||||
_unfilteredChat = filterChat;
|
||||
}
|
||||
|
||||
public boolean GetFilterChat()
|
||||
{
|
||||
return _unfilteredChat;
|
||||
}
|
||||
|
||||
public long GetLastPPH()
|
||||
{
|
||||
return _lastPPH;
|
||||
}
|
||||
|
||||
public void SetLastPPH(long _lastPPH)
|
||||
{
|
||||
this._lastPPH = _lastPPH;
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
package me.chiss.Core.ClientData;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import nautilus.minecraft.core.webserver.token.Account.ClientIgnoreToken;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
|
||||
public class ClientIgnore extends ClientDataBase<ClientIgnoreToken>
|
||||
{
|
||||
private HashSet<String> _ignore = new HashSet<String>();
|
||||
|
||||
public ClientIgnore(CoreClient client)
|
||||
{
|
||||
super(client, "Ignore", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Load()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void LoadToken(ClientIgnoreToken token)
|
||||
{
|
||||
if (token != null)
|
||||
{
|
||||
for (String cur : token.Ignored)
|
||||
_ignore.add(cur);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean ToggleIgnore(String name)
|
||||
{
|
||||
if (_ignore.contains(name))
|
||||
{
|
||||
//Memory
|
||||
_ignore.remove(name);
|
||||
|
||||
Save();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//Memory
|
||||
_ignore.add(name);
|
||||
|
||||
Save();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
//XXX
|
||||
}
|
||||
|
||||
public boolean IsIgnored(String name)
|
||||
{
|
||||
return _ignore.contains(name);
|
||||
}
|
||||
|
||||
public Set<String> GetIgnored()
|
||||
{
|
||||
return _ignore;
|
||||
}
|
||||
}
|
@ -1,116 +0,0 @@
|
||||
package me.chiss.Core.ClientData;
|
||||
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.minecraft.punish.Tokens.PunishToken;
|
||||
|
||||
public class ClientMute extends ClientDataBase<PunishToken>
|
||||
{
|
||||
private String _admin = "";
|
||||
private String _reason = "";
|
||||
private Rank _rank = Rank.ALL;
|
||||
|
||||
private long _muteTime = 0;
|
||||
private long _muteDuration = -1;
|
||||
|
||||
public ClientMute(CoreClient client)
|
||||
{
|
||||
super(client, "Mute", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Load()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void LoadToken(PunishToken token)
|
||||
{
|
||||
SetAdmin(token.Admin);
|
||||
//SetMuteDuration((long)(3600000 * token.Hours));
|
||||
SetMuteTime(System.currentTimeMillis());
|
||||
SetReason(token.Reason);
|
||||
}
|
||||
|
||||
public void DisplayData(Player player)
|
||||
{
|
||||
if (IsMuted())
|
||||
{
|
||||
player.sendMessage(F.value("Muted", "True", true));
|
||||
|
||||
player.sendMessage(F.value(1, "Date", UtilTime.when(_muteTime)));
|
||||
player.sendMessage(F.value(1, "Duration", UtilTime.when(_muteDuration)));
|
||||
if (_muteTime != 0)
|
||||
player.sendMessage(F.value(1, "Remaining", UtilTime.convertString(GetRemaining(), 1, TimeUnit.FIT)));
|
||||
player.sendMessage(F.value(1, "Admin", _admin));
|
||||
player.sendMessage(F.value(1, "Reason", _reason));
|
||||
}
|
||||
else
|
||||
{
|
||||
player.sendMessage(F.value("Muted", "False", false));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean IsMuted()
|
||||
{
|
||||
if (_muteDuration == -1)
|
||||
return false;
|
||||
|
||||
if (_muteDuration == 0)
|
||||
return true;
|
||||
|
||||
return !UtilTime.elapsed(_muteTime, _muteDuration);
|
||||
}
|
||||
|
||||
public long GetRemaining()
|
||||
{
|
||||
return _muteDuration - (System.currentTimeMillis() - _muteTime);
|
||||
}
|
||||
|
||||
public String GetAdmin() {
|
||||
return _admin;
|
||||
}
|
||||
|
||||
public void SetAdmin(String admin) {
|
||||
this._admin = admin;
|
||||
}
|
||||
|
||||
public String GetReason() {
|
||||
return _reason;
|
||||
}
|
||||
|
||||
public void SetReason(String reason) {
|
||||
this._reason = reason;
|
||||
}
|
||||
|
||||
public long GetMuteTime() {
|
||||
return _muteTime;
|
||||
}
|
||||
|
||||
public void SetMuteTime(long muteTime) {
|
||||
_muteTime = muteTime;
|
||||
}
|
||||
|
||||
public long GetMuteDuration() {
|
||||
return _muteDuration;
|
||||
}
|
||||
|
||||
public void SetMuteDuration(long muteDuration) {
|
||||
_muteDuration = muteDuration;
|
||||
}
|
||||
|
||||
public Rank GetRank() {
|
||||
return _rank;
|
||||
}
|
||||
|
||||
public void SetRank(Rank rank) {
|
||||
_rank = rank;
|
||||
}
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
package me.chiss.Core.ClientData;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
|
||||
public class ClientPlayer extends ClientDataBase<Object>
|
||||
{
|
||||
private long _lastAction = 0;
|
||||
private long _lastGrounded = 0;
|
||||
private long _lastMovement = 0;
|
||||
private long _lastDamagee = 0;
|
||||
private long _lastDamager = 0;
|
||||
private long _lastEnergy = 0;
|
||||
|
||||
private Location _lastLocation = null;
|
||||
|
||||
public ClientPlayer(CoreClient client)
|
||||
{
|
||||
super(client, "Player", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Load()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void LoadToken(Object token)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public long GetLastAction() {
|
||||
return _lastAction;
|
||||
}
|
||||
|
||||
public void SetLastAction(long _lastAction) {
|
||||
this._lastAction = _lastAction;
|
||||
}
|
||||
|
||||
public long GetLastGrounded() {
|
||||
return _lastGrounded;
|
||||
}
|
||||
|
||||
public void SetLastGrounded(long _lastGrounded) {
|
||||
this._lastGrounded = _lastGrounded;
|
||||
}
|
||||
|
||||
public long GetLastMovement() {
|
||||
return _lastMovement;
|
||||
}
|
||||
|
||||
public void SetLastMovement(long _lastMovement) {
|
||||
this._lastMovement = _lastMovement;
|
||||
}
|
||||
|
||||
public Location GetLastLocation() {
|
||||
return _lastLocation;
|
||||
}
|
||||
|
||||
public void SetLastLocation(Location _lastLocation) {
|
||||
this._lastLocation = _lastLocation;
|
||||
}
|
||||
|
||||
public long GetLastDamagee()
|
||||
{
|
||||
return _lastDamagee;
|
||||
}
|
||||
|
||||
public void SetLastDamagee(long _lastDamaged) {
|
||||
this._lastDamagee = _lastDamaged;
|
||||
}
|
||||
|
||||
public long GetLastDamager()
|
||||
{
|
||||
return _lastDamager;
|
||||
}
|
||||
|
||||
public void SetLastDamager(long _lastDamaged) {
|
||||
this._lastDamager = _lastDamaged;
|
||||
}
|
||||
|
||||
public long GetLastCombat()
|
||||
{
|
||||
if (_lastDamager > _lastDamagee)
|
||||
return _lastDamager;
|
||||
return _lastDamagee;
|
||||
}
|
||||
|
||||
public void SetLastEnergy(long time)
|
||||
{
|
||||
_lastEnergy = time;
|
||||
}
|
||||
|
||||
public long GetLastEnergy()
|
||||
{
|
||||
return _lastEnergy;
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
package me.chiss.Core.ClientData;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
|
||||
public class ClientPlayer extends ClientDataBase<Object>
|
||||
{
|
||||
private long _lastAction = 0;
|
||||
private long _lastGrounded = 0;
|
||||
private long _lastMovement = 0;
|
||||
private long _lastDamagee = 0;
|
||||
private long _lastDamager = 0;
|
||||
|
||||
private Location _lastLocation = null;
|
||||
|
||||
public ClientPlayer(CoreClient client)
|
||||
{
|
||||
super(client, "Player", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Load()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void LoadToken(Object token)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public long GetLastAction() {
|
||||
return _lastAction;
|
||||
}
|
||||
|
||||
public void SetLastAction(long _lastAction) {
|
||||
this._lastAction = _lastAction;
|
||||
}
|
||||
|
||||
public long GetLastGrounded() {
|
||||
return _lastGrounded;
|
||||
}
|
||||
|
||||
public void SetLastGrounded(long _lastGrounded) {
|
||||
this._lastGrounded = _lastGrounded;
|
||||
}
|
||||
|
||||
public long GetLastMovement() {
|
||||
return _lastMovement;
|
||||
}
|
||||
|
||||
public void SetLastMovement(long _lastMovement) {
|
||||
this._lastMovement = _lastMovement;
|
||||
}
|
||||
|
||||
public Location GetLastLocation() {
|
||||
return _lastLocation;
|
||||
}
|
||||
|
||||
public void SetLastLocation(Location _lastLocation) {
|
||||
this._lastLocation = _lastLocation;
|
||||
}
|
||||
|
||||
public long GetLastDamagee()
|
||||
{
|
||||
return _lastDamagee;
|
||||
}
|
||||
|
||||
public void SetLastDamagee(long _lastDamaged) {
|
||||
this._lastDamagee = _lastDamaged;
|
||||
}
|
||||
|
||||
public long GetLastDamager()
|
||||
{
|
||||
return _lastDamager;
|
||||
}
|
||||
|
||||
public void SetLastDamager(long _lastDamaged) {
|
||||
this._lastDamager = _lastDamaged;
|
||||
}
|
||||
|
||||
public long GetLastCombat()
|
||||
{
|
||||
if (_lastDamager > _lastDamagee)
|
||||
return _lastDamager;
|
||||
return _lastDamagee;
|
||||
}
|
||||
}
|
@ -1,62 +0,0 @@
|
||||
package me.chiss.Core.ClientData;
|
||||
|
||||
import mineplex.core.server.IRepository;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
public class ClientRank extends ClientDataBase<String>
|
||||
{
|
||||
private Rank _rank;
|
||||
|
||||
public ClientRank(CoreClient client, IRepository repository)
|
||||
{
|
||||
super(client, "Rank", repository);
|
||||
}
|
||||
|
||||
public ClientRank(CoreClient client, IRepository repository, String token)
|
||||
{
|
||||
super(client, "Rank", repository, token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Load()
|
||||
{
|
||||
_rank = Rank.ALL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void LoadToken(String token)
|
||||
{
|
||||
_rank = Rank.valueOf(token);
|
||||
}
|
||||
|
||||
public Rank GetRank()
|
||||
{
|
||||
return _rank;
|
||||
}
|
||||
|
||||
public boolean Has(Rank rank, boolean inform)
|
||||
{
|
||||
if (Client.GetPlayer() != null)
|
||||
if (Client.GetPlayer().isOp())
|
||||
return true;
|
||||
|
||||
if (_rank.compareTo(rank) <= 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (inform)
|
||||
{
|
||||
UtilPlayer.message(Client.GetPlayer(), C.mHead + "Permissions > " +
|
||||
C.mBody + "This requires Permission Rank [" +
|
||||
C.mHead + rank +
|
||||
C.mBody + "].");
|
||||
System.out.println("Rank: " + _rank + " compareTo:" + _rank.compareTo(rank));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
package me.chiss.Core.ClientData;
|
||||
|
||||
import nautilus.minecraft.core.webserver.token.Account.ClientWikiToken;
|
||||
import me.chiss.Core.Wiki.WikiArticle;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.server.IRepository;
|
||||
|
||||
public class ClientWiki extends ClientDataBase<ClientWikiToken>
|
||||
{
|
||||
private int _articlesActive = 0;
|
||||
private int _articlesDeprecated = 0;
|
||||
private int _articlesDenied = 0;
|
||||
|
||||
private WikiArticle _last = null;
|
||||
private long _lastTime = 0;
|
||||
|
||||
private String _lastBlock;
|
||||
|
||||
public ClientWiki(CoreClient client)
|
||||
{
|
||||
super(client, "Wiki", null);
|
||||
}
|
||||
|
||||
public ClientWiki(CoreClient client, IRepository repository, ClientWikiToken token)
|
||||
{
|
||||
super(client, "Wiki", repository, token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Load()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void LoadToken(ClientWikiToken token)
|
||||
{
|
||||
if (token == null)
|
||||
return;
|
||||
|
||||
_articlesActive = token.ArticlesActive;
|
||||
_articlesDeprecated = token.ArticlesDeprecated;
|
||||
_articlesDenied = token.ArticlesDenied;
|
||||
}
|
||||
|
||||
public WikiArticle GetLastArticle()
|
||||
{
|
||||
return _last;
|
||||
}
|
||||
|
||||
public void SetLastArticle(WikiArticle last)
|
||||
{
|
||||
_last = last;
|
||||
}
|
||||
|
||||
public long GetLastTime()
|
||||
{
|
||||
return _lastTime;
|
||||
}
|
||||
|
||||
public void SetLastTime(long lastTime)
|
||||
{
|
||||
_lastTime = lastTime;
|
||||
}
|
||||
|
||||
public String GetLastBlock()
|
||||
{
|
||||
return _lastBlock;
|
||||
}
|
||||
|
||||
public void SetLastBlock(String lastBlock)
|
||||
{
|
||||
_lastBlock = lastBlock;
|
||||
}
|
||||
|
||||
public int GetActive()
|
||||
{
|
||||
return _articlesActive;
|
||||
}
|
||||
|
||||
public int GetDeprecated()
|
||||
{
|
||||
return _articlesDeprecated;
|
||||
}
|
||||
|
||||
public int GetDenied()
|
||||
{
|
||||
return _articlesDenied;
|
||||
}
|
||||
|
||||
public void RegisterArticle(WikiArticle article)
|
||||
{
|
||||
if (article.GetRevision() > 0)
|
||||
{
|
||||
if (article.IsActive())
|
||||
_articlesActive++;
|
||||
else
|
||||
_articlesDeprecated++;
|
||||
}
|
||||
else
|
||||
_articlesDenied++;
|
||||
}
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package me.chiss.Core.ClientData;
|
||||
|
||||
public interface IClientDataLoad
|
||||
{
|
||||
public void Load();
|
||||
}
|
@ -1,127 +0,0 @@
|
||||
package me.chiss.Core.Shop;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import me.chiss.Core.Plugin.IPlugin;
|
||||
import me.chiss.Core.Shop.actions.ChangeCurrency;
|
||||
import me.chiss.Core.Shop.actions.NextPage;
|
||||
import me.chiss.Core.Shop.actions.PreviousPage;
|
||||
import me.chiss.Core.Shop.actions.Purchase;
|
||||
import me.chiss.Core.Shop.actions.Reset;
|
||||
import me.chiss.Core.Shop.actions.Return;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.currency.ItemTokenHandler;
|
||||
import me.chiss.Core.Shop.currency.SkillTokenHandler;
|
||||
import me.chiss.Core.Shop.page.IShopPage;
|
||||
import me.chiss.Core.Shop.pagebuilder.game.CustomBuildPageBuilder;
|
||||
import me.chiss.Core.Shop.pagebuilder.game.ItemPageBuilder;
|
||||
import me.chiss.Core.Shop.pagebuilder.game.SkillsPageBuilder;
|
||||
import me.chiss.Core.Shop.pagebuilder.game.WeaponPageBuilder;
|
||||
import me.chiss.Core.Weapon.IWeaponFactory;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.minecraft.game.classcombat.shop.page.ArmorPageBuilder;
|
||||
import mineplex.minecraft.game.core.classcombat.Class.ClassManager;
|
||||
import mineplex.minecraft.game.core.classcombat.Class.ClientClass;
|
||||
import mineplex.minecraft.game.core.classcombat.Class.IPvpClass.ClassType;
|
||||
import mineplex.minecraft.game.core.classcombat.Class.event.ClassSetupEvent;
|
||||
import mineplex.minecraft.game.core.classcombat.Class.event.ClassSetupEvent.SetupType;
|
||||
import mineplex.minecraft.game.core.classcombat.Skill.SkillFactory;
|
||||
import mineplex.minecraft.game.core.classcombat.item.IItemFactory;
|
||||
|
||||
public class CustomBuildShop extends Shop
|
||||
{
|
||||
private IWeaponFactory _weaponFactory;
|
||||
private IItemFactory _itemFactory;
|
||||
|
||||
public CustomBuildShop(IPlugin plugin, CoreClientManager manager, ClassManager gameClassFactory, SkillFactory skillFactory, IWeaponFactory weaponFactory, IItemFactory itemFactory)
|
||||
{
|
||||
super(plugin, manager);
|
||||
|
||||
_weaponFactory = weaponFactory;
|
||||
_itemFactory = itemFactory;
|
||||
|
||||
ShopBlockType = Material.ENCHANTMENT_TABLE;
|
||||
|
||||
ICurrencyHandler itemTokenHandler = new ItemTokenHandler();
|
||||
ICurrencyHandler skillTokenHandler = new SkillTokenHandler();
|
||||
|
||||
AddPageBuilder(new ArmorPageBuilder(this, "-----------Class-------Skills", gameClassFactory));
|
||||
AddPageBuilder(new CustomBuildPageBuilder(this, "Class------Custom------Skills", gameClassFactory));
|
||||
AddPageBuilder(new SkillsPageBuilder(this,"Class-------Skills-----------", skillFactory, gameClassFactory));
|
||||
|
||||
CreateShopActions();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void CreateShopActions()
|
||||
{
|
||||
new NextPage(Plugin.GetPlugin(), this, ClientManager);
|
||||
new PreviousPage(Plugin.GetPlugin(), this, ClientManager);
|
||||
new Reset(Plugin.GetPlugin(), this, ClientManager);
|
||||
new Return(Plugin.GetPlugin(), this, ClientManager, _weaponFactory, _itemFactory);
|
||||
new Purchase(Plugin.GetPlugin(), this, ClientManager);
|
||||
new ChangeCurrency(Plugin.GetPlugin(), this, ClientManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ShowSkillHotBarForPlayer(CoreClient player) { }
|
||||
|
||||
@Override
|
||||
public void OpenShopForPlayer(Player player)
|
||||
{
|
||||
super.OpenShopForPlayer(player);
|
||||
|
||||
ClientClass clientClass = ClassManager.Get(player);
|
||||
|
||||
ClassType classType = null;
|
||||
if (clientClass.GetGameClass() != null)
|
||||
classType = clientClass.GetGameClass().GetType();
|
||||
|
||||
ClassSetupEvent event = new ClassSetupEvent(player, SetupType.OpenMain, classType, 0, null);
|
||||
|
||||
UtilServer.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void CloseShopForPlayer(CoreClient player)
|
||||
{
|
||||
String key = player.GetPlayerName();
|
||||
GetPage(player).CloseForPlayer(player);
|
||||
|
||||
IShopPage page = GetPage(player);
|
||||
|
||||
while (page.HasPreviousPage())
|
||||
{
|
||||
page = page.GetPreviousPage();
|
||||
}
|
||||
|
||||
IShopPage nextPage;
|
||||
|
||||
while (page.HasNextPage())
|
||||
{
|
||||
nextPage = page.GetNextPage();
|
||||
page.SetNextPage(null);
|
||||
nextPage.SetPreviousPage(null);
|
||||
page = nextPage;
|
||||
}
|
||||
|
||||
PageMap.remove(key);
|
||||
|
||||
if (player.Donor().IsSavingCustomBuild())
|
||||
player.Donor().SaveActiveCustomBuild(true);
|
||||
|
||||
if (InventoryMap.containsKey(player.GetPlayerName()))
|
||||
{
|
||||
player.GetPlayer().getInventory().setContents(InventoryMap.get(player.GetPlayerName()));
|
||||
player.GetPlayer().getInventory().setArmorContents(ArmorMap.get(player.GetPlayerName()));
|
||||
player.Class().SetGameClass(null);
|
||||
InventoryMap.remove(key);
|
||||
ArmorMap.remove(key);
|
||||
}
|
||||
|
||||
player.GetPlayer().updateInventory();
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
package me.chiss.Core.Shop;
|
||||
|
||||
import me.chiss.Core.Class.IClassFactory;
|
||||
import me.chiss.Core.Plugin.IPlugin;
|
||||
import me.chiss.Core.Shop.actions.ChangeCurrency;
|
||||
import me.chiss.Core.Shop.actions.NextPage;
|
||||
import me.chiss.Core.Shop.actions.PreviousPage;
|
||||
import me.chiss.Core.Shop.actions.Purchase;
|
||||
import me.chiss.Core.Shop.currency.CreditHandler;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.currency.PointHandler;
|
||||
import me.chiss.Core.Shop.pagebuilder.game.purchase.ArmorPurchasePageBuilder;
|
||||
import me.chiss.Core.Shop.pagebuilder.game.purchase.ItemPurchasePageBuilder;
|
||||
import me.chiss.Core.Shop.pagebuilder.game.purchase.SkillsPurchasePageBuilder;
|
||||
import me.chiss.Core.Shop.pagebuilder.game.purchase.WeaponPurchasePageBuilder;
|
||||
import me.chiss.Core.Skill.ISkillFactory;
|
||||
import me.chiss.Core.Weapon.IWeaponFactory;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.server.IRepository;
|
||||
import mineplex.minecraft.game.core.classcombat.item.IItemFactory;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class DonatorShop extends Shop
|
||||
{
|
||||
public DonatorShop(IPlugin plugin, IRepository repository, CoreClientManager manager, IClassFactory gameClassFactory, ISkillFactory skillFactory, IWeaponFactory weaponFactory, IItemFactory itemFactory)
|
||||
{
|
||||
super(plugin, repository, manager);
|
||||
|
||||
ShopBlockType = Material.ENDER_CHEST;
|
||||
|
||||
ICurrencyHandler creditHandler = new CreditHandler();
|
||||
ICurrencyHandler pointHandler = new PointHandler();
|
||||
|
||||
AddPageBuilder(new ArmorPurchasePageBuilder(this, "-----------Class-------Skills", gameClassFactory, creditHandler, pointHandler));
|
||||
AddPageBuilder(new SkillsPurchasePageBuilder(this, "Class-------Skills----Weapons", skillFactory, gameClassFactory, creditHandler, pointHandler));
|
||||
AddPageBuilder(new WeaponPurchasePageBuilder(this, "Skills------Weapons-----Items", weaponFactory, gameClassFactory, creditHandler, pointHandler));
|
||||
AddPageBuilder(new ItemPurchasePageBuilder(this, "Weapons-----Items----------", itemFactory, creditHandler, pointHandler));
|
||||
|
||||
CreateShopActions();
|
||||
|
||||
RestoreInventory = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void CreateShopActions()
|
||||
{
|
||||
new NextPage(Plugin.GetPlugin(), this, ClientManager);
|
||||
new PreviousPage(Plugin.GetPlugin(), this, ClientManager);
|
||||
new Purchase(Plugin.GetPlugin(), this, ClientManager);
|
||||
new ChangeCurrency(Plugin.GetPlugin(), this, ClientManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ShowSkillHotBarForPlayer(CoreClient player) { }
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
package me.chiss.Core.Shop;
|
||||
|
||||
import me.chiss.Core.Plugin.IPlugin;
|
||||
import me.chiss.Core.Shop.actions.Return;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.currency.ItemTokenHandler;
|
||||
import me.chiss.Core.Shop.currency.SkillTokenHandler;
|
||||
import me.chiss.Core.Shop.pagebuilder.game.CustomBuildPageBuilder;
|
||||
import me.chiss.Core.Shop.pagebuilder.game.ItemPageBuilder;
|
||||
import me.chiss.Core.Shop.pagebuilder.game.SkillsPageBuilder;
|
||||
import me.chiss.Core.Shop.pagebuilder.game.WeaponPageBuilder;
|
||||
import me.chiss.Core.Weapon.IWeaponFactory;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.minecraft.game.classcombat.shop.page.ArmorPageBuilder;
|
||||
import mineplex.minecraft.game.core.classcombat.Class.ClassManager;
|
||||
import mineplex.minecraft.game.core.classcombat.Skill.SkillFactory;
|
||||
import mineplex.minecraft.game.core.classcombat.item.IItemFactory;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class GameShop extends Shop
|
||||
{
|
||||
public GameShop(JavaPlugin plugin, CoreClientManager manager, ClassManager gameClassFactory, SkillFactory skillFactory)
|
||||
{
|
||||
super(plugin, manager);
|
||||
|
||||
ICurrencyHandler itemTokenHandler = new ItemTokenHandler();
|
||||
ICurrencyHandler skillTokenHandler = new SkillTokenHandler();
|
||||
|
||||
AddPageBuilder(new ArmorPageBuilder(this, "-----------Class-------Skills", gameClassFactory));
|
||||
AddPageBuilder(new CustomBuildPageBuilder(this, "Class------Custom------Skills", gameClassFactory));
|
||||
AddPageBuilder(new SkillsPageBuilder(this,"Class-------Skills----Weapons", skillFactory, gameClassFactory));
|
||||
|
||||
CreateShopActions();
|
||||
}
|
||||
|
||||
public void GiveDefaultBuild(Player player)
|
||||
{
|
||||
CoreClient gamePlayer = ClientManager.Get(player);
|
||||
String key = gamePlayer.GetPlayerName();
|
||||
InventoryMap.put(key, player.getInventory().getContents());
|
||||
|
||||
if (!PageMap.containsKey(key))
|
||||
{
|
||||
BuildPagesForPlayer(gamePlayer);
|
||||
}
|
||||
|
||||
ShowSkillHotBarForPlayer(gamePlayer);
|
||||
|
||||
/* HARDCODE FTW */
|
||||
GetPage(gamePlayer).PrepSlotsForPlayer(gamePlayer);
|
||||
GetPage(gamePlayer).PlayerWants(gamePlayer, 11);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void CreateShopActions()
|
||||
{
|
||||
super.CreateShopActions();
|
||||
new Return(Plugin.GetPlugin(), this, ClientManager, _weaponFactory, _itemFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ShouldOpenShop(Block clickedBlock)
|
||||
{
|
||||
return super.ShouldOpenShop(clickedBlock) || clickedBlock.getType() == Material.ENCHANTMENT_TABLE;
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package me.chiss.Core.Shop;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface IButton
|
||||
{
|
||||
public void Clicked(Player player);
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
package me.chiss.Core.Shop;
|
||||
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import me.chiss.Core.Class.IClassFactory;
|
||||
import me.chiss.Core.Plugin.IPlugin;
|
||||
import me.chiss.Core.Shop.actions.Return;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.currency.ItemTokenHandler;
|
||||
import me.chiss.Core.Shop.currency.SkillTokenHandler;
|
||||
import me.chiss.Core.Shop.pagebuilder.game.PvpCustomBuildPageBuilder;
|
||||
import me.chiss.Core.Shop.pagebuilder.game.SkillsPageBuilder;
|
||||
import me.chiss.Core.Skill.ISkillFactory;
|
||||
import me.chiss.Core.Weapon.IWeaponFactory;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.server.IRepository;
|
||||
import mineplex.minecraft.game.core.classcombat.item.IItemFactory;
|
||||
|
||||
public class PvpBuildShop extends Shop
|
||||
{
|
||||
private IWeaponFactory _weaponFactory;
|
||||
private IItemFactory _itemFactory;
|
||||
|
||||
public PvpBuildShop(IPlugin plugin, IRepository repository, CoreClientManager manager, IClassFactory gameClassFactory, ISkillFactory skillFactory)
|
||||
{
|
||||
super(plugin, repository, manager);
|
||||
|
||||
ShopBlockType = Material.ENCHANTMENT_TABLE;
|
||||
|
||||
ICurrencyHandler itemTokenHandler = new ItemTokenHandler();
|
||||
ICurrencyHandler skillTokenHandler = new SkillTokenHandler();
|
||||
|
||||
AddPageBuilder(new PvpCustomBuildPageBuilder(this, "----------Builds------Skills", gameClassFactory, itemTokenHandler));
|
||||
AddPageBuilder(new SkillsPageBuilder(this,"Builds-------Skills---------", skillFactory, gameClassFactory, skillTokenHandler));
|
||||
|
||||
CreateShopActions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ShowSkillHotBarForPlayer(CoreClient player) { }
|
||||
|
||||
@Override
|
||||
protected void CreateShopActions()
|
||||
{
|
||||
super.CreateShopActions();
|
||||
new Return(Plugin.GetPlugin(), this, ClientManager, _weaponFactory, _itemFactory);
|
||||
}
|
||||
|
||||
public void CloseShopForPlayer(CoreClient player)
|
||||
{
|
||||
String key = player.GetPlayerName();
|
||||
GetPage(player).CloseForPlayer(player);
|
||||
|
||||
PageMap.remove(key);
|
||||
|
||||
if (player.Donor().IsSavingCustomBuild())
|
||||
player.Donor().SaveActiveCustomBuild(false);
|
||||
|
||||
if (InventoryMap.containsKey(player.GetPlayerName()))
|
||||
{
|
||||
player.Class().GetInventory().setContents(InventoryMap.get(player.GetPlayerName()));
|
||||
player.Class().GetInventory().setArmorContents(ArmorMap.get(player.GetPlayerName()));
|
||||
player.Donor().SetTokens(0, 0);
|
||||
player.Donor().SetDefaultTokens(0, 0);
|
||||
InventoryMap.remove(key);
|
||||
ArmorMap.remove(key);
|
||||
}
|
||||
|
||||
player.Class().UpdateInventory();
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package me.chiss.Core.Shop;
|
||||
|
||||
import me.chiss.Core.Class.IClassFactory;
|
||||
import me.chiss.Core.Plugin.IPlugin;
|
||||
import me.chiss.Core.Shop.actions.ChangeCurrency;
|
||||
import me.chiss.Core.Shop.actions.NextPage;
|
||||
import me.chiss.Core.Shop.actions.PreviousPage;
|
||||
import me.chiss.Core.Shop.actions.Purchase;
|
||||
import me.chiss.Core.Shop.currency.CreditHandler;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.currency.PointHandler;
|
||||
import me.chiss.Core.Shop.pagebuilder.game.purchase.ArmorPurchasePageBuilder;
|
||||
import me.chiss.Core.Shop.pagebuilder.game.purchase.SkillsPurchasePageBuilder;
|
||||
import me.chiss.Core.Skill.ISkillFactory;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.server.IRepository;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class PvpDonatorShop extends Shop
|
||||
{
|
||||
public PvpDonatorShop(IPlugin plugin, IRepository repository, CoreClientManager manager, IClassFactory gameClassFactory, ISkillFactory skillFactory)
|
||||
{
|
||||
super(plugin, repository, manager);
|
||||
|
||||
ShopBlockType = Material.ENDER_CHEST;
|
||||
|
||||
ICurrencyHandler creditHandler = new CreditHandler();
|
||||
ICurrencyHandler pointHandler = new PointHandler();
|
||||
|
||||
AddPageBuilder(new ArmorPurchasePageBuilder(this, "-----------Class-------Skills", gameClassFactory, creditHandler, pointHandler));
|
||||
AddPageBuilder(new SkillsPurchasePageBuilder(this, "Class-------Skills----------", skillFactory, gameClassFactory, creditHandler, pointHandler));
|
||||
|
||||
CreateShopActions();
|
||||
|
||||
RestoreInventory = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void CreateShopActions()
|
||||
{
|
||||
new NextPage(Plugin.GetPlugin(), this, ClientManager);
|
||||
new PreviousPage(Plugin.GetPlugin(), this, ClientManager);
|
||||
new Purchase(Plugin.GetPlugin(), this, ClientManager);
|
||||
new ChangeCurrency(Plugin.GetPlugin(), this, ClientManager);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ShowSkillHotBarForPlayer(CoreClient player) { }
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package me.chiss.Core.Shop;
|
||||
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
|
||||
import me.chiss.Core.Plugin.IPlugin;
|
||||
import me.chiss.Core.PvpShop.IPvpShopFactory;
|
||||
import me.chiss.Core.Shop.actions.PvpReturn;
|
||||
import me.chiss.Core.Shop.currency.EconomyHandler;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.pagebuilder.game.PvpShopPageBuilder;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.server.IRepository;
|
||||
|
||||
public class PvpItemShop extends Shop
|
||||
{
|
||||
IPvpShopFactory ShopFactory;
|
||||
|
||||
private String _npcKey;
|
||||
|
||||
public PvpItemShop(IPlugin plugin, IRepository repository, CoreClientManager accountManager, IPvpShopFactory shopFactory, String name)
|
||||
{
|
||||
super(plugin, repository, accountManager);
|
||||
|
||||
ShopBlockType = null;
|
||||
ShopFactory = shopFactory;
|
||||
_npcKey = ChatColor.stripColor(name);
|
||||
|
||||
ICurrencyHandler economyHandler = new EconomyHandler();
|
||||
|
||||
AddPageBuilder(new PvpShopPageBuilder(this, name, shopFactory, economyHandler));
|
||||
|
||||
CreateShopActions();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnPlayerInteractEntity(PlayerInteractEntityEvent event)
|
||||
{
|
||||
if (event.getRightClicked() instanceof LivingEntity && ((LivingEntity)event.getRightClicked()).isCustomNameVisible() && ChatColor.stripColor(((LivingEntity)event.getRightClicked()).getCustomName()).equalsIgnoreCase(_npcKey))
|
||||
{
|
||||
OpenShopForPlayer(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void CreateShopActions()
|
||||
{
|
||||
super.CreateShopActions();
|
||||
new PvpReturn(GetPlugin(), this, ClientManager, ShopFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ShowSkillHotBarForPlayer(CoreClient player)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -1,444 +0,0 @@
|
||||
package me.chiss.Core.Shop;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.minecraft.game.classcombat.Class.IPvpClass;
|
||||
import mineplex.minecraft.game.classcombat.Class.IPvpClass.ClassType;
|
||||
import mineplex.minecraft.game.classcombat.Class.event.ClassSetupEvent;
|
||||
import mineplex.minecraft.game.classcombat.Skill.ISkill;
|
||||
import mineplex.minecraft.game.classcombat.Skill.ISkill.SkillType;
|
||||
import me.chiss.Core.ClientData.IClientClass;
|
||||
import me.chiss.Core.Plugin.IPlugin;
|
||||
import me.chiss.Core.Shop.actions.ChangeCurrency;
|
||||
import me.chiss.Core.Shop.actions.NextPage;
|
||||
import me.chiss.Core.Shop.actions.PreviousPage;
|
||||
import me.chiss.Core.Shop.actions.Purchase;
|
||||
import me.chiss.Core.Shop.actions.Reset;
|
||||
import me.chiss.Core.Shop.page.IShopPage;
|
||||
import me.chiss.Core.Shop.pagebuilder.IPageBuilder;
|
||||
import me.chiss.Core.Shop.salespackage.ShopItem;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public abstract class Shop implements Listener
|
||||
{
|
||||
private HashMap<String, IPvpClass> _classMap;
|
||||
private HashMap<String, Long> _errorThrottling;
|
||||
private HashMap<String, Long> _purchaseBlock;
|
||||
|
||||
protected IPlugin Plugin;
|
||||
protected CoreClientManager ClientManager;
|
||||
protected List<IPageBuilder> PageBuilders;
|
||||
protected Material ShopBlockType;
|
||||
protected HashMap<String, ItemStack[]> InventoryMap;
|
||||
protected HashMap<String, ItemStack[]> ArmorMap;
|
||||
|
||||
protected HashMap<String, IShopPage> PageMap;
|
||||
|
||||
protected boolean RestoreInventory;
|
||||
|
||||
public Shop(IPlugin plugin, CoreClientManager accountManager)
|
||||
{
|
||||
Plugin = plugin;
|
||||
ClientManager = accountManager;
|
||||
PageBuilders = new ArrayList<IPageBuilder>();
|
||||
ShopBlockType = Material.AIR;
|
||||
PageMap = new HashMap<String, IShopPage>();
|
||||
InventoryMap = new HashMap<String, ItemStack[]>();
|
||||
ArmorMap = new HashMap<String, ItemStack[]>();
|
||||
_classMap = new HashMap<String, IPvpClass>();
|
||||
_errorThrottling = new HashMap<String, Long>();
|
||||
_purchaseBlock = new HashMap<String, Long>();
|
||||
|
||||
Plugin.GetPlugin().getServer().getPluginManager().registerEvents(this, Plugin.GetPlugin());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void OnPlayerClickItem(InventoryClickEvent event)
|
||||
{
|
||||
if (ClickedCurrentPage(event))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void OnPlayerPickupItem(PlayerPickupItemEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
if (GetPage(event.getPlayer().getName()) != null)
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnPlayerCloseInventory(InventoryCloseEvent event)
|
||||
{
|
||||
if (ClickedCurrentPage(event.getPlayer(), event.getInventory()))
|
||||
{
|
||||
CloseShopForPlayer(ClientManager.Get((Player)event.getPlayer()));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
IShopPage page = GetPage(event.getPlayer().getName());
|
||||
|
||||
if (page != null)
|
||||
{
|
||||
CloseShopForPlayer(ClientManager.Get((Player)event.getPlayer()));
|
||||
event.getPlayer().closeInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnPlayerOpenInventory(InventoryOpenEvent event)
|
||||
{
|
||||
if (event.isCancelled() && ClickedCurrentPage(event.getPlayer(), event.getInventory()))
|
||||
{
|
||||
CloseShopForPlayer(ClientManager.Get((Player)event.getPlayer()));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean ShouldOpenShop(Block clickedBlock)
|
||||
{
|
||||
return clickedBlock.getType() == ShopBlockType;
|
||||
}
|
||||
|
||||
public boolean HasNextPage(CoreClient gamePlayer)
|
||||
{
|
||||
String key = gamePlayer.GetPlayerName();
|
||||
return PageMap.get(key).HasNextPage();
|
||||
}
|
||||
|
||||
public boolean HasPreviousPage(CoreClient gamePlayer)
|
||||
{
|
||||
String key = gamePlayer.GetPlayerName();
|
||||
return PageMap.get(key).HasPreviousPage();
|
||||
}
|
||||
|
||||
public void OpenShopForPlayer(Player player)
|
||||
{
|
||||
CoreClient gamePlayer = ClientManager.Get(player);
|
||||
String key = gamePlayer.GetPlayerName();
|
||||
InventoryMap.put(key, player.getInventory().getContents().clone());
|
||||
ArmorMap.put(key, player.getInventory().getArmorContents());
|
||||
|
||||
if (!PageMap.containsKey(key))
|
||||
{
|
||||
BuildPagesForPlayer(gamePlayer);
|
||||
}
|
||||
|
||||
ShowSkillHotBarForPlayer(gamePlayer);
|
||||
|
||||
GetPage(gamePlayer).OpenForPlayer(gamePlayer);
|
||||
}
|
||||
|
||||
public void TurnToNextPage(CoreClient gamePlayer)
|
||||
{
|
||||
gamePlayer.GetPlayer().playSound(gamePlayer.GetPlayer().getLocation(), Sound.SILVERFISH_KILL, .6f, .9f);
|
||||
|
||||
GetPage(gamePlayer).CloseForPlayer(gamePlayer);
|
||||
|
||||
String key = gamePlayer.GetPlayerName();
|
||||
PageMap.put(key, PageMap.get(key).GetNextPage());
|
||||
|
||||
GetPage(gamePlayer).OpenForPlayer(gamePlayer);
|
||||
}
|
||||
|
||||
public void TurnToPreviousPage(CoreClient gamePlayer)
|
||||
{
|
||||
gamePlayer.GetPlayer().playSound(gamePlayer.GetPlayer().getLocation(), Sound.SILVERFISH_KILL, .6f, .9f);
|
||||
|
||||
GetPage(gamePlayer).CloseForPlayer(gamePlayer);
|
||||
|
||||
String key = gamePlayer.GetPlayerName();
|
||||
PageMap.put(key, PageMap.get(key).GetPreviousPage());
|
||||
|
||||
GetPage(gamePlayer).OpenForPlayer(gamePlayer);
|
||||
}
|
||||
|
||||
protected IShopPage GetPage(String playerName)
|
||||
{
|
||||
return PageMap.get(playerName);
|
||||
}
|
||||
|
||||
public IShopPage GetPage(CoreClient gamePlayer)
|
||||
{
|
||||
String key = gamePlayer.GetPlayerName();
|
||||
return PageMap.get(key);
|
||||
}
|
||||
|
||||
public void SetPage(CoreClient gamePlayer, IShopPage category)
|
||||
{
|
||||
String key = gamePlayer.GetPlayerName();
|
||||
PageMap.put(key, category);
|
||||
}
|
||||
|
||||
public boolean ClickedCurrentPage(InventoryClickEvent event)
|
||||
{
|
||||
return ClickedCurrentPage(event.getWhoClicked(), event.getInventory());
|
||||
}
|
||||
|
||||
public boolean ClickedCurrentPage(HumanEntity clicker, Inventory inventory)
|
||||
{
|
||||
return PageMap.containsKey(clicker.getName()) && inventory.getTitle().equalsIgnoreCase(GetPage(ClientManager.Get((Player)clicker)).GetTitle());
|
||||
}
|
||||
|
||||
protected void CreateShopActions()
|
||||
{
|
||||
new NextPage(Plugin.GetPlugin(), this, ClientManager);
|
||||
new PreviousPage(Plugin.GetPlugin(), this, ClientManager);
|
||||
new Purchase(Plugin.GetPlugin(), this, ClientManager);
|
||||
new Reset(Plugin.GetPlugin(), this, ClientManager);
|
||||
new ChangeCurrency(Plugin.GetPlugin(), this, ClientManager);
|
||||
}
|
||||
|
||||
protected void AddPageBuilder(IPageBuilder pageBuilder)
|
||||
{
|
||||
PageBuilders.add(pageBuilder);
|
||||
}
|
||||
|
||||
protected void BuildPagesForPlayer(CoreClient player)
|
||||
{
|
||||
String key = player.GetPlayerName();
|
||||
int pageNumber = 1;
|
||||
IShopPage previousPage = null;
|
||||
|
||||
for (IPageBuilder page : PageBuilders)
|
||||
{
|
||||
if (!PageMap.containsKey(key))
|
||||
{
|
||||
IShopPage newPage = page.BuildForPlayer(player);
|
||||
newPage.SetPageNumber(pageNumber);
|
||||
|
||||
PageMap.put(key, newPage);
|
||||
}
|
||||
else
|
||||
{
|
||||
previousPage = PageMap.get(key);
|
||||
|
||||
while (previousPage.HasNextPage())
|
||||
{
|
||||
previousPage = previousPage.GetNextPage();
|
||||
}
|
||||
|
||||
IShopPage newPage = page.BuildForPlayer(player);
|
||||
newPage.SetPageNumber(pageNumber);
|
||||
|
||||
previousPage.SetNextPage(newPage);
|
||||
newPage.SetPreviousPage(previousPage);
|
||||
}
|
||||
|
||||
pageNumber++;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void CloseShopForPlayer(CoreClient player)
|
||||
{
|
||||
String key = player.GetPlayerName();
|
||||
GetPage(player).CloseForPlayer(player);
|
||||
|
||||
IShopPage page = GetPage(player);
|
||||
|
||||
while (page.HasPreviousPage())
|
||||
{
|
||||
page = page.GetPreviousPage();
|
||||
}
|
||||
|
||||
IShopPage nextPage;
|
||||
|
||||
while (page.HasNextPage())
|
||||
{
|
||||
nextPage = page.GetNextPage();
|
||||
page.SetNextPage(null);
|
||||
nextPage.SetPreviousPage(null);
|
||||
page = nextPage;
|
||||
}
|
||||
|
||||
if (RestoreInventory)
|
||||
{
|
||||
if (InventoryMap.containsKey(player.GetPlayerName()))
|
||||
player.GetPlayer().getInventory().setContents(InventoryMap.get(player.GetPlayerName()));
|
||||
|
||||
if (ArmorMap.containsKey(player.GetPlayerName()))
|
||||
player.GetPlayer().getInventory().setArmorContents(ArmorMap.get(player.GetPlayerName()));
|
||||
}
|
||||
|
||||
player.GetPlayer().updateInventory();
|
||||
|
||||
PageMap.remove(key);
|
||||
InventoryMap.remove(key);
|
||||
ArmorMap.remove(key);
|
||||
|
||||
if (player.Donor().IsSavingCustomBuild())
|
||||
player.Donor().SaveActiveCustomBuild(true);
|
||||
|
||||
if (player.GetPlayer().isOnline())
|
||||
{
|
||||
player.GetPlayer().sendMessage(ChatColor.BLUE + "Shop>" + ChatColor.GRAY + " Visit " + ChatColor.YELLOW + Plugin.GetWebServerAddress() + "Store" + ChatColor.GRAY + " to purchase Credits!");
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetShopFor(Player player)
|
||||
{
|
||||
String key = player.getName();
|
||||
|
||||
if (PageMap.containsKey(key))
|
||||
{
|
||||
IShopPage currentPage = PageMap.get(key);
|
||||
|
||||
while (currentPage.HasNextPage())
|
||||
{
|
||||
currentPage = currentPage.GetNextPage();
|
||||
}
|
||||
|
||||
currentPage.ResetVisuals();
|
||||
|
||||
while (currentPage.HasPreviousPage())
|
||||
{
|
||||
currentPage = currentPage.GetPreviousPage();
|
||||
currentPage.ResetVisuals();
|
||||
}
|
||||
|
||||
PageMap.put(key, currentPage);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetClassForPlayer(CoreClient player, IPvpClass gameClass)
|
||||
{
|
||||
_classMap.put(player.GetPlayerName(), gameClass);
|
||||
}
|
||||
|
||||
public IPvpClass GetClassForPlayer(CoreClient player)
|
||||
{
|
||||
return _classMap.get(player.GetPlayerName());
|
||||
}
|
||||
|
||||
public void ShowSkillHotBarForPlayer(CoreClient player)
|
||||
{
|
||||
PlayerInventory playerInv = player.Class().GetInventory();
|
||||
|
||||
for (int i = 9; i < 18; i++)
|
||||
{
|
||||
playerInv.setItem(i, null);
|
||||
}
|
||||
|
||||
for (int i = 27; i < 36; i++)
|
||||
{
|
||||
playerInv.setItem(i, null);
|
||||
}
|
||||
|
||||
String[] skillList = new String[3];
|
||||
|
||||
ISkill swordSkill = player.Class().GetSkillByType(SkillType.Sword);
|
||||
ISkill axeSkill = player.Class().GetSkillByType(SkillType.Axe);
|
||||
ISkill bowSkill = player.Class().GetSkillByType(SkillType.Bow);
|
||||
ISkill classPassiveASkill = player.Class().GetSkillByType(SkillType.PassiveA);
|
||||
ISkill classPassiveBSkill = player.Class().GetSkillByType(SkillType.PassiveB);
|
||||
ISkill globalPassiveASkill = player.Class().GetSkillByType(SkillType.PassiveC);
|
||||
ISkill globalPassiveBSkill = player.Class().GetSkillByType(SkillType.PassiveD);
|
||||
ISkill globalPassiveCSkill = player.Class().GetSkillByType(SkillType.PassiveE);
|
||||
|
||||
String swordString = (swordSkill == null ? "None" : swordSkill.GetName() + " " + player.Class().GetSkillLevel(swordSkill));
|
||||
String axeString = (axeSkill == null ? "None" : axeSkill.GetName() + " " + player.Class().GetSkillLevel(axeSkill));
|
||||
String bowString = (bowSkill == null ? "None" : bowSkill.GetName() + " " + player.Class().GetSkillLevel(bowSkill));
|
||||
String classPassiveAString = (classPassiveASkill == null ? "None" : classPassiveASkill.GetName() + " " + player.Class().GetSkillLevel(classPassiveASkill));
|
||||
String classPassiveBString = (classPassiveBSkill == null ? "None" : classPassiveBSkill.GetName() + " " + player.Class().GetSkillLevel(classPassiveBSkill));
|
||||
String globalPassiveAString = (globalPassiveASkill == null ? "None" : globalPassiveASkill.GetName() + " " + player.Class().GetSkillLevel(globalPassiveASkill));
|
||||
String globalPassiveBString = (globalPassiveBSkill == null ? "None" : globalPassiveBSkill.GetName() + " " + player.Class().GetSkillLevel(globalPassiveBSkill));
|
||||
String globalPassiveCString = (globalPassiveCSkill == null ? "None" : globalPassiveCSkill.GetName() + " " + player.Class().GetSkillLevel(globalPassiveCSkill));
|
||||
|
||||
skillList[0] = C.cGray + "Weapon skills: " + swordString + ", " + axeString + ", " + bowString;
|
||||
skillList[1] = C.cGray + "Class Passive Skills: " + classPassiveAString + ", " + classPassiveBString;
|
||||
skillList[2] = C.cGray + "Global Passive Skills: " + globalPassiveAString + ", " + globalPassiveBString + ", " + globalPassiveCString;
|
||||
|
||||
ShopItem sword = new ShopItem(Material.IRON_SWORD, "Sword Skill:", GetLore(player.Class(), swordSkill), 1, true, true);
|
||||
ShopItem axe = new ShopItem(Material.IRON_AXE, "Axe Skill:", GetLore(player.Class(), axeSkill), 1, true, true);
|
||||
ShopItem bow = new ShopItem(Material.BOW, "Bow Skill:", GetLore(player.Class(), bowSkill), 1, true, true);
|
||||
ShopItem classPassiveA = new ShopItem(Material.BOOK, "Class Passive A Skills:", GetLore(player.Class(), classPassiveASkill), 1, true, true);
|
||||
ShopItem classPassiveB = new ShopItem(Material.BOOK, "Class Passive B Skills:", GetLore(player.Class(), classPassiveBSkill), 1, true, true);
|
||||
ShopItem globalPassiveA = new ShopItem(Material.BOOK, "Global Passive A Skill:", GetLore(player.Class(), globalPassiveASkill), 1, true, true);
|
||||
ShopItem globalPassiveB = new ShopItem(Material.BOOK, "Global Passive B Skill:", GetLore(player.Class(), globalPassiveBSkill), 1, true, true);
|
||||
ShopItem globalPassiveC = new ShopItem(Material.BOOK, "Global Passive C Skill:", GetLore(player.Class(), globalPassiveCSkill), 1, true, true);
|
||||
|
||||
playerInv.setItem(18, new ShopItem(Material.WRITTEN_BOOK, "Your Skills:", skillList, 1, true, true));
|
||||
playerInv.setItem(19, sword);
|
||||
playerInv.setItem(20, axe);
|
||||
playerInv.setItem(21, bow);
|
||||
playerInv.setItem(22, classPassiveA);
|
||||
playerInv.setItem(23, classPassiveB);
|
||||
playerInv.setItem(24, globalPassiveA);
|
||||
playerInv.setItem(25, globalPassiveB);
|
||||
playerInv.setItem(26, globalPassiveC);
|
||||
}
|
||||
|
||||
protected String[] GetLore(IClientClass playerClass, ISkill skill)
|
||||
{
|
||||
if (skill == null)
|
||||
return new String[] { ChatColor.GRAY + "None" };
|
||||
|
||||
int skillLevel = skill.;
|
||||
String[] lore = new String[2 + skill.GetDesc().length];
|
||||
lore[0] = ChatColor.GRAY + "§l" + (skillLevel == 0 ? "None" : (skill.GetName() + " " + skillLevel));
|
||||
|
||||
if (skillLevel != 0)
|
||||
lore[1] = " ";
|
||||
|
||||
for (int i=2; i <= skill.GetDesc().length; i++)
|
||||
{
|
||||
lore[i] = ChatColor.GRAY + "" + skill.GetDesc()[i-1];
|
||||
}
|
||||
|
||||
return lore;
|
||||
}
|
||||
|
||||
public JavaPlugin GetPlugin()
|
||||
{
|
||||
return Plugin.GetPlugin();
|
||||
}
|
||||
|
||||
public void AddPlayerProcessError(CoreClient player)
|
||||
{
|
||||
if (_errorThrottling.containsKey(player.GetPlayerName()) && (System.currentTimeMillis() - _errorThrottling.get(player.GetPlayerName()) <= 5000))
|
||||
_purchaseBlock.put(player.GetPlayerName(), System.currentTimeMillis());
|
||||
|
||||
_errorThrottling.put(player.GetPlayerName(), System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public boolean CanPlayerAttemptPurchase(CoreClient player)
|
||||
{
|
||||
return !_purchaseBlock.containsKey(player.GetPlayerName()) || (System.currentTimeMillis() - _purchaseBlock.get(player.GetPlayerName()) > 10000);
|
||||
}
|
||||
|
||||
public Material GetBlockType()
|
||||
{
|
||||
return ShopBlockType;
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package me.chiss.Core.Shop.actions;
|
||||
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class ChangeCurrency extends ShopActionBase
|
||||
{
|
||||
public ChangeCurrency(JavaPlugin plugin, Shop shop, CoreClientManager clientManager)
|
||||
{
|
||||
super(plugin, shop, clientManager);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void InventoryClick(InventoryClickEvent event)
|
||||
{
|
||||
if (Shop.ClickedCurrentPage(event) && event.isLeftClick() && event.getRawSlot() == 4)
|
||||
{
|
||||
CoreClient player = ClientManager.Get((Player)event.getWhoClicked());
|
||||
|
||||
Shop.GetPage(player).ChangeCurrency(player);
|
||||
Shop.GetPage(player).UpdateBalance(player);
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package me.chiss.Core.Shop.actions;
|
||||
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class NextPage extends ShopActionBase
|
||||
{
|
||||
public NextPage(JavaPlugin plugin, Shop shop, CoreClientManager clientManager)
|
||||
{
|
||||
super(plugin, shop, clientManager);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void InventoryClick(InventoryClickEvent event)
|
||||
{
|
||||
CoreClient player = ClientManager.Get((Player)event.getWhoClicked());
|
||||
|
||||
if (Shop.ClickedCurrentPage(event) && event.getRawSlot() == 8 && Shop.HasNextPage(player))
|
||||
{
|
||||
Shop.TurnToNextPage(player);
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package me.chiss.Core.Shop.actions;
|
||||
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class PreviousPage extends ShopActionBase
|
||||
{
|
||||
public PreviousPage(JavaPlugin plugin, Shop shop, CoreClientManager clientManager)
|
||||
{
|
||||
super(plugin, shop, clientManager);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void InventoryClick(InventoryClickEvent event)
|
||||
{
|
||||
CoreClient player = ClientManager.Get((Player)event.getWhoClicked());
|
||||
|
||||
if (Shop.ClickedCurrentPage(event) && event.getRawSlot() == 0 && Shop.HasPreviousPage(player))
|
||||
{
|
||||
Shop.TurnToPreviousPage(player);
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
package me.chiss.Core.Shop.actions;
|
||||
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Purchase extends ShopActionBase
|
||||
{
|
||||
public Purchase(JavaPlugin plugin, Shop shop, CoreClientManager clientManager)
|
||||
{
|
||||
super(plugin, shop, clientManager);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void InventoryClick(InventoryClickEvent event)
|
||||
{
|
||||
if (Shop.ClickedCurrentPage(event) && event.isLeftClick() && !event.isShiftClick() && event.getRawSlot() > 0)
|
||||
{
|
||||
if (event.getCurrentItem().getType() != Material.AIR)
|
||||
{
|
||||
if (event.getRawSlot() > 8 && event.getRawSlot() < 81)
|
||||
{
|
||||
CoreClient player = ClientManager.Get((Player)event.getWhoClicked());
|
||||
int slot = event.getRawSlot();
|
||||
|
||||
Shop.GetPage(player).PlayerWants(player, slot);
|
||||
|
||||
if (Shop.GetPage(player) != null)
|
||||
Shop.GetPage(player).UpdateBalance(player);
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,150 +0,0 @@
|
||||
package me.chiss.Core.Shop.actions;
|
||||
|
||||
import me.chiss.Core.PvpShop.IPvpShopFactory;
|
||||
import me.chiss.Core.PvpShop.IShopItem;
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilInv;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class PvpReturn extends ShopActionBase
|
||||
{
|
||||
private IPvpShopFactory _itemFactory;
|
||||
|
||||
public PvpReturn(JavaPlugin plugin, Shop shop, CoreClientManager clientManager, IPvpShopFactory itemFactory)
|
||||
{
|
||||
super(plugin, shop, clientManager);
|
||||
_itemFactory = itemFactory;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void InventoryClick(InventoryClickEvent event)
|
||||
{
|
||||
if (!Shop.ClickedCurrentPage(event))
|
||||
return;
|
||||
|
||||
if (!event.isRightClick())
|
||||
return;
|
||||
|
||||
if (event.isShiftClick())
|
||||
return;
|
||||
|
||||
if (event.getRawSlot() <= 0)
|
||||
return;
|
||||
|
||||
if (event.getCurrentItem().getType() == Material.AIR)
|
||||
return;
|
||||
|
||||
if (event.getRawSlot() >= 54 && event.getRawSlot() <= 89)
|
||||
SellStack(event);
|
||||
|
||||
if (event.getRawSlot() >= 9 && event.getRawSlot() <= 53)
|
||||
SellAll(event);
|
||||
}
|
||||
|
||||
public void SellAll(InventoryClickEvent event)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
CoreClient player = ClientManager.Get((Player)event.getWhoClicked());
|
||||
ItemStack playerItem = event.getCurrentItem();
|
||||
|
||||
if (playerItem == null || playerItem.getType() == Material.AIR)
|
||||
return;
|
||||
|
||||
boolean durable = (playerItem.getType().getMaxDurability() > 0);
|
||||
|
||||
IShopItem sellItem = null;
|
||||
|
||||
for(IShopItem item : _itemFactory.GetItems())
|
||||
{
|
||||
if (item.GetType() != playerItem.getType())
|
||||
continue;
|
||||
|
||||
//Compare Data for Non-Durable Only
|
||||
if (!durable)
|
||||
if (playerItem.getData() != null)
|
||||
if (item.GetData() != playerItem.getData().getData())
|
||||
continue;
|
||||
|
||||
sellItem = item;
|
||||
break;
|
||||
}
|
||||
|
||||
if (sellItem == null)
|
||||
return;
|
||||
|
||||
byte data = sellItem.GetData();
|
||||
if (durable)
|
||||
data = -1;
|
||||
|
||||
double cost = (double)sellItem.GetEconomyCost() / (double)sellItem.GetAmount() * sellItem.GetReturnPercent();
|
||||
int count = UtilInv.removeAll((Player)event.getWhoClicked(), sellItem.GetType(), data);
|
||||
|
||||
//Set Balance
|
||||
player.Game().SetEconomyBalance(player.Game().GetEconomyBalance() + (int)(count * cost));
|
||||
|
||||
//Update Balance
|
||||
Shop.GetPage(player).UpdateBalance(player);
|
||||
|
||||
//Effect
|
||||
player.GetPlayer().playSound(player.GetPlayer().getLocation(), Sound.PISTON_RETRACT, 0.5f, 2f);
|
||||
|
||||
//Inform
|
||||
UtilPlayer.message(event.getWhoClicked(), F.main("Shop", "You sold " +
|
||||
F.item(count + " " + sellItem.GetName()) + " for " + F.count((int)(count * cost) + " Coins") + "."));
|
||||
}
|
||||
|
||||
public void SellStack(InventoryClickEvent event)
|
||||
{
|
||||
CoreClient player = ClientManager.Get((Player)event.getWhoClicked());
|
||||
ItemStack playerItem = event.getCurrentItem();
|
||||
|
||||
if (playerItem == null || playerItem.getType() == Material.AIR)
|
||||
return;
|
||||
|
||||
for(IShopItem item : _itemFactory.GetItems())
|
||||
{
|
||||
if (item.GetType() != playerItem.getType())
|
||||
continue;
|
||||
|
||||
//Compare Data for Durable Only
|
||||
if (playerItem.getType().getMaxDurability() == 0)
|
||||
if (playerItem.getData() != null)
|
||||
if (item.GetData() != playerItem.getData().getData())
|
||||
continue;
|
||||
|
||||
double cost = (double)item.GetEconomyCost() / (double)item.GetAmount() * item.GetReturnPercent();
|
||||
int count = playerItem.getAmount();
|
||||
|
||||
//Set Balance
|
||||
player.Game().SetEconomyBalance(player.Game().GetEconomyBalance() + (int)(count * cost));
|
||||
|
||||
//Remove Item
|
||||
event.setCurrentItem(null);
|
||||
|
||||
//Update Balance
|
||||
Shop.GetPage(player).UpdateBalance(player);
|
||||
|
||||
//Effect
|
||||
player.GetPlayer().playSound(player.GetPlayer().getLocation(), Sound.PISTON_RETRACT, 0.5f, 2f);
|
||||
|
||||
//Inform
|
||||
UtilPlayer.message(event.getWhoClicked(), F.main("Shop", "You sold " +
|
||||
F.item(count + " " + item.GetName()) + " for " + F.count((int)(count * cost) + " Coins") + "."));
|
||||
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package me.chiss.Core.Shop.actions;
|
||||
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Reset extends ShopActionBase
|
||||
{
|
||||
public Reset(JavaPlugin plugin, Shop shop, CoreClientManager clientManager)
|
||||
{
|
||||
super(plugin, shop, clientManager);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void InventoryClick(InventoryClickEvent event)
|
||||
{
|
||||
if (Shop.ClickedCurrentPage(event) && event.isRightClick() && event.getRawSlot() == 4)
|
||||
{
|
||||
CoreClient player = ClientManager.Get((Player)event.getWhoClicked());
|
||||
|
||||
Shop.GetPage(player).Reset(player);
|
||||
Shop.GetPage(player).UpdateBalance(player);
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,100 +0,0 @@
|
||||
package me.chiss.Core.Shop.actions;
|
||||
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.salespackage.ShopItem;
|
||||
import me.chiss.Core.Utility.InventoryUtil;
|
||||
import me.chiss.Core.Weapon.IWeapon;
|
||||
import me.chiss.Core.Weapon.IWeaponFactory;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.minecraft.game.core.classcombat.item.IItem;
|
||||
import mineplex.minecraft.game.core.classcombat.item.IItemFactory;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftInventory;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Return extends ShopActionBase
|
||||
{
|
||||
private IWeaponFactory _weaponFactory;
|
||||
private IItemFactory _itemFactory;
|
||||
|
||||
public Return(JavaPlugin plugin, Shop shop, CoreClientManager clientManager, IWeaponFactory weaponFactory, IItemFactory itemFactory)
|
||||
{
|
||||
super(plugin, shop, clientManager);
|
||||
_weaponFactory = weaponFactory;
|
||||
_itemFactory = itemFactory;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void InventoryClick(InventoryClickEvent event)
|
||||
{
|
||||
if (Shop.ClickedCurrentPage(event) && event.isRightClick() && !event.isShiftClick() && event.getRawSlot() > 0)
|
||||
{
|
||||
if (event.getCurrentItem().getType() != Material.AIR)
|
||||
{
|
||||
if (event.getRawSlot() > 8 && event.getRawSlot() < 81)
|
||||
{
|
||||
CoreClient player = ClientManager.Get((Player)event.getWhoClicked());
|
||||
int slot = event.getRawSlot();
|
||||
|
||||
Shop.GetPage(player).PlayerReturning(player, slot);
|
||||
Shop.GetPage(player).UpdateBalance(player);
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
else if (event.getRawSlot() > 80 && event.getRawSlot() < 90)
|
||||
{
|
||||
CoreClient player = ClientManager.Get((Player)event.getWhoClicked());
|
||||
ItemStack playerItem = event.getCurrentItem();
|
||||
boolean foundItem = false;
|
||||
|
||||
for(IWeapon weapon : _weaponFactory.GetWeapons())
|
||||
{
|
||||
if (weapon.GetType() == playerItem.getType() && playerItem.getAmount() >= weapon.GetAmount() && playerItem.getDurability() == 0)
|
||||
{
|
||||
ItemStack itemStack = new ShopItem(weapon.GetType(), weapon.GetName(), weapon.GetAmount(), false);
|
||||
int returnAmount = InventoryUtil.GetCountOfObjectsRemovedInSlot((CraftInventory)player.Class().GetInventory(), event.getSlot(), itemStack);
|
||||
int cost = weapon.GetTokenCost();
|
||||
|
||||
player.Donor().ReturnItem(returnAmount * cost);
|
||||
foundItem = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundItem)
|
||||
{
|
||||
for(IItem item : _itemFactory.GetItems())
|
||||
{
|
||||
if (item.GetType() == playerItem.getType() && playerItem.getAmount() >= item.GetAmount() && playerItem.getDurability() == 0)
|
||||
{
|
||||
ItemStack itemStack = new ShopItem(item.GetType(), item.GetName(), item.GetAmount(), false);
|
||||
int returnAmount = InventoryUtil.GetCountOfObjectsRemovedInSlot((CraftInventory)player.Class().GetInventory(), event.getSlot(), itemStack);
|
||||
int cost = item.GetTokenCost();
|
||||
|
||||
player.Donor().ReturnItem(returnAmount * cost);
|
||||
foundItem = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (foundItem)
|
||||
{
|
||||
Shop.GetPage(player).UpdateBalance(player);
|
||||
|
||||
player.GetPlayer().playSound(player.GetPlayer().getLocation(), Sound.SPIDER_WALK, 1, .6f);
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package me.chiss.Core.Shop.actions;
|
||||
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public abstract class ShopActionBase implements Listener
|
||||
{
|
||||
protected JavaPlugin Plugin;
|
||||
protected Shop Shop;
|
||||
protected CoreClientManager ClientManager;
|
||||
|
||||
public ShopActionBase(JavaPlugin plugin, Shop shop, CoreClientManager clientManager)
|
||||
{
|
||||
Plugin = plugin;
|
||||
Shop = shop;
|
||||
ClientManager = clientManager;
|
||||
|
||||
Plugin.getServer().getPluginManager().registerEvents(this, Plugin);
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
package me.chiss.Core.Shop.currency;
|
||||
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
|
||||
public class CreditHandler implements ICurrencyHandler
|
||||
{
|
||||
@Override
|
||||
public int GetCost(ISalesPackage salesPackage)
|
||||
{
|
||||
return salesPackage.GetCreditCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Deduct(CoreClient player, ISalesPackage salesPackage)
|
||||
{
|
||||
player.Donor().SetCredits(player.Donor().GetBlueGems() - salesPackage.GetCreditCost());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Return(CoreClient player, ISalesPackage salesPackage)
|
||||
{
|
||||
player.Donor().SetCredits(player.Donor().GetBlueGems() + salesPackage.ReturnFrom(player) * salesPackage.GetCreditCost());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetName()
|
||||
{
|
||||
return "Credits";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean CanAfford(CoreClient player, ISalesPackage salesPackage)
|
||||
{
|
||||
return player.Donor().GetBlueGems() >= salesPackage.GetCreditCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material GetItemDisplayType()
|
||||
{
|
||||
return Material.DIAMOND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ResetBalance(CoreClient player)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetBalance(CoreClient player)
|
||||
{
|
||||
return player.Donor().GetBlueGems();
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
package me.chiss.Core.Shop.currency;
|
||||
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
|
||||
public class EconomyHandler implements ICurrencyHandler
|
||||
{
|
||||
@Override
|
||||
public int GetCost(ISalesPackage salesPackage)
|
||||
{
|
||||
return salesPackage.GetEconomyCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Deduct(CoreClient player, ISalesPackage salesPackage)
|
||||
{
|
||||
player.Game().SetEconomyBalance(player.Game().GetEconomyBalance() - salesPackage.GetEconomyCost());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Return(CoreClient player, ISalesPackage salesPackage)
|
||||
{
|
||||
player.Game().SetEconomyBalance(player.Game().GetEconomyBalance() + salesPackage.ReturnFrom(player) * salesPackage.GetEconomyCost());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetName()
|
||||
{
|
||||
return "Coins";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean CanAfford(CoreClient player, ISalesPackage salesPackage)
|
||||
{
|
||||
return player.Game().GetEconomyBalance() >= salesPackage.GetEconomyCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material GetItemDisplayType()
|
||||
{
|
||||
return Material.GOLD_INGOT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ResetBalance(CoreClient player)
|
||||
{
|
||||
//player.Game().SetEconomyBalance(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetBalance(CoreClient player)
|
||||
{
|
||||
return player.Game().GetEconomyBalance();
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package me.chiss.Core.Shop.currency;
|
||||
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
|
||||
public interface ICurrencyHandler
|
||||
{
|
||||
int GetCost(ISalesPackage salesPackage);
|
||||
void Deduct(CoreClient player, ISalesPackage salesPackage);
|
||||
void Return(CoreClient player, ISalesPackage salesPackage);
|
||||
String GetName();
|
||||
Material GetItemDisplayType();
|
||||
boolean CanAfford(CoreClient player, ISalesPackage salesPackage);
|
||||
void ResetBalance(CoreClient player);
|
||||
int GetBalance(CoreClient player);
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
package me.chiss.Core.Shop.currency;
|
||||
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
|
||||
public class ItemTokenHandler implements ICurrencyHandler
|
||||
{
|
||||
@Override
|
||||
public int GetCost(ISalesPackage salesPackage)
|
||||
{
|
||||
return salesPackage.GetTokenCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Deduct(CoreClient player, ISalesPackage salesPackage)
|
||||
{
|
||||
player.Donor().SetItemTokens(player.Donor().GetItemTokens() - salesPackage.GetTokenCost());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Return(CoreClient player, ISalesPackage salesPackage)
|
||||
{
|
||||
player.Donor().SetItemTokens(player.Donor().GetItemTokens() + salesPackage.ReturnFrom(player) * salesPackage.GetTokenCost());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetName()
|
||||
{
|
||||
return "Item Tokens";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean CanAfford(CoreClient player, ISalesPackage salesPackage)
|
||||
{
|
||||
return player.Donor().GetItemTokens() >= salesPackage.GetTokenCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material GetItemDisplayType()
|
||||
{
|
||||
return Material.EMERALD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ResetBalance(CoreClient player)
|
||||
{
|
||||
player.Donor().ResetItemTokens();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetBalance(CoreClient player)
|
||||
{
|
||||
return player.Donor().GetItemTokens();
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
package me.chiss.Core.Shop.currency;
|
||||
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
|
||||
public class PointHandler implements ICurrencyHandler
|
||||
{
|
||||
@Override
|
||||
public int GetCost(ISalesPackage salesPackage)
|
||||
{
|
||||
return salesPackage.GetPointCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Deduct(CoreClient player, ISalesPackage salesPackage)
|
||||
{
|
||||
player.Donor().SetPoints(player.Donor().GetGreenGems() - salesPackage.GetPointCost());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Return(CoreClient player, ISalesPackage salesPackage)
|
||||
{
|
||||
player.Donor().SetPoints(player.Donor().GetGreenGems() + salesPackage.ReturnFrom(player) * salesPackage.GetPointCost());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetName()
|
||||
{
|
||||
return "Points";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean CanAfford(CoreClient player, ISalesPackage salesPackage)
|
||||
{
|
||||
return player.Donor().GetGreenGems() >= salesPackage.GetPointCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material GetItemDisplayType()
|
||||
{
|
||||
return Material.EMERALD;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ResetBalance(CoreClient player)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetBalance(CoreClient player)
|
||||
{
|
||||
return player.Donor().GetGreenGems();
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
package me.chiss.Core.Shop.currency;
|
||||
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
|
||||
public class SkillTokenHandler implements ICurrencyHandler
|
||||
{
|
||||
@Override
|
||||
public int GetCost(ISalesPackage salesPackage)
|
||||
{
|
||||
return salesPackage.GetTokenCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Deduct(CoreClient player, ISalesPackage salesPackage)
|
||||
{
|
||||
player.Donor().SetSkillTokens(player.Donor().GetSkillTokens() - salesPackage.GetTokenCost());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Return(CoreClient player, ISalesPackage salesPackage)
|
||||
{
|
||||
player.Donor().SetSkillTokens(player.Donor().GetSkillTokens() + salesPackage.ReturnFrom(player) * salesPackage.GetTokenCost());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetName()
|
||||
{
|
||||
return "Skill Tokens";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean CanAfford(CoreClient player, ISalesPackage salesPackage)
|
||||
{
|
||||
return player.Donor().GetSkillTokens() >= salesPackage.GetTokenCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material GetItemDisplayType()
|
||||
{
|
||||
return Material.DIAMOND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ResetBalance(CoreClient player)
|
||||
{
|
||||
player.Donor().ResetSkillTokens();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetBalance(CoreClient player)
|
||||
{
|
||||
return player.Donor().GetSkillTokens();
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
package me.chiss.Core.Shop.events;
|
||||
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class PurchasePackageEvent extends Event implements Cancellable
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean _cancelled = false;
|
||||
|
||||
private String _playerName;
|
||||
private String _itemName;
|
||||
private String _reason;
|
||||
|
||||
public PurchasePackageEvent(String player, String item)
|
||||
{
|
||||
_playerName = player;
|
||||
_itemName = item;
|
||||
}
|
||||
|
||||
public String GetPlayerName()
|
||||
{
|
||||
return _playerName;
|
||||
}
|
||||
|
||||
public String GetItemName()
|
||||
{
|
||||
return _itemName;
|
||||
}
|
||||
|
||||
public String GetReason()
|
||||
{
|
||||
return _reason;
|
||||
}
|
||||
|
||||
public void SetReason(String reason)
|
||||
{
|
||||
_reason = reason;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return _cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel)
|
||||
{
|
||||
_cancelled = cancel;
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package me.chiss.Core.Shop.listeners;
|
||||
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
|
||||
public interface IPurchaseListener
|
||||
{
|
||||
void OnPurchasePackage(ISalesPackage salesPackage);
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package me.chiss.Core.Shop.listeners;
|
||||
|
||||
public interface IResetListener
|
||||
{
|
||||
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package me.chiss.Core.Shop.listeners;
|
||||
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
|
||||
public interface IReturnListener
|
||||
{
|
||||
void OnReturnPackage(ISalesPackage salesPackage);
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package me.chiss.Core.Shop.page;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
|
||||
public interface IPage<PageType extends IPage<PageType>>
|
||||
{
|
||||
String GetTitle();
|
||||
boolean HasNextPage();
|
||||
boolean HasPreviousPage();
|
||||
void SetPreviousPage(PageType previousPage);
|
||||
void SetNextPage(PageType nextPage);
|
||||
PageType GetPreviousPage();
|
||||
PageType GetNextPage();
|
||||
|
||||
void OpenForPlayer(CoreClient clicker);
|
||||
void CloseForPlayer(CoreClient clicker);
|
||||
|
||||
void SetPageNumber(int pageNumber);
|
||||
int GetPageNumber();
|
||||
|
||||
List<HumanEntity> getViewers();
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package me.chiss.Core.Shop.page;
|
||||
|
||||
import me.chiss.Core.Shop.salespackage.ISalesPackage;
|
||||
import mineplex.core.account.CoreClient;
|
||||
|
||||
public interface IShopPage extends IPage<IShopPage>
|
||||
{
|
||||
void AddItem(ISalesPackage iSalesPackage, int slot);
|
||||
ISalesPackage GetItem(int itemSlot);
|
||||
|
||||
void Reset(CoreClient player);
|
||||
|
||||
void PlayerWants(CoreClient donor, int slot);
|
||||
void PlayerReturning(CoreClient player, int slot);
|
||||
|
||||
void ChangeCurrency(CoreClient player);
|
||||
void UpdateBalance(CoreClient player);
|
||||
|
||||
void UpdateSlot(CoreClient player, int slot);
|
||||
void ResetVisuals();
|
||||
void PrepSlotsForPlayer(CoreClient player);
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
package me.chiss.Core.Shop.page;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import net.minecraft.server.v1_6_R3.Item;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftInventoryCustom;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemStack;
|
||||
|
||||
public class PageBase<PageType extends IPage<PageType>> extends CraftInventoryCustom implements IPage<PageType>
|
||||
{
|
||||
private int _pageNumber;
|
||||
|
||||
protected PageType PreviousPage;
|
||||
protected PageType NextPage;
|
||||
|
||||
public PageBase(String title)
|
||||
{
|
||||
super(null, 54, title);
|
||||
setMaxStackSize(128);
|
||||
}
|
||||
|
||||
public void SetPageNumber(int pageNumber)
|
||||
{
|
||||
_pageNumber = pageNumber;
|
||||
}
|
||||
|
||||
public int GetPageNumber()
|
||||
{
|
||||
return _pageNumber;
|
||||
}
|
||||
|
||||
public void SetPreviousPage(PageType previousPage)
|
||||
{
|
||||
if (previousPage != null)
|
||||
{
|
||||
getInventory().setItem(0, CraftItemStack.asNewCraftStack(Item.PAPER, previousPage.GetPageNumber()).getHandle());
|
||||
PreviousPage = previousPage;
|
||||
}
|
||||
}
|
||||
|
||||
public PageType GetPreviousPage()
|
||||
{
|
||||
return PreviousPage;
|
||||
}
|
||||
|
||||
public boolean HasPreviousPage()
|
||||
{
|
||||
return (PreviousPage != null);
|
||||
}
|
||||
|
||||
public void SetNextPage(PageType nextPage)
|
||||
{
|
||||
if (nextPage != null)
|
||||
{
|
||||
getInventory().setItem(8, CraftItemStack.asNewCraftStack(Item.PAPER, nextPage.GetPageNumber()).getHandle());
|
||||
NextPage = nextPage;
|
||||
}
|
||||
}
|
||||
|
||||
public PageType GetNextPage()
|
||||
{
|
||||
return NextPage;
|
||||
}
|
||||
|
||||
public boolean HasNextPage()
|
||||
{
|
||||
return (NextPage != null);
|
||||
}
|
||||
|
||||
public String GetTitle()
|
||||
{
|
||||
return getTitle();
|
||||
}
|
||||
|
||||
public void OpenForPlayer(CoreClient playerClient)
|
||||
{
|
||||
playerClient.GetPlayer().openInventory(this);
|
||||
}
|
||||
|
||||
public void CloseForPlayer(CoreClient playerClient)
|
||||
{
|
||||
playerClient.GetPlayer().closeInventory();
|
||||
this.inventory.onClose((CraftPlayer)playerClient.GetPlayer());
|
||||
}
|
||||
}
|
@ -1,208 +0,0 @@
|
||||
package me.chiss.Core.Shop.page;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.salespackage.ISalesPackage;
|
||||
import me.chiss.Core.Shop.salespackage.ItemPackage;
|
||||
import me.chiss.Core.Shop.salespackage.ShopItem;
|
||||
import mineplex.core.account.CoreClient;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer;
|
||||
|
||||
public abstract class ShopPageBase extends PageBase<IShopPage> implements IShopPage
|
||||
{
|
||||
protected Shop Shop;
|
||||
protected HashMap<Integer, ISalesPackage> SalesPackageMap;
|
||||
protected HashMap<Integer, ISalesPackage> UnlockedMap;
|
||||
protected HashMap<Integer, ISalesPackage> LockedMap;
|
||||
protected List<ICurrencyHandler> CurrencyHandlers;
|
||||
protected ICurrencyHandler CurrentCurrencyHandler;
|
||||
|
||||
public ShopPageBase(Shop shop, String title, List<ICurrencyHandler> currencyHandlers, HashMap<Integer, ISalesPackage> unlockedMap, HashMap<Integer, ISalesPackage> lockedMap)
|
||||
{
|
||||
super(title);
|
||||
|
||||
Shop = shop;
|
||||
SalesPackageMap = new HashMap<Integer, ISalesPackage>();
|
||||
UnlockedMap = unlockedMap;
|
||||
LockedMap = lockedMap;
|
||||
CurrencyHandlers = currencyHandlers;
|
||||
|
||||
if (CurrencyHandlers != null && CurrencyHandlers.size() > 0)
|
||||
CurrentCurrencyHandler = CurrencyHandlers.get(0);
|
||||
}
|
||||
|
||||
public ISalesPackage GetItem(int i)
|
||||
{
|
||||
return SalesPackageMap.get(i);
|
||||
}
|
||||
|
||||
public void UpdateBalance(CoreClient player)
|
||||
{
|
||||
int balance = CurrentCurrencyHandler.GetBalance(player);
|
||||
|
||||
String[] lore = new String[5];
|
||||
lore[0] = "§rBalance: " + ChatColor.YELLOW + balance + " " + CurrentCurrencyHandler.GetName();
|
||||
|
||||
SetResetButtonLore(balance, lore);
|
||||
}
|
||||
|
||||
protected void SetResetButtonLore(int balance, String[] lore)
|
||||
{
|
||||
lore[1] = "§rRight-click to return all items on this page.";
|
||||
|
||||
ShopItem currencyItem = new ShopItem(CurrentCurrencyHandler.GetItemDisplayType(), CurrentCurrencyHandler.GetName(), lore, 0, false, true);
|
||||
|
||||
/* Max is 64 still.
|
||||
if (balance <= 128)
|
||||
currencyItem.setAmount(balance);
|
||||
*/
|
||||
|
||||
setItem(4, currencyItem);
|
||||
}
|
||||
|
||||
public void ResetVisuals()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Reset(CoreClient player)
|
||||
{
|
||||
player.GetPlayer().playSound(player.GetPlayer().getLocation(), Sound.SPIDER_WALK, 1, .6f);
|
||||
|
||||
for (ISalesPackage salesPackage : SalesPackageMap.values())
|
||||
{
|
||||
CurrentCurrencyHandler.Return(player, salesPackage);
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenForPlayer(CoreClient playerClient)
|
||||
{
|
||||
PrepSlotsForPlayer(playerClient);
|
||||
|
||||
UpdateBalance(playerClient);
|
||||
|
||||
playerClient.GetPlayer().openInventory(this);
|
||||
}
|
||||
|
||||
public void PrepSlotsForPlayer(CoreClient playerClient)
|
||||
{
|
||||
for (int slot : UnlockedMap.keySet())
|
||||
{
|
||||
UpdateSlot(playerClient, slot);
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseForPlayer(CoreClient playerClient)
|
||||
{
|
||||
playerClient.GetPlayer().closeInventory();
|
||||
this.inventory.onClose((CraftPlayer)playerClient.GetPlayer());
|
||||
}
|
||||
|
||||
public void ChangeCurrency(CoreClient playerClient)
|
||||
{
|
||||
if (CurrencyHandlers != null)
|
||||
{
|
||||
if (CurrencyHandlers.size() > 1)
|
||||
{
|
||||
playerClient.GetPlayer().playSound(playerClient.GetPlayer().getLocation(), Sound.NOTE_PLING, 1, .6f);
|
||||
}
|
||||
else
|
||||
{
|
||||
playerClient.GetPlayer().playSound(playerClient.GetPlayer().getLocation(), Sound.ITEM_BREAK, 1, .6f);
|
||||
}
|
||||
|
||||
CurrentCurrencyHandler = GetNextCurrencyHandler();
|
||||
}
|
||||
}
|
||||
|
||||
protected ICurrencyHandler GetNextCurrencyHandler()
|
||||
{
|
||||
if (CurrencyHandlers.size() > 1)
|
||||
{
|
||||
int currentIndex = CurrencyHandlers.indexOf(CurrentCurrencyHandler);
|
||||
|
||||
if (currentIndex + 1 < CurrencyHandlers.size())
|
||||
{
|
||||
return CurrencyHandlers.get(currentIndex + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return CurrencyHandlers.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
return CurrentCurrencyHandler;
|
||||
}
|
||||
|
||||
public void PlayerWants(CoreClient player, int slot)
|
||||
{
|
||||
ISalesPackage sellable = GetItem(slot);
|
||||
|
||||
if (sellable != null && CanPurchasePackage(player, sellable))
|
||||
{
|
||||
PurchaseSalesPackage(player, sellable);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.GetPlayer().playSound(player.GetPlayer().getLocation(), Sound.ITEM_BREAK, 1f, .6f);
|
||||
}
|
||||
|
||||
UpdateSlot(player, slot);
|
||||
}
|
||||
|
||||
protected boolean CanPurchasePackage(CoreClient player, ISalesPackage sellable)
|
||||
{
|
||||
return CurrentCurrencyHandler.CanAfford(player, sellable) && sellable.CanFitIn(player);
|
||||
}
|
||||
|
||||
protected void PurchaseSalesPackage(CoreClient player, ISalesPackage sellable)
|
||||
{
|
||||
player.GetPlayer().playSound(player.GetPlayer().getLocation(), Sound.ORB_PICKUP, 1f, .6f);
|
||||
sellable.PurchaseBy(player);
|
||||
CurrentCurrencyHandler.Deduct(player, sellable);
|
||||
}
|
||||
|
||||
public void PlayerReturning(CoreClient player, int slot)
|
||||
{
|
||||
ISalesPackage sellable = GetItem(slot);
|
||||
|
||||
if (sellable != null && CurrentCurrencyHandler != null)
|
||||
{
|
||||
CurrentCurrencyHandler.Return(player, sellable);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddItem(ISalesPackage salesItem, int slot)
|
||||
{
|
||||
for (Integer salesItemslot : salesItem.AddToCategory(getInventory(), slot))
|
||||
{
|
||||
SalesPackageMap.put(salesItemslot, salesItem);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateSlot(CoreClient player, int slot)
|
||||
{
|
||||
if (UnlockedMap != null && UnlockedMap.get(slot) != null)
|
||||
{
|
||||
if (ShowUnlockedAtSlot(player, slot))
|
||||
{
|
||||
AddItem(UnlockedMap.get(slot), slot);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddItem(LockedMap.get(slot), slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean ShowUnlockedAtSlot(CoreClient player, int slot)
|
||||
{
|
||||
return player.Donor().Owns(UnlockedMap.get(slot).GetSalesPackageId()) || UnlockedMap.get(slot).IsFree();
|
||||
}
|
||||
}
|
@ -1,270 +0,0 @@
|
||||
package me.chiss.Core.Shop.page.game;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.chiss.Core.Class.IPvpClass;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.minecraft.game.core.classcombat.Class.repository.token.CustomBuildToken;
|
||||
import mineplex.minecraft.game.core.classcombat.events.ClassSetupEvent;
|
||||
import mineplex.minecraft.game.core.classcombat.events.ClassSetupEvent.SetupType;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
import mineplex.minecraft.shop.item.ItemPackage;
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.page.ShopPageBase;
|
||||
import me.chiss.Core.Shop.salespackage.ShopItem;
|
||||
|
||||
public class CustomBuildPage extends ShopPageBase
|
||||
{
|
||||
protected IPvpClass _currentClass;
|
||||
|
||||
protected HashMap<IPvpClass, HashMap<Integer, ISalesPackage>> UnlockedClassMap;
|
||||
protected HashMap<IPvpClass, HashMap<Integer, ISalesPackage>> LockedClassMap;
|
||||
|
||||
protected boolean equipItems = true;
|
||||
protected boolean equipDefaultArmor = true;
|
||||
protected boolean saveActiveCustomBuild = false;
|
||||
|
||||
public CustomBuildPage(Shop shop, String title, List<ICurrencyHandler> currencyHandlers, HashMap<IPvpClass, HashMap<Integer, ISalesPackage>> unlockedClassMap, HashMap<IPvpClass, HashMap<Integer, ISalesPackage>> lockedClassMap)
|
||||
{
|
||||
super(shop, title, currencyHandlers, null, null);
|
||||
|
||||
UnlockedClassMap = unlockedClassMap;
|
||||
LockedClassMap = lockedClassMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PlayerWants(CoreClient player, int slot)
|
||||
{
|
||||
ISalesPackage shopItem = GetItem(slot);
|
||||
if (shopItem != null)
|
||||
{
|
||||
ItemStack item = getItem(slot);
|
||||
|
||||
if (shopItem.CanFitIn(player))
|
||||
{
|
||||
int customBuildIndex = (slot % 9) / 2;
|
||||
CustomBuildToken customBuild;
|
||||
|
||||
if ((customBuildIndex > 1 && !player.Rank().Has(Rank.EMERALD, false))
|
||||
|| (customBuildIndex > 2 && !player.Rank().Has(Rank.DIAMOND, false)))
|
||||
{
|
||||
player.GetPlayer().playSound(player.GetPlayer().getLocation(), Sound.ITEM_BREAK, 1f, .6f);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player.Donor().GetCustomBuilds(_currentClass).containsKey(customBuildIndex))
|
||||
{
|
||||
customBuild = player.Donor().GetCustomBuilds(_currentClass).get(customBuildIndex);
|
||||
player.Donor().SetTokens(customBuild.SkillTokensBalance, customBuild.ItemTokensBalance);
|
||||
player.Donor().SetDefaultTokens(120, 120);
|
||||
}
|
||||
else
|
||||
{
|
||||
customBuild = new CustomBuildToken();
|
||||
customBuild.Name = "Build " + (customBuildIndex + 1);
|
||||
customBuild.PvpClassId = _currentClass.GetSalesPackageId();
|
||||
customBuild.SkillTokensBalance = 120;
|
||||
customBuild.ItemTokensBalance = 120;
|
||||
player.Donor().SetDefaultTokens(120, 120);
|
||||
}
|
||||
|
||||
player.Donor().SetActiveCustomBuild(customBuildIndex, _currentClass, customBuild);
|
||||
|
||||
if (item.getType() == Material.INK_SACK && item.getData().getData() != 8)
|
||||
{
|
||||
//Event
|
||||
ClassSetupEvent event = new ClassSetupEvent(player.GetPlayer(), SetupType.ApplyCustomBuild,
|
||||
_currentClass.GetType(), customBuild.CustomBuildNumber + 1, customBuild);
|
||||
Shop.GetPlugin().getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.IsCancelled())
|
||||
return;
|
||||
|
||||
player.Class().EquipCustomBuild(customBuild, equipItems, equipDefaultArmor);
|
||||
|
||||
if (saveActiveCustomBuild)
|
||||
player.Donor().SetSavingCustomBuild(customBuildIndex, _currentClass, customBuild);
|
||||
|
||||
Shop.CloseShopForPlayer(player);
|
||||
}
|
||||
else if (item.getType() == Material.ANVIL)
|
||||
{
|
||||
//Event
|
||||
ClassSetupEvent event = new ClassSetupEvent(player.GetPlayer(), SetupType.SaveEditCustomBuild,
|
||||
_currentClass.GetType(), customBuild.CustomBuildNumber + 1, customBuild);
|
||||
Shop.GetPlugin().getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.IsCancelled())
|
||||
return;
|
||||
|
||||
player.Class().EquipCustomBuild(customBuild, equipItems, equipDefaultArmor);
|
||||
player.Donor().SetSavingCustomBuild(customBuildIndex, _currentClass, customBuild);
|
||||
Shop.TurnToNextPage(player);
|
||||
}
|
||||
else if (item.getType() == Material.WORKBENCH && customBuild.CustomBuildNumber != null)
|
||||
{
|
||||
//Event
|
||||
ClassSetupEvent event = new ClassSetupEvent(player.GetPlayer(), SetupType.EditCustomBuild,
|
||||
_currentClass.GetType(), customBuild.CustomBuildNumber + 1, customBuild);
|
||||
Shop.GetPlugin().getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.IsCancelled())
|
||||
return;
|
||||
|
||||
player.Class().EquipCustomBuild(customBuild, equipItems, equipDefaultArmor);
|
||||
Shop.TurnToNextPage(player);
|
||||
}
|
||||
else if (item.getType() == Material.FIRE && customBuild.CustomBuildNumber != null)
|
||||
{
|
||||
//Event
|
||||
ClassSetupEvent event = new ClassSetupEvent(player.GetPlayer(), SetupType.DeleteCustomBuild,
|
||||
_currentClass.GetType(), customBuild.CustomBuildNumber + 1, customBuild);
|
||||
Shop.GetPlugin().getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.IsCancelled())
|
||||
return;
|
||||
|
||||
player.Donor().GetCustomBuilds(_currentClass).remove(customBuildIndex);
|
||||
ReconstructPageForPlayer(player);
|
||||
player.Class().UpdateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.GetPlayer().playSound(player.GetPlayer().getLocation(), Sound.ITEM_BREAK, 1f, .6f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void UpdateBalance(CoreClient player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Reset(CoreClient player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OpenForPlayer(CoreClient player)
|
||||
{
|
||||
if (_currentClass == null || _currentClass != player.Class().GetGameClass())
|
||||
{
|
||||
_currentClass = player.Class().GetGameClass();
|
||||
|
||||
if (_currentClass == null)
|
||||
_currentClass = Shop.GetClassForPlayer(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (player.Donor().IsSavingCustomBuild())
|
||||
player.Donor().SaveActiveCustomBuild(!equipItems);
|
||||
}
|
||||
|
||||
ReconstructPageForPlayer(player);
|
||||
|
||||
UpdateBalance(player);
|
||||
|
||||
player.Class().OpenInventory(this);
|
||||
}
|
||||
|
||||
private void ReconstructPageForPlayer(CoreClient player)
|
||||
{
|
||||
SalesPackageMap.clear();
|
||||
HashMap<Integer, ISalesPackage> packageMap = UnlockedClassMap.get(_currentClass);
|
||||
|
||||
if (_currentClass != null)
|
||||
{
|
||||
for (Entry<Integer, ISalesPackage> entry : packageMap.entrySet())
|
||||
{
|
||||
UpdateClassSlot(player, entry.getKey());
|
||||
}
|
||||
|
||||
int slot = 9;
|
||||
|
||||
for (int i=0; i < 5; i++)
|
||||
{
|
||||
byte itemData;
|
||||
String[] lockedText = new String[] { };
|
||||
boolean locked = false;
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
itemData = 1;
|
||||
break;
|
||||
case 1:
|
||||
itemData = 14;
|
||||
break;
|
||||
case 2:
|
||||
itemData = 11;
|
||||
|
||||
if (!player.Rank().Has(Rank.EMERALD, false))
|
||||
{
|
||||
locked = true;
|
||||
lockedText = new String[] { "§rGet " + (i < 3 ? "Silver" : "Gold") + " rank to access this slot" };
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
itemData = 2;
|
||||
|
||||
if (!player.Rank().Has(Rank.DIAMOND, false))
|
||||
{
|
||||
locked = true;
|
||||
lockedText = new String[] { "§rGet " + (i < 3 ? "GOLD" : "DIAMOND") + " rank to access this slot" };
|
||||
}
|
||||
break;
|
||||
default:
|
||||
itemData = 4;
|
||||
|
||||
if (!player.Rank().Has(Rank.DIAMOND, false))
|
||||
{
|
||||
locked = true;
|
||||
lockedText = new String[] { "§rGet " + (i < 3 ? "GOLD" : "DIAMOND") + " rank to access this slot" };
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (player.Donor().GetCustomBuilds(_currentClass).containsKey(i))
|
||||
{
|
||||
CustomBuildToken customBuild = player.Donor().GetCustomBuilds(_currentClass).get(i);
|
||||
|
||||
AddItem(new ItemPackage(new ShopItem(Material.INK_SACK, itemData, customBuild.Name, lockedText, 1, locked, true), 0, 0, 0, 0, false, -1), slot);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddItem(new ItemPackage(new ShopItem(Material.INK_SACK, (byte)8, locked ? "Locked Build" : "Unsaved Build", lockedText, 1, locked, true), 0, 0, 0, 0, false, -1), slot);
|
||||
}
|
||||
|
||||
slot += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void UpdateClassSlot(CoreClient player, int slot)
|
||||
{
|
||||
if (UnlockedClassMap.get(_currentClass).get(slot).IsFree()
|
||||
|| (player.Rank().Has(Rank.EMERALD, false) && slot % 9 == 4)
|
||||
|| (player.Rank().Has(Rank.DIAMOND, false) && (slot % 9 == 6 || slot % 9 == 8)))
|
||||
{
|
||||
AddItem(UnlockedClassMap.get(_currentClass).get(slot), slot);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddItem(LockedClassMap.get(_currentClass).get(slot), slot);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package me.chiss.Core.Shop.page.game;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.page.ShopPageBase;
|
||||
|
||||
public class ItemPage extends ShopPageBase
|
||||
{
|
||||
public ItemPage(Shop shop, String title, List<ICurrencyHandler> currencyHandlers, HashMap<Integer, ISalesPackage> unlockedMap, HashMap<Integer, ISalesPackage> lockedMap)
|
||||
{
|
||||
super(shop, title, currencyHandlers, unlockedMap, lockedMap);
|
||||
}
|
||||
|
||||
protected boolean ShowUnlockedAtSlot(CoreClient player, int slot)
|
||||
{
|
||||
return super.ShowUnlockedAtSlot(player, slot) || player.Rank().Has(Rank.EMERALD, false);
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
package me.chiss.Core.Shop.page.game;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import me.chiss.Core.Class.IPvpClass;
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
|
||||
public class PvpCustomBuildPage extends CustomBuildPage
|
||||
{
|
||||
public PvpCustomBuildPage(Shop shop, String title, List<ICurrencyHandler> currencyHandlers, HashMap<IPvpClass, HashMap<Integer, ISalesPackage>> unlockedClassMap, HashMap<IPvpClass, HashMap<Integer, ISalesPackage>> lockedClassMap)
|
||||
{
|
||||
super(shop, title, currencyHandlers, null, null);
|
||||
|
||||
UnlockedClassMap = unlockedClassMap;
|
||||
LockedClassMap = lockedClassMap;
|
||||
|
||||
equipItems = false;
|
||||
equipDefaultArmor = false;
|
||||
saveActiveCustomBuild = true;
|
||||
}
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package me.chiss.Core.Shop.page.game;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.page.ShopPageBase;
|
||||
import me.chiss.Core.Shop.salespackage.ShopItem;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
|
||||
public class ShopItemPage extends ShopPageBase
|
||||
{
|
||||
public ShopItemPage(Shop shop, String title, List<ICurrencyHandler> currencyHandlers, HashMap<Integer, ISalesPackage> unlockedMap, HashMap<Integer, ISalesPackage> lockedMap)
|
||||
{
|
||||
super(shop, title, currencyHandlers, unlockedMap, lockedMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void SetResetButtonLore(int balance, String[] lore)
|
||||
{
|
||||
setItem(4, new ShopItem(CurrentCurrencyHandler.GetItemDisplayType(), CurrentCurrencyHandler.GetName(), lore, 0, false, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void PurchaseSalesPackage(CoreClient player, ISalesPackage sellable)
|
||||
{
|
||||
player.GetPlayer().playSound(player.GetPlayer().getLocation(), Sound.ORB_PICKUP, 1f, .6f);
|
||||
sellable.PurchaseBy(player);
|
||||
CurrentCurrencyHandler.Deduct(player, sellable);
|
||||
}
|
||||
}
|
@ -1,340 +0,0 @@
|
||||
package me.chiss.Core.Shop.page.game;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.minecraft.game.core.classcombat.Class.IPvpClass;
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.page.ShopPageBase;
|
||||
import me.chiss.Core.Shop.salespackage.DonationPackage;
|
||||
import me.chiss.Core.Shop.salespackage.ISalesPackage;
|
||||
import me.chiss.Core.Shop.salespackage.ShopItem;
|
||||
import me.chiss.Core.Shop.salespackage.SkillPackage;
|
||||
|
||||
public class SkillsPage extends ShopPageBase
|
||||
{
|
||||
protected IPvpClass CurrentClass;
|
||||
protected HashMap<IPvpClass, HashMap<Integer, List<ISalesPackage>>> UnlockedClassMap;
|
||||
protected HashMap<Integer, List<ISalesPackage>> UnlockedGlobalMap;
|
||||
protected HashMap<IPvpClass, HashMap<Integer, List<ISalesPackage>>> LockedClassMap;
|
||||
protected HashMap<Integer, List<ISalesPackage>> LockedGlobalMap;
|
||||
|
||||
public SkillsPage(Shop shop, String title, List<ICurrencyHandler> currencyHandlers,
|
||||
HashMap<IPvpClass, HashMap<Integer, List<ISalesPackage>>> unlockedClassMap, HashMap<Integer, List<ISalesPackage>> unlockedGlobalMap,
|
||||
HashMap<IPvpClass, HashMap<Integer, List<ISalesPackage>>> lockedClassMap, HashMap<Integer, List<ISalesPackage>> lockedGlobalMap)
|
||||
{
|
||||
super(shop, title, currencyHandlers, null, null);
|
||||
|
||||
UnlockedClassMap = unlockedClassMap;
|
||||
UnlockedGlobalMap = unlockedGlobalMap;
|
||||
LockedClassMap = lockedClassMap;
|
||||
LockedGlobalMap = lockedGlobalMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OpenForPlayer(CoreClient player)
|
||||
{
|
||||
if (CurrentClass == null || CurrentClass != player.Class().GetGameClass())
|
||||
{
|
||||
CurrentClass = player.Class().GetGameClass();
|
||||
|
||||
if (CurrentClass == null)
|
||||
CurrentClass = Shop.GetClassForPlayer(player);
|
||||
}
|
||||
|
||||
ReconstructPageForPlayer(player);
|
||||
|
||||
PlayerInventory playerInv = player.Class().GetInventory();
|
||||
|
||||
for (int i = 9; i < 36; i++)
|
||||
{
|
||||
playerInv.setItem(i, null);
|
||||
}
|
||||
|
||||
TranslateIntoVirtualInventory(player);
|
||||
|
||||
UpdateBalance(player);
|
||||
|
||||
player.Class().OpenInventory(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void CloseForPlayer(CoreClient player)
|
||||
{
|
||||
PlayerInventory playerInv = player.Class().GetInventory();
|
||||
|
||||
for (int i = 9; i < 36; i++)
|
||||
{
|
||||
playerInv.setItem(i, null);
|
||||
}
|
||||
|
||||
Shop.ShowSkillHotBarForPlayer(player);
|
||||
|
||||
player.GetPlayer().closeInventory();
|
||||
this.inventory.onClose((CraftPlayer)player.GetPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PlayerWants(CoreClient player, int slot)
|
||||
{
|
||||
ISalesPackage sellable = GetItem(slot);
|
||||
|
||||
if (sellable == null)
|
||||
{
|
||||
player.GetPlayer().playSound(player.GetPlayer().getLocation(), Sound.ITEM_BREAK, 1f, .6f);
|
||||
return;
|
||||
}
|
||||
|
||||
if (CurrentCurrencyHandler.CanAfford(player, sellable) && sellable.CanFitIn(player))
|
||||
{
|
||||
PurchaseSalesPackage(player, sellable, slot);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.GetPlayer().playSound(player.GetPlayer().getLocation(), Sound.ITEM_BREAK, 1f, .6f);
|
||||
}
|
||||
}
|
||||
|
||||
protected void PurchaseSalesPackage(CoreClient player, ISalesPackage sellable, int slot)
|
||||
{
|
||||
if (sellable instanceof SkillPackage)
|
||||
{
|
||||
SkillPackage skillSellable = GetSkillPackage(sellable);
|
||||
|
||||
ISkill existingSkill = player.Class().GetSkillByType(skillSellable.GetSkill().GetSkillType());
|
||||
|
||||
if (existingSkill != null)
|
||||
{
|
||||
for (Entry<Integer, ISalesPackage> salesPackage : SalesPackageMap.entrySet())
|
||||
{
|
||||
if (salesPackage.getValue() instanceof SkillPackage)
|
||||
{
|
||||
SkillPackage otherSkillSellable = GetSkillPackage(salesPackage.getValue());
|
||||
|
||||
if (otherSkillSellable.GetSkill() == existingSkill)
|
||||
{
|
||||
if (existingSkill != skillSellable.GetSkill())
|
||||
{
|
||||
int skillLevel = player.Class().GetSkillLevel(existingSkill);
|
||||
for (int i=0; i < skillLevel; i++)
|
||||
{
|
||||
CurrentCurrencyHandler.Return(player, otherSkillSellable);
|
||||
}
|
||||
|
||||
otherSkillSellable.ReturnAllLevels(player);
|
||||
|
||||
if (slot >= 54)
|
||||
{
|
||||
UnlockedGlobalMap.get(salesPackage.getKey() - 45).get(0).DeliverTo(player.Class(), salesPackage.getKey() - 45);
|
||||
SalesPackageMap.put(salesPackage.getKey(), UnlockedGlobalMap.get(salesPackage.getKey() - 45).get(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
AddItem(UnlockedClassMap.get(CurrentClass).get(salesPackage.getKey()).get(0), salesPackage.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!skillSellable.IsActive() || skillSellable.GetLevel() < skillSellable.GetSkill().GetMaxLevel())
|
||||
{
|
||||
int index = skillSellable.IsActive() ? skillSellable.GetLevel() + 1 : skillSellable.GetLevel();
|
||||
|
||||
if (player.Donor().Owns(skillSellable.GetSkill().GetSalesPackageId(index)) || skillSellable.GetSkill().IsFree(index) || player.Rank().Has(Rank.DIAMOND, false))
|
||||
{
|
||||
player.GetPlayer().playSound(player.GetPlayer().getLocation(), Sound.ORB_PICKUP, 1f, .6f);
|
||||
|
||||
if (slot >= 54)
|
||||
{
|
||||
UpdateGlobalSlot(player, slot, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateClassSlot(player, slot, index);
|
||||
}
|
||||
|
||||
GetItem(slot).PurchaseBy(player);
|
||||
CurrentCurrencyHandler.Deduct(player, GetItem(slot));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Reset(CoreClient player)
|
||||
{
|
||||
player.GetPlayer().playSound(player.GetPlayer().getLocation(), Sound.SPIDER_WALK, 1, .6f);
|
||||
|
||||
for (Entry<Integer, ISalesPackage> entry : SalesPackageMap.entrySet())
|
||||
{
|
||||
if (entry.getValue() instanceof SkillPackage)
|
||||
{
|
||||
SkillPackage skillSellable = (SkillPackage)entry.getValue();
|
||||
int skillLevel = player.Class().GetSkillLevel(skillSellable.GetSkill());
|
||||
|
||||
for (int i=0; i < skillLevel; i++)
|
||||
CurrentCurrencyHandler.Return(player, skillSellable);
|
||||
|
||||
skillSellable.ReturnAllLevels(player);
|
||||
|
||||
skillLevel = player.Class().GetSkillLevel(skillSellable.GetSkill());
|
||||
|
||||
player.Class().AddSkill(skillSellable.GetSkill(), 0);
|
||||
|
||||
if (entry.getKey() >= 54)
|
||||
{
|
||||
UpdateGlobalSlot(player, entry.getKey(), player.Class().GetSkillLevel(skillSellable.GetSkill()));
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateClassSlot(player, entry.getKey(), player.Class().GetSkillLevel(skillSellable.GetSkill()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player.Donor().ResetSkillTokens();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PlayerReturning(CoreClient player, int slot)
|
||||
{
|
||||
ISalesPackage sellable = GetItem(slot);
|
||||
|
||||
if (sellable instanceof SkillPackage)
|
||||
{
|
||||
SkillPackage skillSellable = (SkillPackage)sellable;
|
||||
|
||||
if (skillSellable.IsActive())
|
||||
{
|
||||
player.GetPlayer().playSound(player.GetPlayer().getLocation(), Sound.SPIDER_WALK, 1, .6f);
|
||||
|
||||
int index = skillSellable.GetLevel() - 1;
|
||||
|
||||
if (slot >= 54)
|
||||
{
|
||||
UpdateGlobalSlot(player, slot, index);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateClassSlot(player, slot, index);
|
||||
}
|
||||
|
||||
CurrentCurrencyHandler.Return(player, sellable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetVisuals()
|
||||
{
|
||||
CurrentClass = null;
|
||||
}
|
||||
|
||||
protected void TranslateIntoVirtualInventory(CoreClient player)
|
||||
{
|
||||
PlayerInventory playerInv = player.Class().GetInventory();
|
||||
playerInv.setItem(9, new ShopItem(Material.INK_SACK, (byte)11, "Global Passive A Skills", null, 1, true, true));
|
||||
playerInv.setItem(18, new ShopItem(Material.INK_SACK, (byte)2, "Global Passive B Skills", null, 1, true, true));
|
||||
playerInv.setItem(27, new ShopItem(Material.INK_SACK, (byte)4, "Global Passive C Skills", null, 1, true, true));
|
||||
|
||||
for (Entry<Integer, List<ISalesPackage>> entry : UnlockedGlobalMap.entrySet())
|
||||
{
|
||||
UpdateGlobalSlot(player, 45 + entry.getKey(), GetIndexForSkill(player, entry, GetSkillPackage(0, entry.getValue())));
|
||||
}
|
||||
}
|
||||
|
||||
private void ReconstructPageForPlayer(CoreClient player)
|
||||
{
|
||||
clear();
|
||||
|
||||
if (PreviousPage != null)
|
||||
{
|
||||
SetPreviousPage(PreviousPage);
|
||||
}
|
||||
|
||||
if (NextPage != null)
|
||||
{
|
||||
SetNextPage(NextPage);
|
||||
}
|
||||
|
||||
SalesPackageMap.clear();
|
||||
HashMap<Integer, List<ISalesPackage>> packageMap = UnlockedClassMap.get(CurrentClass);
|
||||
|
||||
AddItem(new ItemPackage(new ShopItem(Material.IRON_SWORD, "Sword Skills", null, 1, true, true), 0, 0, 0, 0, false, -1), 9);
|
||||
AddItem(new ItemPackage(new ShopItem(Material.IRON_AXE, "Axe Skills", null, 1, true, true), 0, 0, 0, 0, false, -1), 18);
|
||||
AddItem(new ItemPackage(new ShopItem(Material.BOW, "Bow Skills", null, 1, true, true), 0, 0, 0, 0, false, -1), 27);
|
||||
AddItem(new ItemPackage(new ShopItem(Material.INK_SACK, (byte)1, "Class Passive A Skills", null, 1, true, true), 0, 0, 0, 0, false, -1), 36);
|
||||
AddItem(new ItemPackage(new ShopItem(Material.INK_SACK, (byte)14, "Class Passive B Skills", null, 1, true, true), 0, 0, 0, 0, false, -1), 45);
|
||||
|
||||
if (CurrentClass != null)
|
||||
{
|
||||
for (Entry<Integer, List<ISalesPackage>> entry : packageMap.entrySet())
|
||||
{
|
||||
UpdateClassSlot(player, entry.getKey(), GetIndexForSkill(player, entry, GetSkillPackage(0, entry.getValue())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected int GetIndexForSkill(CoreClient player, Entry<Integer, List<ISalesPackage>> entry, SkillPackage skillPackage)
|
||||
{
|
||||
return player.Class().GetSkillLevel(skillPackage.GetSkill());
|
||||
}
|
||||
|
||||
protected SkillPackage GetSkillPackage(int number, List<ISalesPackage> salesPacakgeList)
|
||||
{
|
||||
return GetSkillPackage(salesPacakgeList.get(number));
|
||||
}
|
||||
|
||||
protected SkillPackage GetSkillPackage(ISalesPackage salesPackage)
|
||||
{
|
||||
SkillPackage skillPackage;
|
||||
if (salesPackage instanceof DonationPackage)
|
||||
{
|
||||
skillPackage = (SkillPackage)((DonationPackage)salesPackage).GetWrappedPackage();
|
||||
}
|
||||
else
|
||||
{
|
||||
skillPackage = (SkillPackage)salesPackage;
|
||||
}
|
||||
|
||||
return skillPackage;
|
||||
}
|
||||
|
||||
protected void UpdateGlobalSlot(CoreClient player, int slot, int index)
|
||||
{
|
||||
if (player.Donor().Owns(UnlockedGlobalMap.get(slot - 45).get(index).GetSalesPackageId()) || UnlockedGlobalMap.get(slot - 45).get(index).IsFree() || player.Rank().Has(Rank.DIAMOND, false))
|
||||
{
|
||||
UnlockedGlobalMap.get(slot - 45).get(index).DeliverTo(player.Class(), slot - 45);
|
||||
SalesPackageMap.put(slot, UnlockedGlobalMap.get(slot - 45).get(index));
|
||||
}
|
||||
else
|
||||
{
|
||||
LockedGlobalMap.get(slot - 45).get(index).DeliverTo(player.Class(), slot - 45);
|
||||
SalesPackageMap.put(slot, LockedGlobalMap.get(slot - 45).get(index));
|
||||
}
|
||||
}
|
||||
|
||||
protected void UpdateClassSlot(CoreClient player, int slot, int index)
|
||||
{
|
||||
if (player.Donor().Owns(UnlockedClassMap.get(CurrentClass).get(slot).get(index).GetSalesPackageId()) || UnlockedClassMap.get(CurrentClass).get(slot).get(index).IsFree() || player.Rank().Has(Rank.DIAMOND, false))
|
||||
{
|
||||
AddItem(UnlockedClassMap.get(CurrentClass).get(slot).get(index), slot);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddItem(LockedClassMap.get(CurrentClass).get(slot).get(index), slot);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
package me.chiss.Core.Shop.page.game;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import me.chiss.Core.Class.IPvpClass;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.page.ShopPageBase;
|
||||
|
||||
public class WeaponPage extends ShopPageBase
|
||||
{
|
||||
private IPvpClass _currentClass;
|
||||
|
||||
private HashMap<IPvpClass, HashMap<Integer, ISalesPackage>> UnlockedClassMap;
|
||||
private HashMap<IPvpClass, HashMap<Integer, ISalesPackage>> LockedClassMap;
|
||||
|
||||
public WeaponPage(Shop shop, String title, List<ICurrencyHandler> currencyHandlers, HashMap<IPvpClass, HashMap<Integer, ISalesPackage>> unlockedClassMap, HashMap<IPvpClass, HashMap<Integer, ISalesPackage>> lockedClassMap)
|
||||
{
|
||||
super(shop, title, currencyHandlers, null, null);
|
||||
|
||||
UnlockedClassMap = unlockedClassMap;
|
||||
LockedClassMap = lockedClassMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OpenForPlayer(CoreClient player)
|
||||
{
|
||||
if (_currentClass == null || _currentClass != player.Class().GetGameClass())
|
||||
{
|
||||
_currentClass = player.Class().GetGameClass();
|
||||
|
||||
if (_currentClass == null)
|
||||
_currentClass = Shop.GetClassForPlayer(player);
|
||||
}
|
||||
|
||||
ReconstructPageForPlayer(player);
|
||||
|
||||
UpdateBalance(player);
|
||||
|
||||
player.Class().OpenInventory(this);
|
||||
}
|
||||
|
||||
private void ReconstructPageForPlayer(CoreClient player)
|
||||
{
|
||||
SalesPackageMap.clear();
|
||||
HashMap<Integer, ISalesPackage> packageMap = UnlockedClassMap.get(_currentClass);
|
||||
|
||||
if (_currentClass != null)
|
||||
{
|
||||
for (Entry<Integer, ISalesPackage> entry : packageMap.entrySet())
|
||||
{
|
||||
UpdateClassSlot(player, entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void UpdateClassSlot(CoreClient player, int slot)
|
||||
{
|
||||
if (player.Donor().Owns(UnlockedClassMap.get(_currentClass).get(slot).GetSalesPackageId()) || UnlockedClassMap.get(_currentClass).get(slot).IsFree() || player.Rank().Has(Rank.EMERALD, false))
|
||||
{
|
||||
AddItem(UnlockedClassMap.get(_currentClass).get(slot), slot);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddItem(LockedClassMap.get(_currentClass).get(slot), slot);
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean ShowUnlockedAtSlot(CoreClient player, int slot)
|
||||
{
|
||||
return super.ShowUnlockedAtSlot(player, slot) || player.Rank().Has(Rank.EMERALD, false);
|
||||
}
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
package me.chiss.Core.Shop.page.game.purchase;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.page.game.purchase.ConfirmationPage;
|
||||
import me.chiss.Core.Shop.salespackage.DefaultClassPackage;
|
||||
import me.chiss.Core.Shop.salespackage.DonationPackage;
|
||||
import me.chiss.Core.Shop.salespackage.ShopItem;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.minecraft.game.classcombat.shop.page.ArmorPage;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
|
||||
public class ArmorPurchasePage extends ArmorPage
|
||||
{
|
||||
public ArmorPurchasePage(Shop shop, String title, List<ICurrencyHandler> currencyHandlers, HashMap<Integer, ISalesPackage> unlockedMap, HashMap<Integer, ISalesPackage> lockedMap)
|
||||
{
|
||||
super(shop, title, currencyHandlers, unlockedMap, lockedMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void SetResetButtonLore(int balance, String[] lore)
|
||||
{
|
||||
if (CurrencyHandlers.size() > 1)
|
||||
{
|
||||
lore[1] = "§rClick to change to " + GetNextCurrencyHandler().GetName();
|
||||
}
|
||||
|
||||
if (balance <= 0)
|
||||
{
|
||||
setItem(4, new ShopItem(CurrentCurrencyHandler.GetItemDisplayType(), CurrentCurrencyHandler.GetName() + "(None)", lore, 0, false, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
setItem(4, new ShopItem(CurrentCurrencyHandler.GetItemDisplayType(), CurrentCurrencyHandler.GetName(), lore, 0, false, true));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void PurchaseSalesPackage(CoreClient player, ISalesPackage sellable)
|
||||
{
|
||||
player.Class().GetInventory().clear();
|
||||
|
||||
for (ICurrencyHandler allCurrencyHandler : CurrencyHandlers)
|
||||
{
|
||||
allCurrencyHandler.ResetBalance(player);
|
||||
}
|
||||
|
||||
player.Class().SetGameClass(null);
|
||||
|
||||
player.Class().ClearDefaults();
|
||||
|
||||
if (player.Donor().Owns(sellable.GetSalesPackageId()) || sellable.IsFree())
|
||||
{
|
||||
DefaultClassPackage wrappedPackage = (DefaultClassPackage)((DonationPackage)sellable).GetWrappedPackage();
|
||||
Shop.SetClassForPlayer(player, wrappedPackage.GetGameClass());
|
||||
|
||||
SetNextPage(NextPage);
|
||||
Shop.TurnToNextPage(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
new ConfirmationPage(Shop, this, sellable, CurrentCurrencyHandler, player).OpenForPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void UpdateBalance(CoreClient player)
|
||||
{
|
||||
int balance = CurrentCurrencyHandler.GetBalance(player);
|
||||
|
||||
String[] lore = new String[5];
|
||||
lore[0] = "§rBalance: " + ChatColor.YELLOW + balance + " " + CurrentCurrencyHandler.GetName();
|
||||
|
||||
SetResetButtonLore(balance, lore);
|
||||
}
|
||||
}
|
@ -1,387 +0,0 @@
|
||||
package me.chiss.Core.Shop.page.game.purchase;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.currency.CreditHandler;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.events.PurchasePackageEvent;
|
||||
import me.chiss.Core.Shop.page.IShopPage;
|
||||
import me.chiss.Core.Shop.salespackage.ShopItem;
|
||||
import mineplex.core.server.util.TransactionResponse;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
import mineplex.minecraft.shop.item.ItemPackage;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftInventoryCustom;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ConfirmationPage extends CraftInventoryCustom implements IShopPage, Runnable
|
||||
{
|
||||
private Shop _shop;
|
||||
private Runnable _runnable;
|
||||
private IShopPage _returnCategory;
|
||||
private ISalesPackage _salesItem;
|
||||
private ICurrencyHandler _currencyHandler;
|
||||
private CoreClient _player;
|
||||
private String _title;
|
||||
private int _okSquareSlotStart;
|
||||
private boolean _processing;
|
||||
private boolean _receivedResult;
|
||||
private int _progressCount;
|
||||
private ShopItem _progressItem;
|
||||
private int _taskId;
|
||||
|
||||
public ConfirmationPage(Shop shop, IShopPage returnCategory, ISalesPackage salesItem, ICurrencyHandler currencyHandler, CoreClient player)
|
||||
{
|
||||
this(shop, null, returnCategory, salesItem, currencyHandler, player);
|
||||
}
|
||||
|
||||
public ConfirmationPage(Shop shop, Runnable runnable, IShopPage returnCategory, ISalesPackage salesItem, ICurrencyHandler currencyHandler, CoreClient player)
|
||||
{
|
||||
super(null, 54, " Confirmation");
|
||||
|
||||
_shop = shop;
|
||||
_runnable = runnable;
|
||||
_title = " Confirmation";
|
||||
_returnCategory = returnCategory;
|
||||
_salesItem = salesItem;
|
||||
_currencyHandler = currencyHandler;
|
||||
_player = player;
|
||||
_progressItem = new ShopItem(Material.WOOL, (byte)11, ChatColor.BLUE + "Processing", null, 1, false, true);
|
||||
_okSquareSlotStart = 27;
|
||||
|
||||
if (_shop.CanPlayerAttemptPurchase(player))
|
||||
{
|
||||
BuildPage();
|
||||
}
|
||||
else
|
||||
{
|
||||
BuildErrorPage("You have attempted too many invalid transactions. Please wait 10 seconds before retrying.");
|
||||
_taskId = _shop.GetPlugin().getServer().getScheduler().scheduleSyncRepeatingTask(_shop.GetPlugin(), this, 2L, 2L);
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildPage()
|
||||
{
|
||||
_salesItem.AddToCategory(this.getInventory(), 22);
|
||||
|
||||
this.getInventory().setItem(4, new ShopItem(_currencyHandler.GetItemDisplayType(), (byte)0, _currencyHandler.GetName(), new String[] { C.cGray + _currencyHandler.GetCost(_salesItem) + " " + _currencyHandler.GetName() + " will be deducted from your account balance." }, 1, false, true).getHandle());
|
||||
|
||||
BuildSquareAt(_okSquareSlotStart, new ShopItem(Material.WOOL, (byte)5, ChatColor.GREEN + "OK", null, 1, false, true));
|
||||
BuildSquareAt(_okSquareSlotStart + 6, new ShopItem(Material.WOOL, (byte)14, ChatColor.RED + "CANCEL", null, 1, false, true));
|
||||
}
|
||||
|
||||
private void BuildSquareAt(int slot, ShopItem item)
|
||||
{
|
||||
BuildSquareAt(slot, item, new ItemPackage(item, 0, 0, 0, 0, false, -1));
|
||||
}
|
||||
|
||||
private void BuildSquareAt(int slot, ShopItem item, ISalesPackage middleItem)
|
||||
{
|
||||
this.setItem(slot, item);
|
||||
this.setItem(slot + 1, item);
|
||||
this.setItem(slot + 2, item);
|
||||
|
||||
slot += 9;
|
||||
|
||||
this.setItem(slot, item);
|
||||
List<Integer> slotsAddedTo = middleItem.AddToCategory(this.getInventory(), slot + 1);
|
||||
this.setItem(slot + 2, item);
|
||||
|
||||
boolean crossedItem = true;
|
||||
|
||||
while (crossedItem)
|
||||
{
|
||||
crossedItem = false;
|
||||
|
||||
slot += 9;
|
||||
|
||||
if (!slotsAddedTo.contains(slot))
|
||||
this.setItem(slot, item);
|
||||
else
|
||||
crossedItem = true;
|
||||
|
||||
if (!slotsAddedTo.contains(slot + 1))
|
||||
this.setItem(slot + 1, item);
|
||||
else
|
||||
crossedItem = true;
|
||||
|
||||
if (!slotsAddedTo.contains(slot + 2))
|
||||
this.setItem(slot + 2, item);
|
||||
else
|
||||
crossedItem = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISalesPackage GetItem(int itemSlot)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PrepSlotsForPlayer(CoreClient clicker)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void OpenForPlayer(CoreClient clicker)
|
||||
{
|
||||
_shop.SetPage(clicker, this);
|
||||
|
||||
clicker.Class().OpenInventory(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void CloseForPlayer(CoreClient clicker)
|
||||
{
|
||||
clicker.Class().CloseInventory();
|
||||
_processing = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetTitle()
|
||||
{
|
||||
return _title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Reset(CoreClient player)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean HasNextPage()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean HasPreviousPage()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetPreviousPage(IShopPage previousPage)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetNextPage(IShopPage nextPage)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public IShopPage GetPreviousPage()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IShopPage GetNextPage()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void AddItem(ISalesPackage iSalesPackage, int slot)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetPageNumber(int pageNumber)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetPageNumber()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void UpdateBalance(CoreClient player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PlayerWants(CoreClient donor, int slot)
|
||||
{
|
||||
ItemStack item = getItem(slot);
|
||||
if (item != null)
|
||||
{
|
||||
if (item.getType() == Material.WOOL)
|
||||
{
|
||||
if (_receivedResult)
|
||||
{
|
||||
_returnCategory.OpenForPlayer(donor);
|
||||
_shop.SetPage(donor, _returnCategory);
|
||||
_shop.GetPlugin().getServer().getScheduler().cancelTask(_taskId);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (item.getData().getData() == 5)
|
||||
{
|
||||
ProcessTransaction();
|
||||
}
|
||||
else if (item.getData().getData() == 14)
|
||||
{
|
||||
_returnCategory.OpenForPlayer(donor);
|
||||
_shop.SetPage(donor, _returnCategory);
|
||||
_shop.GetPlugin().getServer().getScheduler().cancelTask(_taskId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PlayerReturning(CoreClient player, int slot)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ResetVisuals()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ChangeCurrency(CoreClient player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void UpdateSlot(CoreClient player, int slot)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void ProcessTransaction()
|
||||
{
|
||||
for (int i=_okSquareSlotStart; i < 54; i++)
|
||||
{
|
||||
clear(i);
|
||||
}
|
||||
|
||||
_processing = true;
|
||||
|
||||
PurchasePackageEvent event = new PurchasePackageEvent(_player.GetPlayerName(), _salesItem.GetName());
|
||||
|
||||
_shop.GetPlugin().getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled())
|
||||
{
|
||||
_shop.GetRepository().PurchaseSalesPackage(new Callback<TransactionResponse> ()
|
||||
{
|
||||
public void run(TransactionResponse response)
|
||||
{
|
||||
ShowResultsPage(response);
|
||||
}
|
||||
}, _player.GetPlayerName(), _currencyHandler instanceof CreditHandler, _salesItem.GetSalesPackageId());
|
||||
|
||||
_taskId = _shop.GetPlugin().getServer().getScheduler().scheduleSyncRepeatingTask(_shop.GetPlugin(), this, 2L, 2L);
|
||||
}
|
||||
else
|
||||
{
|
||||
BuildErrorPage(event.GetReason());
|
||||
_shop.AddPlayerProcessError(_player);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowResultsPage(TransactionResponse response)
|
||||
{
|
||||
_processing = false;
|
||||
_receivedResult = true;
|
||||
|
||||
switch (response)
|
||||
{
|
||||
case Failed:
|
||||
BuildErrorPage("There was an error processing your request.");
|
||||
_shop.AddPlayerProcessError(_player);
|
||||
break;
|
||||
case InsufficientFunds:
|
||||
BuildErrorPage("Your account has insufficient funds.");
|
||||
_shop.AddPlayerProcessError(_player);
|
||||
break;
|
||||
case Success:
|
||||
_salesItem.PurchaseBy(_player);
|
||||
_currencyHandler.Deduct(_player, _salesItem);
|
||||
|
||||
BuildSuccessPage("Your purchase was successful.");
|
||||
|
||||
if (_runnable != null)
|
||||
_runnable.run();
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
_progressCount = 0;
|
||||
}
|
||||
|
||||
private void BuildErrorPage(String message)
|
||||
{
|
||||
ShopItem item = new ShopItem(Material.WOOL, (byte)14, ChatColor.RED + message, null, 1, false, true);
|
||||
for (int i = 0; i < this.getSize(); i++)
|
||||
{
|
||||
this.setItem(i, item);
|
||||
}
|
||||
|
||||
_player.GetPlayer().playSound(_player.GetPlayer().getLocation(), Sound.BLAZE_DEATH, 1, .1f);
|
||||
}
|
||||
|
||||
private void BuildSuccessPage(String message)
|
||||
{
|
||||
ShopItem item = new ShopItem(Material.WOOL, (byte)5, ChatColor.GREEN + message, null, 1, false, true);
|
||||
for (int i = 0; i < this.getSize(); i++)
|
||||
{
|
||||
this.setItem(i, item);
|
||||
}
|
||||
|
||||
_player.GetPlayer().playSound(_player.GetPlayer().getLocation(), Sound.NOTE_PLING, 1, .9f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (_processing)
|
||||
{
|
||||
if (_progressCount == 9)
|
||||
{
|
||||
for (int i=45; i < 54; i++)
|
||||
{
|
||||
clear(i);
|
||||
}
|
||||
|
||||
_progressCount = 0;
|
||||
}
|
||||
|
||||
setItem(45 + _progressCount, _progressItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_progressCount >= 20)
|
||||
{
|
||||
_shop.GetPlugin().getServer().getScheduler().cancelTask(_taskId);
|
||||
|
||||
_shop.SetPage(_player, _returnCategory);
|
||||
_returnCategory.OpenForPlayer(_player);
|
||||
}
|
||||
}
|
||||
|
||||
_progressCount++;
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package me.chiss.Core.Shop.page.game.purchase;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.page.game.ItemPage;
|
||||
import me.chiss.Core.Shop.salespackage.ShopItem;
|
||||
|
||||
public class ItemPurchasePage extends ItemPage
|
||||
{
|
||||
public ItemPurchasePage(Shop shop, String title, List<ICurrencyHandler> currencyHandlers, HashMap<Integer, ISalesPackage> unlockedMap, HashMap<Integer, ISalesPackage> lockedMap)
|
||||
{
|
||||
super(shop, title, currencyHandlers, unlockedMap, lockedMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void SetResetButtonLore(int balance, String[] lore)
|
||||
{
|
||||
if (CurrencyHandlers.size() > 1)
|
||||
{
|
||||
lore[1] = "§rClick to change to " + GetNextCurrencyHandler().GetName();
|
||||
}
|
||||
|
||||
if (balance <= 0)
|
||||
{
|
||||
setItem(4, new ShopItem(CurrentCurrencyHandler.GetItemDisplayType(), CurrentCurrencyHandler.GetName() + "(None)", lore, 0, false, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
setItem(4, new ShopItem(CurrentCurrencyHandler.GetItemDisplayType(), CurrentCurrencyHandler.GetName(), lore, 0, false, true));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void PurchaseSalesPackage(CoreClient player, ISalesPackage sellable)
|
||||
{
|
||||
if (!player.Donor().Owns(sellable.GetSalesPackageId()) && !sellable.IsFree() && !player.Rank().Has(Rank.EMERALD, false))
|
||||
new ConfirmationPage(Shop, this, sellable, CurrentCurrencyHandler, player).OpenForPlayer(player);
|
||||
else
|
||||
{
|
||||
player.GetPlayer().playSound(player.GetPlayer().getLocation(), Sound.ITEM_BREAK, 1f, .6f);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,109 +0,0 @@
|
||||
package me.chiss.Core.Shop.page.game.purchase;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
|
||||
import me.chiss.Core.Class.IPvpClass;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.page.game.SkillsPage;
|
||||
import me.chiss.Core.Shop.salespackage.DonationPackage;
|
||||
import me.chiss.Core.Shop.salespackage.ShopItem;
|
||||
import me.chiss.Core.Shop.salespackage.SkillPackage;
|
||||
|
||||
public class SkillsPurchasePage extends SkillsPage
|
||||
{
|
||||
public SkillsPurchasePage(Shop shop, String title, List<ICurrencyHandler> currencyHandlers,
|
||||
HashMap<IPvpClass, HashMap<Integer, List<ISalesPackage>>> unlockedClassMap, HashMap<Integer, List<ISalesPackage>> unlockedGlobalMap,
|
||||
HashMap<IPvpClass, HashMap<Integer, List<ISalesPackage>>> lockedClassMap, HashMap<Integer, List<ISalesPackage>> lockedGlobalMap)
|
||||
{
|
||||
super(shop, title, currencyHandlers, unlockedClassMap, unlockedGlobalMap, lockedClassMap, lockedGlobalMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void SetResetButtonLore(int balance, String[] lore)
|
||||
{
|
||||
if (CurrencyHandlers.size() > 1)
|
||||
{
|
||||
lore[1] = "§rClick to change to " + GetNextCurrencyHandler().GetName();
|
||||
}
|
||||
|
||||
if (balance <= 0)
|
||||
{
|
||||
setItem(4, new ShopItem(CurrentCurrencyHandler.GetItemDisplayType(), CurrentCurrencyHandler.GetName() + "(None)", lore, 0, false, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
ShopItem currencyItem = new ShopItem(CurrentCurrencyHandler.GetItemDisplayType(), CurrentCurrencyHandler.GetName(), lore, 0, false, true);
|
||||
|
||||
/* Max is still 64
|
||||
if (balance <= 128)
|
||||
currencyItem.setAmount(balance);
|
||||
*/
|
||||
|
||||
setItem(4, currencyItem);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void PurchaseSalesPackage(CoreClient player, ISalesPackage sellable, int slot)
|
||||
{
|
||||
if (sellable instanceof DonationPackage)
|
||||
{
|
||||
SkillPackage skillSellable = GetSkillPackage(sellable);
|
||||
|
||||
if (player.Rank().Has(Rank.DIAMOND, false))
|
||||
{
|
||||
player.GetPlayer().playSound(player.GetPlayer().getLocation(), Sound.ITEM_BREAK, 1f, .6f);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!skillSellable.IsActive() || skillSellable.GetLevel() < skillSellable.GetSkill().GetMaxLevel())
|
||||
{
|
||||
int index = skillSellable.IsActive() ? skillSellable.GetLevel() + 1 : skillSellable.GetLevel();
|
||||
|
||||
if (slot >= 54)
|
||||
{
|
||||
sellable = LockedGlobalMap.get(slot - 45).get(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
sellable = LockedClassMap.get(CurrentClass).get(slot).get(index);
|
||||
}
|
||||
|
||||
new ConfirmationPage(Shop, this, sellable, CurrentCurrencyHandler, player).OpenForPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int GetIndexForSkill(CoreClient player, Entry<Integer, List<ISalesPackage>> entry, SkillPackage skillPackage)
|
||||
{
|
||||
int index = 0;
|
||||
|
||||
if (player.Donor().Owns(entry.getValue().get(index).GetSalesPackageId()) || entry.getValue().get(index).IsFree() || player.Rank().Has(Rank.DIAMOND, false))
|
||||
{
|
||||
for (int i = 1; i <= skillPackage.GetSkill().GetMaxLevel(); i++)
|
||||
{
|
||||
skillPackage = GetSkillPackage(entry.getValue().get(i));
|
||||
|
||||
if (!player.Donor().Owns(skillPackage.GetSalesPackageId()) && !skillPackage.IsFree() && !player.Rank().Has(Rank.DIAMOND, false))
|
||||
break;
|
||||
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
index = player.Class().GetSkillLevel(skillPackage.GetSkill());
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package me.chiss.Core.Shop.page.game.purchase;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
|
||||
import me.chiss.Core.Class.IPvpClass;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.page.game.WeaponPage;
|
||||
import me.chiss.Core.Shop.salespackage.ShopItem;
|
||||
|
||||
public class WeaponPurchasePage extends WeaponPage
|
||||
{
|
||||
public WeaponPurchasePage(Shop shop, String title, List<ICurrencyHandler> currencyHandlers, HashMap<IPvpClass, HashMap<Integer, ISalesPackage>> unlockedClassMap, HashMap<IPvpClass, HashMap<Integer, ISalesPackage>> lockedClassMap)
|
||||
{
|
||||
super(shop, title, currencyHandlers, unlockedClassMap, lockedClassMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void SetResetButtonLore(int balance, String[] lore)
|
||||
{
|
||||
if (CurrencyHandlers.size() > 1)
|
||||
{
|
||||
lore[1] = "§rClick to change to " + GetNextCurrencyHandler().GetName();
|
||||
}
|
||||
|
||||
if (balance <= 0)
|
||||
{
|
||||
setItem(4, new ShopItem(CurrentCurrencyHandler.GetItemDisplayType(), CurrentCurrencyHandler.GetName() + "(None)", lore, 0, false, true));
|
||||
}
|
||||
else
|
||||
{
|
||||
setItem(4, new ShopItem(CurrentCurrencyHandler.GetItemDisplayType(), CurrentCurrencyHandler.GetName(), lore, 0, false, true));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void PurchaseSalesPackage(CoreClient player, ISalesPackage sellable)
|
||||
{
|
||||
if (!player.Donor().Owns(sellable.GetSalesPackageId()) && !sellable.IsFree() && !player.Rank().Has(Rank.EMERALD, false))
|
||||
new ConfirmationPage(Shop, this, sellable, CurrentCurrencyHandler, player).OpenForPlayer(player);
|
||||
else
|
||||
{
|
||||
player.GetPlayer().playSound(player.GetPlayer().getLocation(), Sound.ITEM_BREAK, 1f, .6f);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package me.chiss.Core.Shop.pagebuilder;
|
||||
|
||||
import me.chiss.Core.Shop.page.IShopPage;
|
||||
import mineplex.core.account.CoreClient;
|
||||
|
||||
public interface IPageBuilder
|
||||
{
|
||||
IShopPage BuildForPlayer(CoreClient player);
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package me.chiss.Core.Shop.pagebuilder;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.pagebuilder.itemwrapper.IItemWrapper;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
|
||||
public abstract class PageBuilderBase implements IPageBuilder
|
||||
{
|
||||
protected Shop Shop;
|
||||
protected String Title;
|
||||
protected IItemWrapper ItemWrapper;
|
||||
protected HashMap<Integer, ISalesPackage> LockedSalesPackageMap;
|
||||
protected HashMap<Integer, ISalesPackage> UnlockedSalesPackageMap;
|
||||
protected List<ICurrencyHandler> CurrencyHandlers;
|
||||
|
||||
public PageBuilderBase(Shop shop, String title, IItemWrapper itemWrapper, ICurrencyHandler...currencyHandlers)
|
||||
{
|
||||
Shop = shop;
|
||||
Title = title;
|
||||
ItemWrapper = itemWrapper;
|
||||
CurrencyHandlers = Arrays.asList(currencyHandlers);
|
||||
|
||||
LockedSalesPackageMap = new HashMap<Integer, ISalesPackage>();
|
||||
UnlockedSalesPackageMap = new HashMap<Integer, ISalesPackage>();
|
||||
}
|
||||
|
||||
protected void AddItem(HashMap<Integer, ISalesPackage> map, ISalesPackage salesItem, int slot)
|
||||
{
|
||||
map.put(slot, ItemWrapper.WrapPackage(salesItem));
|
||||
}
|
||||
|
||||
protected void AddItem(HashMap<Integer, ISalesPackage> map, ISalesPackage salesItem)
|
||||
{
|
||||
map.put(GetNextAvailableSlotNumber(map), ItemWrapper.WrapPackage(salesItem));
|
||||
}
|
||||
|
||||
protected int GetNextAvailableSlotNumber(HashMap<Integer, ?> map)
|
||||
{
|
||||
int slot = 45;
|
||||
|
||||
while(map.get(slot) != null)
|
||||
{
|
||||
slot++;
|
||||
slot += slot % 9 == 0 ? -18 : 0;
|
||||
}
|
||||
|
||||
return slot;
|
||||
}
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
package me.chiss.Core.Shop.pagebuilder.game;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import me.chiss.Core.Class.IClassFactory;
|
||||
import me.chiss.Core.Class.IPvpClass;
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.page.IShopPage;
|
||||
import me.chiss.Core.Shop.page.game.CustomBuildPage;
|
||||
import me.chiss.Core.Shop.pagebuilder.PageBuilderBase;
|
||||
import me.chiss.Core.Shop.pagebuilder.itemwrapper.NoWrapper;
|
||||
import me.chiss.Core.Shop.salespackage.ShopItem;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
import mineplex.minecraft.shop.item.ItemPackage;
|
||||
|
||||
public class CustomBuildPageBuilder extends PageBuilderBase
|
||||
{
|
||||
protected HashMap<IPvpClass, HashMap<Integer, ISalesPackage>> ClassLockedSalesPackageMap;
|
||||
protected HashMap<IPvpClass, HashMap<Integer, ISalesPackage>> ClassUnlockedSalesPackageMap;
|
||||
|
||||
protected ItemPackage _unlockedEditSavedBuild;
|
||||
protected ItemPackage _lockedEditSavedBuild;
|
||||
|
||||
protected ItemPackage _unlockedEditDontSaveBuild;
|
||||
protected ItemPackage _lockedEditDontSaveBuild;
|
||||
|
||||
protected ItemPackage _unlockedDeleteBuild;
|
||||
protected ItemPackage _lockedDeleteBuild;
|
||||
|
||||
protected List<ICurrencyHandler> CurrencyHandlers;
|
||||
|
||||
public CustomBuildPageBuilder(Shop shop, String title, IClassFactory gameClassFactory, ICurrencyHandler...currencyHandlers)
|
||||
{
|
||||
super(shop, title, new NoWrapper(), currencyHandlers);
|
||||
|
||||
ClassLockedSalesPackageMap = new HashMap<IPvpClass, HashMap<Integer, ISalesPackage>>();
|
||||
ClassUnlockedSalesPackageMap = new HashMap<IPvpClass, HashMap<Integer, ISalesPackage>>();
|
||||
|
||||
_unlockedEditSavedBuild = new ItemPackage(new ShopItem(Material.ANVIL, "Edit & Save Build", new String[] { }, 1, false, true), 0, 0, 0, 0, true, -1);
|
||||
_lockedEditSavedBuild = new ItemPackage(new ShopItem(Material.ANVIL, "Edit & Save Build", new String[] { }, 1, true, true), 0, 0, 0, 0, true, -1);
|
||||
|
||||
_unlockedEditDontSaveBuild = new ItemPackage(new ShopItem(Material.WORKBENCH, "Edit & Don't Save Build", new String[] { }, 1, false, true), 0, 0, 0, 0, true, -1);
|
||||
_lockedEditDontSaveBuild = new ItemPackage(new ShopItem(Material.WORKBENCH, "Edit & Don't Save Build", new String[] { }, 1, true, true), 0, 0, 0, 0, true, -1);
|
||||
|
||||
_unlockedDeleteBuild = new ItemPackage(new ShopItem(Material.FIRE, "Delete Build", new String[] { "§rIt will never come back..."}, 1, false, true), 0, 0, 0, 0, true, -1);
|
||||
_lockedDeleteBuild = new ItemPackage(new ShopItem(Material.FIRE, "Delete Build", new String[] { "§rIt will never come back..." }, 1, true, true), 0, 0, 0, 0, true, -1);
|
||||
|
||||
for (IPvpClass gameClass : gameClassFactory.GetGameClasses())
|
||||
{
|
||||
HashMap<Integer, ISalesPackage> lockedClassMap = new HashMap<Integer, ISalesPackage>();
|
||||
HashMap<Integer, ISalesPackage> unlockedClassMap = new HashMap<Integer, ISalesPackage>();
|
||||
|
||||
BuildCustomBuildPage(unlockedClassMap, lockedClassMap);
|
||||
|
||||
ClassLockedSalesPackageMap.put(gameClass, lockedClassMap);
|
||||
ClassUnlockedSalesPackageMap.put(gameClass, unlockedClassMap);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IShopPage BuildForPlayer(CoreClient player)
|
||||
{
|
||||
return new CustomBuildPage(Shop, Title, CurrencyHandlers, ClassUnlockedSalesPackageMap, ClassLockedSalesPackageMap);
|
||||
}
|
||||
|
||||
protected void BuildCustomBuildPage(HashMap<Integer, ISalesPackage> unlockedClassMap, HashMap<Integer, ISalesPackage> lockedClassMap)
|
||||
{
|
||||
int slot = 18;
|
||||
|
||||
for (int i=0; i < 5; i++)
|
||||
{
|
||||
lockedClassMap.put(slot, _lockedEditSavedBuild);
|
||||
unlockedClassMap.put(slot, _unlockedEditSavedBuild);
|
||||
|
||||
lockedClassMap.put(slot + 9, _lockedEditDontSaveBuild);
|
||||
unlockedClassMap.put(slot + 9, _unlockedEditDontSaveBuild);
|
||||
|
||||
lockedClassMap.put(slot + 27, _lockedDeleteBuild);
|
||||
unlockedClassMap.put(slot + 27, _unlockedDeleteBuild);
|
||||
|
||||
slot += 2;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,121 +0,0 @@
|
||||
package me.chiss.Core.Shop.pagebuilder.game;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.page.IShopPage;
|
||||
import me.chiss.Core.Shop.page.game.ItemPage;
|
||||
import me.chiss.Core.Shop.pagebuilder.PageBuilderBase;
|
||||
import me.chiss.Core.Shop.pagebuilder.itemwrapper.IItemWrapper;
|
||||
import me.chiss.Core.Shop.pagebuilder.itemwrapper.NoWrapper;
|
||||
import me.chiss.Core.Shop.salespackage.ShopItem;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.minecraft.game.core.classcombat.item.IItem;
|
||||
import mineplex.minecraft.game.core.classcombat.item.IItemFactory;
|
||||
import mineplex.minecraft.shop.item.ItemPackage;
|
||||
|
||||
public class ItemPageBuilder extends PageBuilderBase
|
||||
{
|
||||
private IItemFactory _itemFactory;
|
||||
|
||||
public ItemPageBuilder(Shop shop, String title, IItemWrapper itemWrapper, IItemFactory itemFactory, ICurrencyHandler...currencyHandlers)
|
||||
{
|
||||
super(shop, title, itemWrapper, currencyHandlers);
|
||||
|
||||
_itemFactory = itemFactory;
|
||||
|
||||
for (IItem item : _itemFactory.GetItems())
|
||||
{
|
||||
int slot = 9;
|
||||
|
||||
switch (item.GetType())
|
||||
{
|
||||
case POTATO_ITEM:
|
||||
slot = 9;
|
||||
break;
|
||||
case APPLE:
|
||||
slot = 10;
|
||||
break;
|
||||
case CARROT_ITEM:
|
||||
slot = 11;
|
||||
break;
|
||||
case MUSHROOM_SOUP:
|
||||
slot = 12;
|
||||
break;
|
||||
case COMMAND:
|
||||
slot = 18;
|
||||
break;
|
||||
case NOTE_BLOCK:
|
||||
slot = 19;
|
||||
break;
|
||||
case REDSTONE_LAMP_ON:
|
||||
slot = 20;
|
||||
break;
|
||||
case POTION:
|
||||
slot = 27;
|
||||
break;
|
||||
case SLIME_BALL:
|
||||
slot = 28;
|
||||
break;
|
||||
case ENDER_PEARL:
|
||||
slot = 29;
|
||||
break;
|
||||
case STONE_AXE:
|
||||
slot = 30;
|
||||
break;
|
||||
case NETHER_STAR:
|
||||
slot = 31;
|
||||
break;
|
||||
case MELON_SEEDS:
|
||||
slot = 32;
|
||||
break;
|
||||
case SHEARS:
|
||||
slot = 36;
|
||||
break;
|
||||
case ARROW:
|
||||
slot = 45;
|
||||
break;
|
||||
case WEB:
|
||||
slot = 46;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
AddItemPackage(item, slot);
|
||||
}
|
||||
}
|
||||
|
||||
public ItemPageBuilder(Shop shop, String title, IItemFactory itemFactory, ICurrencyHandler...currencyHandlers)
|
||||
{
|
||||
this(shop, title, new NoWrapper(), itemFactory, currencyHandlers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IShopPage BuildForPlayer(CoreClient player)
|
||||
{
|
||||
return new ItemPage(Shop, Title, CurrencyHandlers, UnlockedSalesPackageMap, LockedSalesPackageMap);
|
||||
}
|
||||
|
||||
protected void AddItemPackage(IItem item, int slot)
|
||||
{
|
||||
List<String> itemLore = new ArrayList<String>();
|
||||
|
||||
itemLore.add(C.cYellow + item.GetTokenCost() + " Tokens");
|
||||
itemLore.add(C.cBlack);
|
||||
|
||||
itemLore.addAll(Arrays.asList(item.GetDesc()));
|
||||
|
||||
for (int i = 2; i < itemLore.size(); i++)
|
||||
{
|
||||
itemLore.set(i, C.cGray + itemLore.get(i));
|
||||
}
|
||||
|
||||
AddItem(LockedSalesPackageMap, new ItemPackage(new ShopItem(item.GetType(), item.GetName(), itemLore.toArray(new String[itemLore.size()]), item.GetAmount(), true), item.GetCreditCost(), item.GetPointCost(), item.GetTokenCost(), item.GetEconomyCost(), item.IsFree(), item.GetSalesPackageId()), slot);
|
||||
AddItem(UnlockedSalesPackageMap, new ItemPackage(new ShopItem(item.GetType(), item.GetName(), itemLore.toArray(new String[itemLore.size()]), item.GetAmount(), false), item.GetCreditCost(), item.GetPointCost(), item.GetTokenCost(), item.GetEconomyCost(), item.IsFree(), item.GetSalesPackageId()), slot);
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package me.chiss.Core.Shop.pagebuilder.game;
|
||||
|
||||
import me.chiss.Core.Class.IClassFactory;
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.page.IShopPage;
|
||||
import me.chiss.Core.Shop.page.game.PvpCustomBuildPage;
|
||||
import mineplex.core.account.CoreClient;
|
||||
|
||||
public class PvpCustomBuildPageBuilder extends CustomBuildPageBuilder
|
||||
{
|
||||
public PvpCustomBuildPageBuilder(Shop shop, String title, IClassFactory gameClassFactory, ICurrencyHandler...currencyHandlers)
|
||||
{
|
||||
super(shop, title, gameClassFactory, currencyHandlers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IShopPage BuildForPlayer(CoreClient player)
|
||||
{
|
||||
return new PvpCustomBuildPage(Shop, Title, CurrencyHandlers, ClassUnlockedSalesPackageMap, ClassLockedSalesPackageMap);
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
package me.chiss.Core.Shop.pagebuilder.game;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import me.chiss.Core.PvpShop.IPvpShopFactory;
|
||||
import me.chiss.Core.PvpShop.IShopItem;
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.page.IShopPage;
|
||||
import me.chiss.Core.Shop.page.game.ShopItemPage;
|
||||
import me.chiss.Core.Shop.pagebuilder.PageBuilderBase;
|
||||
import me.chiss.Core.Shop.pagebuilder.itemwrapper.IItemWrapper;
|
||||
import me.chiss.Core.Shop.pagebuilder.itemwrapper.NoWrapper;
|
||||
import me.chiss.Core.Shop.salespackage.PvpItemPackage;
|
||||
import me.chiss.Core.Shop.salespackage.PvpShopItem;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.util.C;
|
||||
|
||||
public class PvpShopPageBuilder extends PageBuilderBase
|
||||
{
|
||||
private IPvpShopFactory _shopFactory;
|
||||
|
||||
public PvpShopPageBuilder(Shop shop, String title, IItemWrapper itemWrapper, IPvpShopFactory shopFactory, ICurrencyHandler...currencyHandlers)
|
||||
{
|
||||
super(shop, title, itemWrapper, currencyHandlers);
|
||||
|
||||
_shopFactory = shopFactory;
|
||||
|
||||
for (IShopItem item : _shopFactory.GetItems())
|
||||
AddItemPackage(item, item.GetSlot());
|
||||
}
|
||||
|
||||
public PvpShopPageBuilder(Shop shop, String title, IPvpShopFactory shopFactory, ICurrencyHandler...currencyHandlers)
|
||||
{
|
||||
this(shop, title, new NoWrapper(), shopFactory, currencyHandlers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IShopPage BuildForPlayer(CoreClient player)
|
||||
{
|
||||
return new ShopItemPage(Shop, Title, CurrencyHandlers, UnlockedSalesPackageMap, LockedSalesPackageMap);
|
||||
}
|
||||
|
||||
protected void AddItemPackage(IShopItem item, int slot)
|
||||
{
|
||||
List<String> itemLore = new ArrayList<String>();
|
||||
|
||||
itemLore.add(C.cGreen + item.GetEconomyCost() + " Coins");
|
||||
itemLore.add(C.cBlack);
|
||||
|
||||
itemLore.addAll(Arrays.asList(item.GetDesc()));
|
||||
|
||||
for (int i = 2; i < itemLore.size(); i++)
|
||||
{
|
||||
itemLore.set(i, C.cGray + itemLore.get(i));
|
||||
}
|
||||
|
||||
AddItem(UnlockedSalesPackageMap, new PvpItemPackage(new PvpShopItem(item.GetType(), item.GetData(), item.GetName(), item.GetDeliveryName(), itemLore.toArray(new String[itemLore.size()]), item.GetAmount(), false, true),
|
||||
item.GetCreditCost(), item.GetPointCost(), item.GetTokenCost(), item.GetEconomyCost(), item.IsFree(), item.GetSalesPackageId()), slot);
|
||||
}
|
||||
}
|
@ -1,191 +0,0 @@
|
||||
package me.chiss.Core.Shop.pagebuilder.game;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.page.IShopPage;
|
||||
import me.chiss.Core.Shop.page.game.SkillsPage;
|
||||
import me.chiss.Core.Shop.pagebuilder.IPageBuilder;
|
||||
import me.chiss.Core.Shop.salespackage.ISalesPackage;
|
||||
import me.chiss.Core.Shop.salespackage.SkillPackage;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.minecraft.game.core.classcombat.Class.ClassManager;
|
||||
import mineplex.minecraft.game.core.classcombat.Class.IClassFactory;
|
||||
import mineplex.minecraft.game.core.classcombat.Class.IPvpClass;
|
||||
import mineplex.minecraft.game.core.classcombat.Skill.ISkillFactory;
|
||||
import mineplex.minecraft.game.core.classcombat.Skill.SkillFactory;
|
||||
|
||||
public class SkillsPageBuilder implements IPageBuilder
|
||||
{
|
||||
private SkillFactory _skillFactory;
|
||||
private ClassManager _gameClassFactory;
|
||||
|
||||
protected Shop Shop;
|
||||
protected String Title;
|
||||
|
||||
protected HashMap<IPvpClass, HashMap<Integer, List<ISalesPackage>>> ClassLockedSalesPackageMap;
|
||||
protected HashMap<IPvpClass, HashMap<Integer, List<ISalesPackage>>> ClassUnlockedSalesPackageMap;
|
||||
|
||||
protected HashMap<Integer, List<ISalesPackage>> GlobalLockedSalesPackageMap;
|
||||
protected HashMap<Integer, List<ISalesPackage>> GlobalUnlockedSalesPackageMap;
|
||||
|
||||
protected List<ICurrencyHandler> CurrencyHandlers;
|
||||
|
||||
public SkillsPageBuilder(Shop shop, String title, SkillFactory skillFactory, ClassManager gameClassFactory, ICurrencyHandler...currencyHandlers)
|
||||
{
|
||||
Shop = shop;
|
||||
CurrencyHandlers = Arrays.asList(currencyHandlers);
|
||||
Title = title;
|
||||
_skillFactory = skillFactory;
|
||||
_gameClassFactory = gameClassFactory;
|
||||
|
||||
ClassLockedSalesPackageMap = new HashMap<IPvpClass, HashMap<Integer, List<ISalesPackage>>>();
|
||||
ClassUnlockedSalesPackageMap = new HashMap<IPvpClass, HashMap<Integer, List<ISalesPackage>>>();
|
||||
|
||||
GlobalLockedSalesPackageMap = new HashMap<Integer, List<ISalesPackage>>();
|
||||
GlobalUnlockedSalesPackageMap = new HashMap<Integer, List<ISalesPackage>>();
|
||||
|
||||
BuildClassSkills();
|
||||
BuildGlobalSkills();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IShopPage BuildForPlayer(CoreClient player)
|
||||
{
|
||||
IShopPage category = new SkillsPage(Shop, Title, CurrencyHandlers,
|
||||
ClassUnlockedSalesPackageMap, GlobalUnlockedSalesPackageMap,
|
||||
ClassLockedSalesPackageMap, GlobalLockedSalesPackageMap);
|
||||
|
||||
return category;
|
||||
}
|
||||
|
||||
private void BuildClassSkills()
|
||||
{
|
||||
int slotNumber = 53;
|
||||
|
||||
for (IPvpClass gameClass : _gameClassFactory.GetGameClasses())
|
||||
{
|
||||
HashMap<Integer, List<ISalesPackage>> lockedClassMap = new HashMap<Integer, List<ISalesPackage>>();
|
||||
HashMap<Integer, List<ISalesPackage>> unlockedClassMap = new HashMap<Integer, List<ISalesPackage>>();
|
||||
|
||||
int swordSlotNumber = 10;
|
||||
int axeSlotNumber = 19;
|
||||
int bowSlotNumber = 28;
|
||||
int passiveASlotNumber = 37;
|
||||
int passiveBSlotNumber = 46;
|
||||
|
||||
for (ISkill skill : _skillFactory.GetSkillsFor(gameClass))
|
||||
{
|
||||
switch (skill.GetSkillType())
|
||||
{
|
||||
case Sword:
|
||||
slotNumber = swordSlotNumber;
|
||||
swordSlotNumber++;
|
||||
break;
|
||||
case Axe:
|
||||
slotNumber = axeSlotNumber;
|
||||
axeSlotNumber++;
|
||||
break;
|
||||
case Bow:
|
||||
slotNumber = bowSlotNumber;
|
||||
bowSlotNumber++;
|
||||
break;
|
||||
case PassiveA:
|
||||
slotNumber = passiveASlotNumber;
|
||||
passiveASlotNumber++;
|
||||
break;
|
||||
case PassiveB:
|
||||
slotNumber = passiveBSlotNumber;
|
||||
passiveBSlotNumber++;
|
||||
break;
|
||||
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
List<ISalesPackage> unlockedskillPackages = new ArrayList<ISalesPackage>(skill.GetMaxLevel());
|
||||
List<ISalesPackage> lockedSkillPackages = new ArrayList<ISalesPackage>(skill.GetMaxLevel());
|
||||
|
||||
BuildSkillPackages(skill, unlockedskillPackages, lockedSkillPackages);
|
||||
|
||||
lockedClassMap.put(slotNumber, lockedSkillPackages);
|
||||
unlockedClassMap.put(slotNumber, unlockedskillPackages);
|
||||
}
|
||||
|
||||
ClassLockedSalesPackageMap.put(gameClass, lockedClassMap);
|
||||
ClassUnlockedSalesPackageMap.put(gameClass, unlockedClassMap);
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildGlobalSkills()
|
||||
{
|
||||
int slotNumber = 53;
|
||||
|
||||
int passiveCSlotNumber = 10;
|
||||
int passiveDSlotNumber = 19;
|
||||
int passiveESlotNumber = 28;
|
||||
|
||||
for (ISkill skill : _skillFactory.GetGlobalSkills())
|
||||
{
|
||||
switch (skill.GetSkillType())
|
||||
{
|
||||
case PassiveC:
|
||||
slotNumber = passiveCSlotNumber;
|
||||
passiveCSlotNumber++;
|
||||
break;
|
||||
case PassiveD:
|
||||
slotNumber = passiveDSlotNumber;
|
||||
passiveDSlotNumber++;
|
||||
break;
|
||||
case PassiveE:
|
||||
slotNumber = passiveESlotNumber;
|
||||
passiveESlotNumber++;
|
||||
break;
|
||||
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
List<ISalesPackage> unlockedskillPackages = new ArrayList<ISalesPackage>(skill.GetMaxLevel());
|
||||
List<ISalesPackage> lockedSkillPackages = new ArrayList<ISalesPackage>(skill.GetMaxLevel());
|
||||
|
||||
BuildSkillPackages(skill, unlockedskillPackages, lockedSkillPackages);
|
||||
|
||||
GlobalLockedSalesPackageMap.put(slotNumber, lockedSkillPackages);
|
||||
GlobalUnlockedSalesPackageMap.put(slotNumber, unlockedskillPackages);
|
||||
}
|
||||
}
|
||||
|
||||
protected void BuildSkillPackages(ISkill skill, List<ISalesPackage> unlockedSkillPackages, List<ISalesPackage> lockedSkillPackages)
|
||||
{
|
||||
List<String> skillLore = new ArrayList<String>();
|
||||
|
||||
skillLore.add(C.cYellow + skill.GetTokenCost() + " Tokens" + C.cWhite + " per Level");
|
||||
skillLore.add(C.cWhite + "Equipped " + C.cYellow + "0/" + skill.GetMaxLevel() + C.cWhite + " Levels");
|
||||
// skillLore.add(C.cWhite + "You own " + C.cYellow + levelOwned + "/" + skill.GetMaxLevel() + C.cWhite + " Levels");
|
||||
skillLore.add(C.cBlack);
|
||||
|
||||
skillLore.addAll(Arrays.asList(skill.GetDesc()));
|
||||
|
||||
for (int i = 2; i < skillLore.size(); i++)
|
||||
{
|
||||
skillLore.set(i, C.cGray + skillLore.get(i));
|
||||
}
|
||||
|
||||
lockedSkillPackages.add(new SkillPackage(skill, skillLore.toArray(new String[skillLore.size()]), false, 1, true));
|
||||
unlockedSkillPackages.add(new SkillPackage(skill, skillLore.toArray(new String[skillLore.size()]), false, 1, false));
|
||||
|
||||
for (int i = 1; i <= skill.GetMaxLevel(); i++)
|
||||
{
|
||||
skillLore.set(1, C.cWhite + "Equipped " + C.cYellow + i + "/" + skill.GetMaxLevel() + C.cWhite + " Levels");
|
||||
// skillLore.add(C.cWhite + "You own " + C.cYellow + levelOwned + "/" + skill.GetMaxLevel() + C.cWhite + " Levels");
|
||||
lockedSkillPackages.add(new SkillPackage(skill, skillLore.toArray(new String[skillLore.size()]), true, i, true));
|
||||
unlockedSkillPackages.add(new SkillPackage(skill, skillLore.toArray(new String[skillLore.size()]), true, i, false));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
package me.chiss.Core.Shop.pagebuilder.game;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import me.chiss.Core.Class.IClassFactory;
|
||||
import me.chiss.Core.Class.IPvpClass;
|
||||
import mineplex.minecraft.game.core.classcombat.Class.IPvpClass.ClassType;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
import mineplex.minecraft.shop.item.ItemPackage;
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.page.IShopPage;
|
||||
import me.chiss.Core.Shop.page.game.WeaponPage;
|
||||
import me.chiss.Core.Shop.pagebuilder.IPageBuilder;
|
||||
import me.chiss.Core.Shop.salespackage.ShopItem;
|
||||
import me.chiss.Core.Weapon.IWeapon;
|
||||
import me.chiss.Core.Weapon.IWeaponFactory;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.util.C;
|
||||
|
||||
public class WeaponPageBuilder implements IPageBuilder
|
||||
{
|
||||
protected Shop Shop;
|
||||
protected String Title;
|
||||
|
||||
private IWeaponFactory _weaponFactory;
|
||||
|
||||
protected HashMap<IPvpClass, HashMap<Integer, ISalesPackage>> ClassLockedSalesPackageMap;
|
||||
protected HashMap<IPvpClass, HashMap<Integer, ISalesPackage>> ClassUnlockedSalesPackageMap;
|
||||
|
||||
protected List<ICurrencyHandler> CurrencyHandlers;
|
||||
|
||||
public WeaponPageBuilder(Shop shop, String title, IWeaponFactory weaponFactory, IClassFactory gameClassFactory, ICurrencyHandler...currencyHandlers)
|
||||
{
|
||||
Shop = shop;
|
||||
CurrencyHandlers = Arrays.asList(currencyHandlers);
|
||||
Title = title;
|
||||
_weaponFactory = weaponFactory;
|
||||
|
||||
ClassLockedSalesPackageMap = new HashMap<IPvpClass, HashMap<Integer, ISalesPackage>>();
|
||||
ClassUnlockedSalesPackageMap = new HashMap<IPvpClass, HashMap<Integer, ISalesPackage>>();
|
||||
|
||||
for (IPvpClass gameClass : gameClassFactory.GetGameClasses())
|
||||
{
|
||||
HashMap<Integer, ISalesPackage> lockedClassMap = new HashMap<Integer, ISalesPackage>();
|
||||
HashMap<Integer, ISalesPackage> unlockedClassMap = new HashMap<Integer, ISalesPackage>();
|
||||
|
||||
for (IWeapon weapon : _weaponFactory.GetWeapons())
|
||||
{
|
||||
int slot = 9;
|
||||
|
||||
switch (weapon.GetType())
|
||||
{
|
||||
case IRON_SWORD:
|
||||
slot = 9;
|
||||
break;
|
||||
case DIAMOND_SWORD:
|
||||
slot = 10;
|
||||
break;
|
||||
case GOLD_SWORD:
|
||||
slot = 11;
|
||||
break;
|
||||
case IRON_AXE:
|
||||
slot = 18;
|
||||
break;
|
||||
case DIAMOND_AXE:
|
||||
slot = 19;
|
||||
break;
|
||||
case GOLD_AXE:
|
||||
slot = 20;
|
||||
break;
|
||||
case BOW:
|
||||
if (gameClass.GetType() != ClassType.Assassin && gameClass.GetType() != ClassType.Ranger)
|
||||
continue;
|
||||
|
||||
slot = 27;
|
||||
if (weapon.GetName().contains("Booster"))
|
||||
slot ++;
|
||||
else if (weapon.GetName().contains("Power"))
|
||||
slot += 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
BuildWeaponPackages(weapon, unlockedClassMap, lockedClassMap, slot);
|
||||
}
|
||||
|
||||
ClassLockedSalesPackageMap.put(gameClass, lockedClassMap);
|
||||
ClassUnlockedSalesPackageMap.put(gameClass, unlockedClassMap);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IShopPage BuildForPlayer(CoreClient player)
|
||||
{
|
||||
return new WeaponPage(Shop, Title, CurrencyHandlers, ClassUnlockedSalesPackageMap, ClassLockedSalesPackageMap);
|
||||
}
|
||||
|
||||
protected void BuildWeaponPackages(IWeapon weapon, HashMap<Integer, ISalesPackage> unlockedClassMap, HashMap<Integer, ISalesPackage> lockedClassMap, int slot)
|
||||
{
|
||||
List<String> itemLore = new ArrayList<String>();
|
||||
|
||||
itemLore.add(C.cYellow + weapon.GetTokenCost() + " Tokens");
|
||||
itemLore.add(C.cBlack);
|
||||
|
||||
itemLore.addAll(Arrays.asList(weapon.GetDesc()));
|
||||
|
||||
for (int i = 2; i < itemLore.size(); i++)
|
||||
{
|
||||
itemLore.set(i, C.cGray + itemLore.get(i));
|
||||
}
|
||||
|
||||
lockedClassMap.put(slot, new ItemPackage(new ShopItem(weapon.GetType(), weapon.GetName(), itemLore.toArray(new String[itemLore.size()]), weapon.GetAmount(), true), weapon.GetCreditCost(), weapon.GetPointCost(), weapon.GetTokenCost(), weapon.GetEconomyCost(), weapon.IsFree(), weapon.GetSalesPackageId()));
|
||||
unlockedClassMap.put(slot, new ItemPackage(new ShopItem(weapon.GetType(), weapon.GetName(), itemLore.toArray(new String[itemLore.size()]), weapon.GetAmount(), false), weapon.GetCreditCost(), weapon.GetPointCost(), weapon.GetTokenCost(), weapon.GetEconomyCost(), weapon.IsFree(), weapon.GetSalesPackageId()));
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
package me.chiss.Core.Shop.pagebuilder.game.purchase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import me.chiss.Core.Class.IPvpClass;
|
||||
import me.chiss.Core.Class.IClassFactory;
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.page.IShopPage;
|
||||
import me.chiss.Core.Shop.page.game.purchase.ArmorPurchasePage;
|
||||
import me.chiss.Core.Shop.pagebuilder.itemwrapper.DonationWrapper;
|
||||
import me.chiss.Core.Shop.salespackage.DefaultClassPackage;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.minecraft.game.classcombat.shop.page.ArmorPageBuilder;
|
||||
|
||||
public class ArmorPurchasePageBuilder extends ArmorPageBuilder
|
||||
{
|
||||
public ArmorPurchasePageBuilder(Shop shop, String title, IClassFactory gameClassFactory, ICurrencyHandler...currencyHandlers)
|
||||
{
|
||||
super(shop, title, new DonationWrapper(), gameClassFactory, currencyHandlers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IShopPage BuildForPlayer(CoreClient player)
|
||||
{
|
||||
return new ArmorPurchasePage(Shop, Title, CurrencyHandlers, UnlockedSalesPackageMap, LockedSalesPackageMap);
|
||||
}
|
||||
|
||||
protected void PrepareCachedMaps(IPvpClass gameClass, int slot)
|
||||
{
|
||||
List<String> lockedClassDesc = new ArrayList<String>();
|
||||
List<String> unlockedClassDesc = new ArrayList<String>();
|
||||
|
||||
lockedClassDesc.add(C.cYellow + gameClass.GetCreditCost() + "c" + C.cWhite + " or " + C.cYellow + gameClass.GetPointCost() + "p ");
|
||||
unlockedClassDesc.add(C.cBlack);
|
||||
|
||||
lockedClassDesc.addAll(Arrays.asList(gameClass.GetDesc()));
|
||||
unlockedClassDesc.addAll(Arrays.asList(gameClass.GetDesc()));
|
||||
|
||||
for (int i = 2; i < lockedClassDesc.size(); i++)
|
||||
{
|
||||
lockedClassDesc.set(i, C.cGray + lockedClassDesc.get(i));
|
||||
}
|
||||
|
||||
for (int i = 1; i < unlockedClassDesc.size(); i++)
|
||||
{
|
||||
unlockedClassDesc.set(i, C.cGray + unlockedClassDesc.get(i));
|
||||
}
|
||||
|
||||
|
||||
AddItem(LockedSalesPackageMap, new DefaultClassPackage(gameClass, lockedClassDesc.toArray(new String[lockedClassDesc.size()]), true, true), slot);
|
||||
AddItem(UnlockedSalesPackageMap, new DefaultClassPackage(gameClass, unlockedClassDesc.toArray(new String[unlockedClassDesc.size()]), true, false), slot);
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package me.chiss.Core.Shop.pagebuilder.game.purchase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.page.IShopPage;
|
||||
import me.chiss.Core.Shop.page.game.purchase.ItemPurchasePage;
|
||||
import me.chiss.Core.Shop.pagebuilder.game.ItemPageBuilder;
|
||||
import me.chiss.Core.Shop.pagebuilder.itemwrapper.DonationWrapper;
|
||||
import me.chiss.Core.Shop.salespackage.ShopItem;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.minecraft.game.core.classcombat.item.IItem;
|
||||
import mineplex.minecraft.game.core.classcombat.item.IItemFactory;
|
||||
import mineplex.minecraft.shop.item.ItemPackage;
|
||||
|
||||
public class ItemPurchasePageBuilder extends ItemPageBuilder
|
||||
{
|
||||
public ItemPurchasePageBuilder(Shop shop, String title, IItemFactory itemFactory, ICurrencyHandler...currencyHandlers)
|
||||
{
|
||||
super(shop, title, new DonationWrapper(), itemFactory, currencyHandlers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IShopPage BuildForPlayer(CoreClient player)
|
||||
{
|
||||
return new ItemPurchasePage(Shop, Title, CurrencyHandlers, UnlockedSalesPackageMap, LockedSalesPackageMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void AddItemPackage(IItem item, int slot)
|
||||
{
|
||||
List<String> itemLore = new ArrayList<String>();
|
||||
|
||||
itemLore.add(C.cYellow + item.GetCreditCost() + "c" + C.cWhite + " or " + C.cYellow + item.GetPointCost() + "p");
|
||||
itemLore.add(C.cBlack);
|
||||
|
||||
itemLore.addAll(Arrays.asList(item.GetDesc()));
|
||||
|
||||
for (int i = 2; i < itemLore.size(); i++)
|
||||
{
|
||||
itemLore.set(i, C.cGray + itemLore.get(i));
|
||||
}
|
||||
|
||||
AddItem(LockedSalesPackageMap, new ItemPackage(new ShopItem(item.GetType(), item.GetName(), itemLore.toArray(new String[itemLore.size()]), item.GetAmount(), true), item.GetCreditCost(), item.GetPointCost(), item.GetTokenCost(), item.GetEconomyCost(), item.IsFree(), item.GetSalesPackageId()), slot);
|
||||
AddItem(UnlockedSalesPackageMap, new ItemPackage(new ShopItem(item.GetType(), item.GetName(), itemLore.toArray(new String[itemLore.size()]), item.GetAmount(), false), item.GetCreditCost(), item.GetPointCost(), item.GetTokenCost(), item.GetEconomyCost(), item.IsFree(), item.GetSalesPackageId()), slot);
|
||||
}
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
package me.chiss.Core.Shop.pagebuilder.game.purchase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import me.chiss.Core.Class.IClassFactory;
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.page.IShopPage;
|
||||
import me.chiss.Core.Shop.page.game.purchase.SkillsPurchasePage;
|
||||
import me.chiss.Core.Shop.pagebuilder.game.SkillsPageBuilder;
|
||||
import me.chiss.Core.Shop.salespackage.DonationPackage;
|
||||
import me.chiss.Core.Shop.salespackage.SkillPackage;
|
||||
import me.chiss.Core.Skill.ISkill;
|
||||
import me.chiss.Core.Skill.ISkillFactory;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
|
||||
public class SkillsPurchasePageBuilder extends SkillsPageBuilder
|
||||
{
|
||||
public SkillsPurchasePageBuilder(Shop shop, String title, ISkillFactory skillFactory, IClassFactory gameClassFactory, ICurrencyHandler...currencyHandlers)
|
||||
{
|
||||
super(shop, title, skillFactory, gameClassFactory, currencyHandlers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IShopPage BuildForPlayer(CoreClient player)
|
||||
{
|
||||
IShopPage category = new SkillsPurchasePage(Shop, Title, CurrencyHandlers,
|
||||
ClassUnlockedSalesPackageMap, GlobalUnlockedSalesPackageMap,
|
||||
ClassLockedSalesPackageMap, GlobalLockedSalesPackageMap);
|
||||
|
||||
return category;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void BuildSkillPackages(ISkill skill, List<ISalesPackage> unlockedSkillPackages, List<ISalesPackage> lockedSkillPackages)
|
||||
{
|
||||
List<String> skillLore = new ArrayList<String>();
|
||||
|
||||
skillLore.add(C.cYellow + skill.GetCreditCost() + "c" + C.cWhite + " or " + C.cYellow + skill.GetPointCost() + "p " + C.cWhite + "per Level");
|
||||
skillLore.add(C.cWhite + "You own " + C.cYellow + "0/" + skill.GetMaxLevel() + C.cWhite + " Levels");
|
||||
skillLore.add(C.cBlack);
|
||||
|
||||
skillLore.addAll(Arrays.asList(skill.GetDesc()));
|
||||
|
||||
for (int i = 2; i < skillLore.size(); i++)
|
||||
{
|
||||
skillLore.set(i, C.cGray + skillLore.get(i));
|
||||
}
|
||||
|
||||
lockedSkillPackages.add(new DonationPackage(new SkillPackage(skill, skillLore.toArray(new String[skillLore.size()]), false, 1, true)));
|
||||
unlockedSkillPackages.add(new DonationPackage(new SkillPackage(skill, skillLore.toArray(new String[skillLore.size()]), false, 1, false)));
|
||||
|
||||
for (int i = 1; i <= skill.GetMaxLevel(); i++)
|
||||
{
|
||||
skillLore.set(1, C.cWhite + "You own " + C.cYellow + i + "/" + skill.GetMaxLevel() + C.cWhite + " Levels");
|
||||
lockedSkillPackages.add(new DonationPackage(new SkillPackage(skill, skillLore.toArray(new String[skillLore.size()]), true, i, false)));
|
||||
unlockedSkillPackages.add(new DonationPackage(new SkillPackage(skill, skillLore.toArray(new String[skillLore.size()]), true, i, false)));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package me.chiss.Core.Shop.pagebuilder.game.purchase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import me.chiss.Core.Class.IClassFactory;
|
||||
import me.chiss.Core.Shop.Shop;
|
||||
import me.chiss.Core.Shop.currency.ICurrencyHandler;
|
||||
import me.chiss.Core.Shop.page.IShopPage;
|
||||
import me.chiss.Core.Shop.page.game.purchase.WeaponPurchasePage;
|
||||
import me.chiss.Core.Shop.pagebuilder.game.WeaponPageBuilder;
|
||||
import me.chiss.Core.Shop.salespackage.DonationPackage;
|
||||
import me.chiss.Core.Shop.salespackage.ShopItem;
|
||||
import me.chiss.Core.Weapon.IWeapon;
|
||||
import me.chiss.Core.Weapon.IWeaponFactory;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
import mineplex.minecraft.shop.item.ItemPackage;
|
||||
|
||||
public class WeaponPurchasePageBuilder extends WeaponPageBuilder
|
||||
{
|
||||
public WeaponPurchasePageBuilder(Shop shop, String title, IWeaponFactory weaponFactory, IClassFactory gameClassFactory, ICurrencyHandler...currencyHandlers)
|
||||
{
|
||||
super(shop, title, weaponFactory, gameClassFactory, currencyHandlers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IShopPage BuildForPlayer(CoreClient player)
|
||||
{
|
||||
return new WeaponPurchasePage(Shop, Title, CurrencyHandlers, ClassUnlockedSalesPackageMap, ClassLockedSalesPackageMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void BuildWeaponPackages(IWeapon weapon, HashMap<Integer, ISalesPackage> unlockedClassMap, HashMap<Integer, ISalesPackage> lockedClassMap, int slot)
|
||||
{
|
||||
List<String> itemLore = new ArrayList<String>();
|
||||
|
||||
itemLore.add(C.cYellow + weapon.GetCreditCost() + "c" + C.cWhite + " or " + C.cYellow + weapon.GetPointCost()+ "p");
|
||||
itemLore.add(C.cBlack);
|
||||
|
||||
itemLore.addAll(Arrays.asList(weapon.GetDesc()));
|
||||
|
||||
for (int i = 2; i < itemLore.size(); i++)
|
||||
{
|
||||
itemLore.set(i, C.cGray + itemLore.get(i));
|
||||
}
|
||||
|
||||
lockedClassMap.put(slot, new DonationPackage(new ItemPackage(new ShopItem(weapon.GetType(), weapon.GetName(), itemLore.toArray(new String[itemLore.size()]), weapon.GetAmount(), true), weapon.GetCreditCost(), weapon.GetPointCost(), weapon.GetTokenCost(), weapon.GetEconomyCost(), weapon.IsFree(), weapon.GetSalesPackageId())));
|
||||
unlockedClassMap.put(slot, new DonationPackage(new ItemPackage(new ShopItem(weapon.GetType(), weapon.GetName(), itemLore.toArray(new String[itemLore.size()]), weapon.GetAmount(), false), weapon.GetCreditCost(), weapon.GetPointCost(), weapon.GetTokenCost(), weapon.GetEconomyCost(), weapon.IsFree(), weapon.GetSalesPackageId())));
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package me.chiss.Core.Shop.pagebuilder.itemwrapper;
|
||||
|
||||
import me.chiss.Core.Shop.salespackage.DonationPackage;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
|
||||
public class DonationWrapper implements IItemWrapper
|
||||
{
|
||||
@Override
|
||||
public ISalesPackage WrapPackage(ISalesPackage salesPackage)
|
||||
{
|
||||
return new DonationPackage(salesPackage);
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package me.chiss.Core.Shop.pagebuilder.itemwrapper;
|
||||
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
|
||||
public interface IItemWrapper
|
||||
{
|
||||
ISalesPackage WrapPackage(ISalesPackage salesPackage);
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package me.chiss.Core.Shop.pagebuilder.itemwrapper;
|
||||
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
|
||||
public class NoWrapper implements IItemWrapper
|
||||
{
|
||||
@Override
|
||||
public ISalesPackage WrapPackage(ISalesPackage salesPackage)
|
||||
{
|
||||
return salesPackage;
|
||||
}
|
||||
}
|
@ -1,219 +0,0 @@
|
||||
package me.chiss.Core.Shop.salespackage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.chiss.Core.Class.IPvpClass;
|
||||
import me.chiss.Core.ClientData.IClientClass;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
import net.minecraft.server.v1_6_R3.IInventory;
|
||||
|
||||
public class ArmorPackage implements ISalesPackage
|
||||
{
|
||||
private IPvpClass _gameClass;
|
||||
private HashMap<Integer, ShopItem> _shopItemMap;
|
||||
private int _cost = 0;
|
||||
private boolean _locked;
|
||||
|
||||
public ArmorPackage(IPvpClass gameClass, boolean locked)
|
||||
{
|
||||
this(gameClass, 0, locked);
|
||||
}
|
||||
|
||||
public ArmorPackage(IPvpClass gameClass, int creditCost, boolean locked)
|
||||
{
|
||||
_gameClass = gameClass;
|
||||
_cost = creditCost;
|
||||
_locked = locked;
|
||||
_shopItemMap = new HashMap<Integer, ShopItem>();
|
||||
|
||||
SetHelmet(new ShopItem(_gameClass.GetHead(), _gameClass.GetName(), 1, _locked));
|
||||
SetChestplate(new ShopItem(_gameClass.GetChestplate(), _gameClass.GetName(), 1, _locked));
|
||||
SetLeggings(new ShopItem(_gameClass.GetLeggings(), _gameClass.GetName(), 1, _locked));
|
||||
SetBoots(new ShopItem(_gameClass.GetBoots(), _gameClass.GetName(), 1, _locked));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetName()
|
||||
{
|
||||
return _gameClass.GetName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetSalesPackageId()
|
||||
{
|
||||
return _gameClass.GetSalesPackageId();
|
||||
}
|
||||
|
||||
public void SetHelmet(ShopItem shopItem)
|
||||
{
|
||||
_shopItemMap.put(0, shopItem);
|
||||
}
|
||||
|
||||
public ShopItem GetHelmet()
|
||||
{
|
||||
return _shopItemMap.get(0);
|
||||
}
|
||||
|
||||
public void SetChestplate(ShopItem shopItem)
|
||||
{
|
||||
_shopItemMap.put(1, shopItem);
|
||||
}
|
||||
|
||||
public ShopItem GetChestplate()
|
||||
{
|
||||
return _shopItemMap.get(1);
|
||||
}
|
||||
|
||||
public void SetLeggings(ShopItem shopItem)
|
||||
{
|
||||
_shopItemMap.put(2, shopItem);
|
||||
}
|
||||
|
||||
public ShopItem GetLeggings()
|
||||
{
|
||||
return _shopItemMap.get(2);
|
||||
}
|
||||
|
||||
public void SetBoots(ShopItem shopItem)
|
||||
{
|
||||
_shopItemMap.put(3, shopItem);
|
||||
}
|
||||
|
||||
public ShopItem GetBoots()
|
||||
{
|
||||
return _shopItemMap.get(3);
|
||||
}
|
||||
|
||||
public int GetCost()
|
||||
{
|
||||
return _cost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean IsFree()
|
||||
{
|
||||
return _gameClass.IsFree();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean CanFitIn(CoreClient player)
|
||||
{
|
||||
return !_locked || _gameClass.IsFree();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DeliverTo(IClientClass player)
|
||||
{
|
||||
ShopItem head = GetHelmet().clone();
|
||||
head.SetDeliverySettings();
|
||||
|
||||
ShopItem chest = GetChestplate().clone();
|
||||
chest.SetDeliverySettings();
|
||||
|
||||
ShopItem legs = GetLeggings().clone();
|
||||
legs.SetDeliverySettings();
|
||||
|
||||
ShopItem boots = GetBoots().clone();
|
||||
boots.SetDeliverySettings();
|
||||
|
||||
player.GetInventory().setHelmet(head.clone());
|
||||
player.GetInventory().setChestplate(chest.clone());
|
||||
player.GetInventory().setLeggings(legs.clone());
|
||||
player.GetInventory().setBoots(boots.clone());
|
||||
|
||||
player.SetDefaultHead(head);
|
||||
player.SetDefaultChest(chest);
|
||||
player.SetDefaultLegs(legs);
|
||||
player.SetDefaultFeet(boots);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DeliverTo(IClientClass player, int slot)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PurchaseBy(CoreClient player)
|
||||
{
|
||||
if (player.Class().GetGameClass() == null)
|
||||
{
|
||||
player.Class().SetGameClass(_gameClass, false);
|
||||
DeliverTo(player.Class());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int ReturnFrom(CoreClient playerClient)
|
||||
{
|
||||
IClientClass player = playerClient.Class();
|
||||
|
||||
ShopItem head = GetHelmet().clone();
|
||||
head.SetDeliverySettings();
|
||||
|
||||
ShopItem chest = GetChestplate().clone();
|
||||
chest.SetDeliverySettings();
|
||||
|
||||
ShopItem legs = GetLeggings().clone();
|
||||
legs.SetDeliverySettings();
|
||||
|
||||
ShopItem boots = GetBoots().clone();
|
||||
boots.SetDeliverySettings();
|
||||
|
||||
if ((player.GetInventory().getHelmet() != null && player.GetInventory().getHelmet().equals(head))
|
||||
&& (player.GetInventory().getChestplate() != null && player.GetInventory().getChestplate().equals(chest))
|
||||
&& (player.GetInventory().getLeggings() != null && player.GetInventory().getLeggings().equals(legs))
|
||||
&& (player.GetInventory().getBoots() != null && player.GetInventory().getBoots().equals(boots)))
|
||||
{
|
||||
|
||||
player.GetInventory().setArmorContents(new ItemStack[4]);
|
||||
player.AddDefaultArmor(player.GetInventory().getArmorContents());
|
||||
player.SetGameClass(null);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> AddToCategory(IInventory inventory, int slot)
|
||||
{
|
||||
List<Integer> slotList = new ArrayList<Integer>();
|
||||
|
||||
slotList.add(slot);
|
||||
inventory.setItem(slot, new ShopItem(Material.ANVIL, _gameClass.GetName() + " Custom Build", null, 0, _locked, true).getHandle());
|
||||
|
||||
return slotList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetTokenCost()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetCreditCost()
|
||||
{
|
||||
return _gameClass.GetCreditCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetPointCost()
|
||||
{
|
||||
return _gameClass.GetPointCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetEconomyCost()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -1,293 +0,0 @@
|
||||
package me.chiss.Core.Shop.salespackage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.chiss.Core.Class.IPvpClass;
|
||||
import mineplex.minecraft.game.core.classcombat.Class.IPvpClass.ClassType;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
import me.chiss.Core.ClientData.IClientClass;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import net.minecraft.server.v1_6_R3.IInventory;
|
||||
|
||||
public class DefaultClassPackage implements ISalesPackage
|
||||
{
|
||||
private IPvpClass _gameClass;
|
||||
private HashMap<Integer, ShopItem> _shopItemMap;
|
||||
private int _itemCost = 120;
|
||||
private int _skillCost = 120;
|
||||
private boolean _locked;
|
||||
|
||||
private HashMap<Integer, ShopItem> _defaultItems;
|
||||
private List<ShopItem> _defaultSkills;
|
||||
|
||||
public DefaultClassPackage(IPvpClass gameClass, String[] desc, boolean donation, boolean locked)
|
||||
{
|
||||
_gameClass = gameClass;
|
||||
_locked = locked;
|
||||
_shopItemMap = new HashMap<Integer, ShopItem>();
|
||||
_defaultItems = new HashMap<Integer, ShopItem>();
|
||||
_defaultSkills = new ArrayList<ShopItem>();
|
||||
|
||||
AddDefaultItem(new ShopItem(Material.IRON_SWORD, "Standard Sword", 1, false), 0);
|
||||
AddDefaultItem(new ShopItem(Material.IRON_AXE, "Standard Axe", 1, false), 1);
|
||||
|
||||
if (_gameClass.GetType() == ClassType.Knight)
|
||||
{
|
||||
AddDefaultItem(new ShopItem(Material.MUSHROOM_SOUP, "Mushroom Soup", 1, false), 2);
|
||||
AddDefaultItem(new ShopItem(Material.MUSHROOM_SOUP, "Mushroom Soup", 1, false), 3);
|
||||
}
|
||||
else if (_gameClass.GetType() == ClassType.Ranger)
|
||||
{
|
||||
AddDefaultItem(new ShopItem(Material.BOW, "Standard Bow", 1, false), 2);
|
||||
AddDefaultItem(new ShopItem(Material.ARROW, "Arrow", 30, false), 3);
|
||||
}
|
||||
else if (_gameClass.GetType() == ClassType.Brute)
|
||||
{
|
||||
AddDefaultItem(new ShopItem(Material.MUSHROOM_SOUP, "Mushroom Soup", 1, false), 2);
|
||||
AddDefaultItem(new ShopItem(Material.MUSHROOM_SOUP, "Mushroom Soup", 1, false), 3);
|
||||
}
|
||||
else if (_gameClass.GetType() == ClassType.Assassin)
|
||||
{
|
||||
AddDefaultItem(new ShopItem(Material.BOW, "Standard Bow", 1, false), 2);
|
||||
AddDefaultItem(new ShopItem(Material.ARROW, "Arrow", 30, false), 3);
|
||||
}
|
||||
else if (_gameClass.GetType() == ClassType.Mage)
|
||||
{
|
||||
AddDefaultItem(new ShopItem(Material.MUSHROOM_SOUP, "Mushroom Soup", 1, false), 2);
|
||||
AddDefaultItem(new ShopItem(Material.MUSHROOM_SOUP, "Mushroom Soup", 1, false), 3);
|
||||
}
|
||||
|
||||
AddDefaultItem(new ShopItem(Material.MUSHROOM_SOUP, "Mushroom Soup", 1, false), 4);
|
||||
AddDefaultItem(new ShopItem(Material.MUSHROOM_SOUP, "Mushroom Soup", 1, false), 5);
|
||||
AddDefaultItem(new ShopItem(Material.MUSHROOM_SOUP, "Mushroom Soup", 1, false), 6);
|
||||
AddDefaultItem(new ShopItem(Material.MUSHROOM_SOUP, "Mushroom Soup", 1, false), 7);
|
||||
AddDefaultItem(new ShopItem(Material.MUSHROOM_SOUP, "Mushroom Soup", 1, false), 8);
|
||||
|
||||
|
||||
String name = _gameClass.GetName() + (donation ? " Class" : " Default Build");
|
||||
|
||||
SetHelmet(new ShopItem(_gameClass.GetHead(), name, desc, 1, _locked));
|
||||
SetChestplate(new ShopItem(_gameClass.GetChestplate(), name, desc, 1, _locked));
|
||||
SetLeggings(new ShopItem(_gameClass.GetLeggings(), name, desc, 1, _locked));
|
||||
SetBoots(new ShopItem(_gameClass.GetBoots(), name, desc, 1, _locked));
|
||||
}
|
||||
|
||||
public IPvpClass GetGameClass()
|
||||
{
|
||||
return _gameClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetName()
|
||||
{
|
||||
return _gameClass.GetName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetSalesPackageId()
|
||||
{
|
||||
return _gameClass.GetSalesPackageId();
|
||||
}
|
||||
|
||||
public void SetHelmet(ShopItem shopItem)
|
||||
{
|
||||
_shopItemMap.put(0, shopItem);
|
||||
}
|
||||
|
||||
public ShopItem GetHelmet()
|
||||
{
|
||||
return _shopItemMap.get(0);
|
||||
}
|
||||
|
||||
public void SetChestplate(ShopItem shopItem)
|
||||
{
|
||||
_shopItemMap.put(1, shopItem);
|
||||
}
|
||||
|
||||
public ShopItem GetChestplate()
|
||||
{
|
||||
return _shopItemMap.get(1);
|
||||
}
|
||||
|
||||
public void SetLeggings(ShopItem shopItem)
|
||||
{
|
||||
_shopItemMap.put(2, shopItem);
|
||||
}
|
||||
|
||||
public ShopItem GetLeggings()
|
||||
{
|
||||
return _shopItemMap.get(2);
|
||||
}
|
||||
|
||||
public void SetBoots(ShopItem shopItem)
|
||||
{
|
||||
_shopItemMap.put(3, shopItem);
|
||||
}
|
||||
|
||||
public ShopItem GetBoots()
|
||||
{
|
||||
return _shopItemMap.get(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean IsFree()
|
||||
{
|
||||
return _gameClass.IsFree();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean CanFitIn(CoreClient player)
|
||||
{
|
||||
return !_locked || _gameClass.IsFree();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DeliverTo(IClientClass player)
|
||||
{
|
||||
ShopItem head = GetHelmet().clone();
|
||||
head.SetDeliverySettings();
|
||||
|
||||
ShopItem chest = GetChestplate().clone();
|
||||
chest.SetDeliverySettings();
|
||||
|
||||
ShopItem legs = GetLeggings().clone();
|
||||
legs.SetDeliverySettings();
|
||||
|
||||
ShopItem boots = GetBoots().clone();
|
||||
boots.SetDeliverySettings();
|
||||
|
||||
player.GetInventory().setHelmet(head.clone());
|
||||
player.GetInventory().setChestplate(chest.clone());
|
||||
player.GetInventory().setLeggings(legs.clone());
|
||||
player.GetInventory().setBoots(boots.clone());
|
||||
|
||||
player.SetDefaultHead(head);
|
||||
player.SetDefaultChest(chest);
|
||||
player.SetDefaultLegs(legs);
|
||||
player.SetDefaultFeet(boots);
|
||||
|
||||
for (Entry<Integer, ShopItem> defaultItem : _defaultItems.entrySet())
|
||||
{
|
||||
ShopItem deliverable = defaultItem.getValue().clone();
|
||||
deliverable.SetDeliverySettings();
|
||||
|
||||
player.GetInventory().setItem(defaultItem.getKey(), deliverable);
|
||||
player.PutDefaultItem(deliverable.clone(), defaultItem.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DeliverTo(IClientClass player, int slot)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PurchaseBy(CoreClient player)
|
||||
{
|
||||
if (player.Class().GetGameClass() == null)
|
||||
{
|
||||
player.Class().SetGameClass(_gameClass);
|
||||
DeliverTo(player.Class());
|
||||
player.Donor().PurchaseItem(_itemCost);
|
||||
player.Donor().PurchaseSkill(_skillCost);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int ReturnFrom(CoreClient playerClient)
|
||||
{
|
||||
IClientClass player = playerClient.Class();
|
||||
|
||||
ShopItem head = GetHelmet().clone();
|
||||
head.SetDeliverySettings();
|
||||
|
||||
ShopItem chest = GetChestplate().clone();
|
||||
chest.SetDeliverySettings();
|
||||
|
||||
ShopItem legs = GetLeggings().clone();
|
||||
legs.SetDeliverySettings();
|
||||
|
||||
ShopItem boots = GetBoots().clone();
|
||||
boots.SetDeliverySettings();
|
||||
|
||||
if ((player.GetInventory().getHelmet() != null && player.GetInventory().getHelmet().equals(head))
|
||||
&& (player.GetInventory().getChestplate() != null && player.GetInventory().getChestplate().equals(chest))
|
||||
&& (player.GetInventory().getLeggings() != null && player.GetInventory().getLeggings().equals(legs))
|
||||
&& (player.GetInventory().getBoots() != null && player.GetInventory().getBoots().equals(boots)))
|
||||
{
|
||||
player.GetInventory().setArmorContents(new ItemStack[4]);
|
||||
player.AddDefaultArmor(player.GetInventory().getArmorContents());
|
||||
|
||||
player.SetGameClass(null);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> AddToCategory(IInventory inventory, int slot)
|
||||
{
|
||||
List<Integer> slotList = new ArrayList<Integer>();
|
||||
|
||||
slotList.add(slot);
|
||||
inventory.setItem(slot, GetHelmet().getHandle());
|
||||
slot += 9;
|
||||
|
||||
slotList.add(slot);
|
||||
inventory.setItem(slot, GetChestplate().getHandle());
|
||||
slot += 9;
|
||||
|
||||
slotList.add(slot);
|
||||
inventory.setItem(slot, GetLeggings().getHandle());
|
||||
slot += 9;
|
||||
|
||||
slotList.add(slot);
|
||||
inventory.setItem(slot, GetBoots().getHandle());
|
||||
slot += 9;
|
||||
|
||||
return slotList;
|
||||
}
|
||||
|
||||
public void AddDefaultItem(ShopItem shopItem, int slot)
|
||||
{
|
||||
_defaultItems.put(slot, shopItem);
|
||||
}
|
||||
|
||||
public void AddDefaultSkill(ShopItem shopItem)
|
||||
{
|
||||
_defaultSkills.add(shopItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetTokenCost()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetCreditCost()
|
||||
{
|
||||
return _gameClass.GetCreditCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetPointCost()
|
||||
{
|
||||
return _gameClass.GetPointCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetEconomyCost()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
package me.chiss.Core.Shop.salespackage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import me.chiss.Core.ClientData.IClientClass;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
import net.minecraft.server.v1_6_R3.IInventory;
|
||||
|
||||
public class DonationPackage implements ISalesPackage
|
||||
{
|
||||
private ISalesPackage _salesPackage;
|
||||
|
||||
public DonationPackage(ISalesPackage salesPackage)
|
||||
{
|
||||
_salesPackage = salesPackage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetName()
|
||||
{
|
||||
return _salesPackage.GetName();
|
||||
}
|
||||
|
||||
public int GetCreditCost()
|
||||
{
|
||||
return _salesPackage.GetCreditCost();
|
||||
}
|
||||
|
||||
public int GetPointCost()
|
||||
{
|
||||
return _salesPackage.GetPointCost();
|
||||
}
|
||||
|
||||
public int GetTokenCost()
|
||||
{
|
||||
return _salesPackage.GetTokenCost();
|
||||
}
|
||||
|
||||
public int GetEconomyCost()
|
||||
{
|
||||
return _salesPackage.GetEconomyCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean IsFree()
|
||||
{
|
||||
return _salesPackage.IsFree();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean CanFitIn(CoreClient player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> AddToCategory(IInventory inventory, int slot)
|
||||
{
|
||||
return _salesPackage.AddToCategory(inventory, slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DeliverTo(IClientClass player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PurchaseBy(CoreClient player)
|
||||
{
|
||||
player.Donor().AddSalesPackagesOwned(_salesPackage.GetSalesPackageId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int ReturnFrom(CoreClient player)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DeliverTo(IClientClass player, int slot)
|
||||
{
|
||||
_salesPackage.DeliverTo(player, slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetSalesPackageId()
|
||||
{
|
||||
return _salesPackage.GetSalesPackageId();
|
||||
}
|
||||
|
||||
public ISalesPackage GetWrappedPackage()
|
||||
{
|
||||
return _salesPackage;
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package me.chiss.Core.Shop.salespackage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import me.chiss.Core.ClientData.IClientClass;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import net.minecraft.server.v1_6_R3.IInventory;
|
||||
|
||||
public interface ISalesPackage
|
||||
{
|
||||
String GetName();
|
||||
int GetCreditCost();
|
||||
int GetPointCost();
|
||||
boolean CanFitIn(CoreClient player);
|
||||
List<Integer> AddToCategory(IInventory inventory, int slot);
|
||||
void DeliverTo(IClientClass player);
|
||||
void PurchaseBy(CoreClient player);
|
||||
int ReturnFrom(CoreClient player);
|
||||
void DeliverTo(IClientClass player, int slot);
|
||||
int GetSalesPackageId();
|
||||
boolean IsFree();
|
||||
}
|
@ -1,186 +0,0 @@
|
||||
package me.chiss.Core.Shop.salespackage;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import me.chiss.Core.ClientData.IClientClass;
|
||||
import me.chiss.Core.Shop.salespackage.ShopItem;
|
||||
import me.chiss.Core.Utility.InventoryUtil;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import net.minecraft.server.v1_6_R3.IInventory;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftInventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ItemPackage implements ISalesPackage
|
||||
{
|
||||
private ShopItem _shopItem;
|
||||
private boolean _restrictToHotbar;
|
||||
private int _creditCost;
|
||||
private int _pointCost;
|
||||
private int _tokenCost;
|
||||
private int _economyCost;
|
||||
private boolean _free;
|
||||
private int _salesPackageId;
|
||||
|
||||
public ItemPackage(ShopItem shopItem, int creditCost, int pointCost, int tokenCost, int economyCost, boolean isFree, int salesPackageId)
|
||||
{
|
||||
this(shopItem, true, creditCost, pointCost, tokenCost, economyCost, isFree, salesPackageId);
|
||||
}
|
||||
|
||||
public ItemPackage(ShopItem shopItem, boolean restrictToHotbar, int creditCost, int pointCost, int tokenCost, int economyCost, boolean isFree, int salesPackageId)
|
||||
{
|
||||
_shopItem = shopItem;
|
||||
_restrictToHotbar = restrictToHotbar;
|
||||
_creditCost = creditCost;
|
||||
_pointCost = pointCost;
|
||||
_economyCost = economyCost;
|
||||
_tokenCost = tokenCost;
|
||||
_free = isFree;
|
||||
_salesPackageId = salesPackageId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetName()
|
||||
{
|
||||
return _shopItem.GetName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetSalesPackageId()
|
||||
{
|
||||
return _salesPackageId;
|
||||
}
|
||||
|
||||
public int GetCreditCost()
|
||||
{
|
||||
return _creditCost;
|
||||
}
|
||||
|
||||
public int GetPointCost()
|
||||
{
|
||||
return _pointCost;
|
||||
}
|
||||
|
||||
public int GetTokenCost()
|
||||
{
|
||||
return _tokenCost;
|
||||
}
|
||||
|
||||
public int GetEconomyCost()
|
||||
{
|
||||
return _economyCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean IsFree()
|
||||
{
|
||||
return _free;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean CanFitIn(CoreClient player)
|
||||
{
|
||||
if (_shopItem.IsLocked() && !IsFree())
|
||||
return false;
|
||||
|
||||
for (ItemStack itemStack : player.Class().GetInventory())
|
||||
{
|
||||
if (itemStack != null && itemStack.getType() == _shopItem.getType() && (itemStack.getAmount() + _shopItem.getAmount()) <= (itemStack.getType() == Material.ARROW ? itemStack.getMaxStackSize() : 1))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (_tokenCost == 0 && _creditCost == 0 && _pointCost == 0)
|
||||
return true;
|
||||
|
||||
if (InventoryUtil.first((CraftInventory)player.Class().GetInventory(), _restrictToHotbar ? 9 : player.Class().GetInventory().getSize(), null, true) == -1)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DeliverTo(IClientClass player)
|
||||
{
|
||||
ShopItem shopItem = _shopItem.clone();
|
||||
shopItem.SetDeliverySettings();
|
||||
|
||||
if (shopItem.getType() == Material.ARROW)
|
||||
{
|
||||
int firstEmpty = player.GetInventory().firstEmpty();
|
||||
|
||||
player.GetInventory().addItem(shopItem);
|
||||
|
||||
if (player.GetInventory().firstEmpty() != firstEmpty)
|
||||
{
|
||||
player.PutDefaultItem(player.GetInventory().getItem(firstEmpty), firstEmpty);
|
||||
}
|
||||
|
||||
for (Entry<Integer, ? extends ItemStack> entry : player.GetInventory().all(Material.ARROW).entrySet())
|
||||
{
|
||||
player.PutDefaultItem(entry.getValue().clone(), entry.getKey());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int emptySlot = player.GetInventory().firstEmpty();
|
||||
|
||||
player.GetInventory().setItem(emptySlot, shopItem);
|
||||
player.PutDefaultItem(shopItem.clone(), emptySlot);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DeliverTo(IClientClass player, int slot)
|
||||
{
|
||||
ShopItem shopItem = _shopItem.clone();
|
||||
shopItem.SetDeliverySettings();
|
||||
|
||||
player.GetInventory().setItem(slot, shopItem);
|
||||
player.PutDefaultItem(shopItem.clone(), slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PurchaseBy(CoreClient player)
|
||||
{
|
||||
DeliverTo(player.Class());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int ReturnFrom(CoreClient player)
|
||||
{
|
||||
if (_shopItem.IsDisplay())
|
||||
return 0;
|
||||
|
||||
ShopItem shopItem = _shopItem.clone();
|
||||
shopItem.SetDeliverySettings();
|
||||
|
||||
int count = 0;
|
||||
|
||||
count = InventoryUtil.GetCountOfObjectsRemoved((CraftInventory)player.Class().GetInventory(), 9, (ItemStack)shopItem);
|
||||
|
||||
for (int i=0; i < 9; i++)
|
||||
{
|
||||
player.Class().PutDefaultItem(player.Class().GetInventory().getItem(i), i);
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> AddToCategory(IInventory inventory, int slot)
|
||||
{
|
||||
inventory.setItem(slot, _shopItem.getHandle());
|
||||
|
||||
return Arrays.asList(slot);
|
||||
}
|
||||
|
||||
public ShopItem GetItem()
|
||||
{
|
||||
return _shopItem;
|
||||
}
|
||||
}
|
@ -1,176 +0,0 @@
|
||||
package me.chiss.Core.Shop.salespackage;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import me.chiss.Core.ClientData.IClientClass;
|
||||
import me.chiss.Core.Utility.InventoryUtil;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.minecraft.shop.item.ISalesPackage;
|
||||
import net.minecraft.server.v1_6_R3.IInventory;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftInventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class PvpItemPackage implements ISalesPackage
|
||||
{
|
||||
private ShopItem _shopItem;
|
||||
private int _creditCost;
|
||||
private int _pointCost;
|
||||
private int _tokenCost;
|
||||
private int _economyCost;
|
||||
private boolean _free;
|
||||
private int _salesPackageId;
|
||||
|
||||
public PvpItemPackage(ShopItem shopItem, int creditCost, int pointCost, int tokenCost, int economyCost, boolean isFree, int salesPackageId)
|
||||
{
|
||||
_shopItem = shopItem;
|
||||
_creditCost = creditCost;
|
||||
_pointCost = pointCost;
|
||||
_economyCost = economyCost;
|
||||
_tokenCost = tokenCost;
|
||||
_free = isFree;
|
||||
_salesPackageId = salesPackageId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetName()
|
||||
{
|
||||
return _shopItem.GetName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetSalesPackageId()
|
||||
{
|
||||
return _salesPackageId;
|
||||
}
|
||||
|
||||
public int GetCreditCost()
|
||||
{
|
||||
return _creditCost;
|
||||
}
|
||||
|
||||
public int GetPointCost()
|
||||
{
|
||||
return _pointCost;
|
||||
}
|
||||
|
||||
public int GetTokenCost()
|
||||
{
|
||||
return _tokenCost;
|
||||
}
|
||||
|
||||
public int GetEconomyCost()
|
||||
{
|
||||
return _economyCost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean IsFree()
|
||||
{
|
||||
return _free;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean CanFitIn(CoreClient player)
|
||||
{
|
||||
if (_shopItem.IsLocked() && !IsFree())
|
||||
return false;
|
||||
|
||||
for (ItemStack itemStack : player.Class().GetInventory())
|
||||
{
|
||||
if (itemStack != null && itemStack.getType() == _shopItem.getType() && (itemStack.getAmount() + _shopItem.getAmount()) <= (itemStack.getType() == Material.ARROW ? itemStack.getMaxStackSize() : 1))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (_tokenCost == 0 && _creditCost == 0 && _pointCost == 0)
|
||||
return true;
|
||||
|
||||
if (InventoryUtil.first((CraftInventory)player.Class().GetInventory(), 9, null, true) == -1)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
public ItemStack GetStack(String player)
|
||||
{
|
||||
byte data = 0;
|
||||
if (_shopItem.getData() != null)
|
||||
data =_shopItem.getData().getData();
|
||||
|
||||
ItemStack stack;
|
||||
if (_shopItem.getType().getMaxStackSize() == 1)
|
||||
stack = ItemStackFactory.Instance.CreateStack(_shopItem.getType(), data, _shopItem.getAmount(),
|
||||
null, new String[] {}, player + " Shop");
|
||||
else
|
||||
stack = ItemStackFactory.Instance.CreateStack(_shopItem.getType(), data, _shopItem.getAmount());
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DeliverTo(IClientClass player)
|
||||
{
|
||||
player.GetInventory().addItem(GetStack(player.GetName()));
|
||||
}
|
||||
|
||||
public final String DATE_FORMAT_DAY = "yyyy-MM-dd";
|
||||
public String date()
|
||||
{
|
||||
Calendar cal = Calendar.getInstance();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_DAY);
|
||||
return sdf.format(cal.getTime());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DeliverTo(IClientClass player, int slot)
|
||||
{
|
||||
player.GetInventory().setItem(slot, GetStack(player.GetName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PurchaseBy(CoreClient player)
|
||||
{
|
||||
DeliverTo(player.Class());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int ReturnFrom(CoreClient player)
|
||||
{
|
||||
if (_shopItem.IsDisplay())
|
||||
return 0;
|
||||
|
||||
ShopItem shopItem = _shopItem.clone();
|
||||
shopItem.SetDeliverySettings();
|
||||
|
||||
int count = 0;
|
||||
|
||||
count = InventoryUtil.GetCountOfObjectsRemoved((CraftInventory)player.Class().GetInventory(), 9, (ItemStack)shopItem);
|
||||
|
||||
for (int i=0; i < 9; i++)
|
||||
{
|
||||
player.Class().PutDefaultItem(player.Class().GetInventory().getItem(i), i);
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> AddToCategory(IInventory inventory, int slot)
|
||||
{
|
||||
inventory.setItem(slot, _shopItem.getHandle());
|
||||
|
||||
return Arrays.asList(slot);
|
||||
}
|
||||
|
||||
public ShopItem GetItem()
|
||||
{
|
||||
return _shopItem;
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
package me.chiss.Core.Shop.salespackage;
|
||||
|
||||
import net.minecraft.server.v1_6_R3.NBTTagList;
|
||||
import net.minecraft.server.v1_6_R3.NBTTagString;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class PvpShopItem extends ShopItem
|
||||
{
|
||||
public PvpShopItem(Material type, byte data, String name,
|
||||
String deliveryName, String[] lore, int deliveryAmount,
|
||||
boolean locked, boolean displayItem)
|
||||
{
|
||||
super(type, data, name, deliveryName, lore, deliveryAmount, locked, displayItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void UpdateVisual(boolean clone)
|
||||
{
|
||||
if (!clone)
|
||||
{
|
||||
this.getHandle().c(ChatColor.YELLOW + _name);
|
||||
}
|
||||
|
||||
NBTTagList lore = new NBTTagList("Lore");
|
||||
|
||||
if (_lore != null)
|
||||
{
|
||||
for (String line : _lore)
|
||||
{
|
||||
if (line != null && !line.isEmpty())
|
||||
lore.add(new NBTTagString("Test", line));
|
||||
}
|
||||
}
|
||||
|
||||
getHandle().tag.getCompound("display").set("Lore", lore);
|
||||
}
|
||||
}
|
@ -1,173 +0,0 @@
|
||||
package me.chiss.Core.Shop.salespackage;
|
||||
|
||||
import net.minecraft.server.v1_6_R3.NBTTagList;
|
||||
import net.minecraft.server.v1_6_R3.NBTTagString;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.inventory.CraftItemStack;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ShopItem extends CraftItemStack
|
||||
{
|
||||
protected String _name;
|
||||
private String _deliveryName;
|
||||
protected String[] _lore;
|
||||
private int _deliveryAmount;
|
||||
private boolean _locked;
|
||||
private boolean _displayItem;
|
||||
|
||||
public ShopItem(ItemStack itemStack, String name, String deliveryName, int deliveryAmount, boolean locked, boolean displayItem)
|
||||
{
|
||||
super(itemStack);
|
||||
|
||||
_name = name;
|
||||
_deliveryName = deliveryName;
|
||||
_displayItem = displayItem;
|
||||
_deliveryAmount = deliveryAmount;
|
||||
|
||||
getHandle().tag = ((CraftItemStack)itemStack).getHandle().tag;
|
||||
|
||||
UpdateVisual(true);
|
||||
}
|
||||
|
||||
public ShopItem(Material type, String name, int deliveryAmount, boolean locked)
|
||||
{
|
||||
this(type, name, null, deliveryAmount, locked);
|
||||
}
|
||||
|
||||
public ShopItem(Material type, String name, String[] lore, int deliveryAmount, boolean locked)
|
||||
{
|
||||
this(type, name, lore, deliveryAmount, locked, false);
|
||||
}
|
||||
|
||||
public ShopItem(Material type, String name, String[] lore, int deliveryAmount, boolean locked, boolean displayItem)
|
||||
{
|
||||
this(type, (byte)0, name, null, lore, deliveryAmount, locked, displayItem);
|
||||
}
|
||||
|
||||
public ShopItem(Material type, byte data, String name, String[] lore, int deliveryAmount, boolean locked, boolean displayItem)
|
||||
{
|
||||
this(type, data, name, null, lore, deliveryAmount, locked, displayItem);
|
||||
}
|
||||
|
||||
public ShopItem(Material type, byte data, String name, String deliveryName, String[] lore, int deliveryAmount, boolean locked, boolean displayItem)
|
||||
{
|
||||
super(type.getId(), Math.max(deliveryAmount, 1), data, null);
|
||||
|
||||
_name = name;
|
||||
_deliveryName = deliveryName;
|
||||
_lore = lore;
|
||||
_displayItem = displayItem;
|
||||
_deliveryAmount = deliveryAmount;
|
||||
_locked = locked;
|
||||
|
||||
UpdateVisual(false);
|
||||
|
||||
// Fix for temp save junk(fixes problem when disconnecting and trying to return)
|
||||
if (getHandle().tag != null)
|
||||
getHandle().tag.setName("tag");
|
||||
|
||||
getHandle().tag.setByte("Count", (byte)Math.max(deliveryAmount, 1));
|
||||
}
|
||||
|
||||
public boolean IsLocked()
|
||||
{
|
||||
return _locked;
|
||||
}
|
||||
|
||||
public void SetDeliverySettings()
|
||||
{
|
||||
setAmount(_deliveryAmount);
|
||||
|
||||
//Delivery Name
|
||||
if (_deliveryName != null)
|
||||
this.getHandle().c(_deliveryName);
|
||||
}
|
||||
|
||||
public ShopItem clone()
|
||||
{
|
||||
return new ShopItem(super.clone(), _name, _deliveryName, _deliveryAmount, _locked, _displayItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (!super.equals(obj))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
net.minecraft.server.v1_6_R3.ItemStack original = ((CraftItemStack)this).getHandle();
|
||||
net.minecraft.server.v1_6_R3.ItemStack comparison = ((CraftItemStack)obj).getHandle();
|
||||
|
||||
return original.tag == null || original.tag.equals(comparison.tag);
|
||||
}
|
||||
|
||||
protected void UpdateVisual(boolean clone)
|
||||
{
|
||||
if (!clone)
|
||||
{
|
||||
if (_locked && !_displayItem)
|
||||
{
|
||||
this.getHandle().c(ChatColor.RED + "§l" + _name);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.getHandle().c(ChatColor.GREEN + "§l" + _name);
|
||||
}
|
||||
}
|
||||
|
||||
NBTTagList lore = new NBTTagList("Lore");
|
||||
|
||||
if (_lore != null)
|
||||
{
|
||||
for (String line : _lore)
|
||||
{
|
||||
if (line != null && !line.isEmpty())
|
||||
lore.add(new NBTTagString("Test", line));
|
||||
}
|
||||
}
|
||||
|
||||
getHandle().tag.getCompound("display").set("Lore", lore);
|
||||
}
|
||||
|
||||
public boolean IsDisplay()
|
||||
{
|
||||
return _displayItem;
|
||||
}
|
||||
|
||||
public void SetLocked(boolean owns)
|
||||
{
|
||||
_locked = owns;
|
||||
UpdateVisual(false);
|
||||
}
|
||||
|
||||
public String GetName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public void SetName(String name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
public void SetLore(String[] string)
|
||||
{
|
||||
_lore = string;
|
||||
|
||||
NBTTagList lore = new NBTTagList("Lore");
|
||||
|
||||
if (_lore != null)
|
||||
{
|
||||
for (String line : _lore)
|
||||
{
|
||||
if (line != null && !line.isEmpty())
|
||||
lore.add(new NBTTagString("Test", line));
|
||||
}
|
||||
}
|
||||
|
||||
getHandle().tag.getCompound("display").set("Lore", lore);
|
||||
}
|
||||
}
|
@ -1,153 +0,0 @@
|
||||
package me.chiss.Core.Shop.salespackage;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import me.chiss.Core.ClientData.IClientClass;
|
||||
import mineplex.core.account.CoreClient;
|
||||
import mineplex.minecraft.game.core.classcombat.Skill.ISkill;
|
||||
import net.minecraft.server.v1_6_R3.IInventory;
|
||||
|
||||
public class SkillPackage implements ISalesPackage
|
||||
{
|
||||
private ShopItem _skillItem;
|
||||
private ISkill _skill;
|
||||
private int _level;
|
||||
private boolean _active;
|
||||
private boolean _locked;
|
||||
|
||||
public SkillPackage(ISkill skill, String[] lore, boolean active, int level, boolean locked)
|
||||
{
|
||||
_skill = skill;
|
||||
_active = active;
|
||||
_level = level;
|
||||
_locked = locked;
|
||||
|
||||
_skillItem = new ShopItem((_locked ? Material.BOOK : _active ? Material.WRITTEN_BOOK : Material.BOOK), _skill.GetName(), null, _level, _locked);
|
||||
_skillItem.SetLore(lore);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetName()
|
||||
{
|
||||
return _skillItem.GetName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int GetSalesPackageId()
|
||||
{
|
||||
return _skill.GetSalesPackageId();
|
||||
}
|
||||
|
||||
public ISkill GetSkill()
|
||||
{
|
||||
return _skill;
|
||||
}
|
||||
|
||||
public int GetCreditCost()
|
||||
{
|
||||
return _skill.GetCreditCost();
|
||||
}
|
||||
|
||||
public int GetPointCost()
|
||||
{
|
||||
return _skill.GetPointCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean IsFree()
|
||||
{
|
||||
return _skill.IsFree(_level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean CanFitIn(CoreClient player)
|
||||
{
|
||||
if (_locked && !IsFree())
|
||||
return false;
|
||||
|
||||
ISkill existingSkill = player.Class().GetSkillByType(_skill.GetSkillType());
|
||||
|
||||
if (existingSkill == _skill)
|
||||
{
|
||||
return player.Class().GetSkillLevel(existingSkill) < _skill.GetMaxLevel();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DeliverTo(IClientClass player)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DeliverTo(IClientClass player, int slot)
|
||||
{
|
||||
player.GetInventory().setItem(slot, _skillItem);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PurchaseBy(CoreClient player)
|
||||
{
|
||||
ISkill skill = GetSkill();
|
||||
|
||||
ISkill existingSkill = player.Class().GetSkillByType(skill.GetSkillType());
|
||||
|
||||
if (existingSkill != null)
|
||||
{
|
||||
player.Class().RemoveSkill(existingSkill);
|
||||
}
|
||||
|
||||
player.Class().AddSkill(skill, _skillItem.getAmount());
|
||||
|
||||
DeliverTo(player.Class());
|
||||
}
|
||||
|
||||
public int ReturnAllLevels(CoreClient player)
|
||||
{
|
||||
if (player.Class().GetSkillByType(GetSkill().GetSkillType()) != null && player.Class().GetSkillByType(GetSkill().GetSkillType()) == GetSkill())
|
||||
{
|
||||
player.Class().RemoveSkill(GetSkill());
|
||||
|
||||
return _skillItem.getAmount();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int ReturnFrom(CoreClient player)
|
||||
{
|
||||
if (player.Class().GetSkillByType(GetSkill().GetSkillType()) != null && player.Class().GetSkillByType(GetSkill().GetSkillType()) == GetSkill())
|
||||
{
|
||||
player.Class().RemoveSkill(GetSkill());
|
||||
|
||||
if (_skillItem.getAmount() > 1)
|
||||
player.Class().AddSkill(GetSkill(), _skillItem.getAmount() - 1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> AddToCategory(IInventory inventory, int slot)
|
||||
{
|
||||
inventory.setItem(slot, _skillItem.getHandle());
|
||||
return Arrays.asList(slot);
|
||||
}
|
||||
|
||||
public int GetLevel()
|
||||
{
|
||||
return _level;
|
||||
}
|
||||
|
||||
public boolean IsActive()
|
||||
{
|
||||
return _active;
|
||||
}
|
||||
}
|
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Nautilus.Game.CaptureThePig</name>
|
||||
<name>Mineplex.Bungee.Mineplexer</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
@ -16,7 +16,7 @@
|
||||
<arguments>
|
||||
<dictionary>
|
||||
<key>LaunchConfigHandle</key>
|
||||
<value><project>/.externalToolBuilders/CaptureThePig.launch</value>
|
||||
<value><project>/.externalToolBuilders/Mineplexer2.launch</value>
|
||||
</dictionary>
|
||||
</arguments>
|
||||
</buildCommand>
|
@ -0,0 +1,41 @@
|
||||
package mineplex.bungee.motd;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import net.md_5.bungee.api.event.ProxyPingEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public class MotdManager implements Listener, Runnable
|
||||
{
|
||||
private Plugin _plugin;
|
||||
private MotdRepository _repository;
|
||||
|
||||
private String _motd = "§b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r §c§l§m§kZ§6§l§m§kZ§e§l§m§kZ§a§l§m§kZ§b§l§m§kZ§r §f§lPLAY NOW§r §b§l§m§kZ§a§l§m§kZ§e§l§m§kZ§6§l§m§kZ§c§l§m§kZ";
|
||||
|
||||
public MotdManager(Plugin plugin)
|
||||
{
|
||||
_plugin = plugin;
|
||||
|
||||
_plugin.getProxy().getScheduler().schedule(_plugin, this, 30L, 30L, TimeUnit.SECONDS);
|
||||
_plugin.getProxy().getPluginManager().registerListener(_plugin, this);
|
||||
|
||||
_repository = new MotdRepository();
|
||||
_repository.initialize();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void ServerPing(ProxyPingEvent event)
|
||||
{
|
||||
net.md_5.bungee.api.ServerPing serverPing = event.getResponse();
|
||||
|
||||
event.setResponse(new net.md_5.bungee.api.ServerPing(serverPing.getVersion(), serverPing.getPlayers(), _motd, serverPing.getFavicon()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
_motd = _repository.retrieveMotd();
|
||||
}
|
||||
}
|
@ -0,0 +1,127 @@
|
||||
package mineplex.bungee.motd;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class MotdRepository
|
||||
{
|
||||
private String _connectionString = "jdbc:mysql://sql.mineplex.com:3306/BungeeServers";
|
||||
private String _userName = "root";
|
||||
private String _password = "tAbechAk3wR7tuTh";
|
||||
|
||||
private static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS BungeeMotd (id INT NOT NULL AUTO_INCREMENT, motd VARCHAR(256), PRIMARY KEY (id));";
|
||||
private static String RETRIEVE_MOTD = "SELECT motd FROM BungeeMotd;";
|
||||
|
||||
public void initialize()
|
||||
{
|
||||
Connection connection = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
// Create table
|
||||
preparedStatement = connection.prepareStatement(CREATE_TABLE);
|
||||
preparedStatement.execute();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (connection != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String retrieveMotd()
|
||||
{
|
||||
String motd = "§b§l§m §8§l§m[ §r §9§lMineplex§r §f§lGames§r §8§l§m ]§b§l§m §r §c§l§m§kZ§6§l§m§kZ§e§l§m§kZ§a§l§m§kZ§b§l§m§kZ§r §f§lPLAY NOW§r §b§l§m§kZ§a§l§m§kZ§e§l§m§kZ§6§l§m§kZ§c§l§m§kZ";
|
||||
Connection connection = null;
|
||||
ResultSet resultSet = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
|
||||
try
|
||||
{
|
||||
connection = DriverManager.getConnection(_connectionString, _userName, _password);
|
||||
|
||||
preparedStatement = connection.prepareStatement(RETRIEVE_MOTD);
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
|
||||
while (resultSet.next())
|
||||
{
|
||||
return resultSet.getString(1);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (preparedStatement != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
preparedStatement.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (resultSet != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
resultSet.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (connection != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
connection.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return motd;
|
||||
}
|
||||
}
|
@ -126,7 +126,7 @@ public class Polysmash extends SkillActive
|
||||
_used.add(player);
|
||||
|
||||
//Condition
|
||||
Factory.Condition().Factory().Slow(GetName(), ent, player, 5, 0, false, true, false);
|
||||
Factory.Condition().Factory().Slow(GetName(), ent, player, 5, 0, false, true, false, false);
|
||||
Factory.Condition().Factory().Silence(GetName(), ent, player, 5, false, true);
|
||||
|
||||
//Effect
|
||||
|
@ -27,7 +27,7 @@ public class Shifter extends Skill
|
||||
{
|
||||
if (event.getType() == UpdateType.FAST)
|
||||
for (Player cur : GetUsers())
|
||||
Factory.Condition().Factory().Protection(GetName(), cur, cur, 1.9, 1, false, false);
|
||||
Factory.Condition().Factory().Protection(GetName(), cur, cur, 1.9, 1, false, false, false);
|
||||
|
||||
if (event.getType() == UpdateType.SLOWER)
|
||||
for (Player cur : GetUsers())
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
@ -81,7 +82,7 @@ public class Pistol extends ItemUsable
|
||||
//Player
|
||||
if (cur instanceof Player)
|
||||
{
|
||||
if (UtilEnt.hitBox(loc, (Player)cur, 1))
|
||||
if (UtilEnt.hitBox(loc, (Player)cur, 1, EntityType.PLAYER))
|
||||
{
|
||||
RifleHit(cur, player, true);
|
||||
player.getWorld().playSound(loc, Sound.BLAZE_HIT, 0.4f, 2f);
|
||||
|
@ -1,6 +0,0 @@
|
||||
package nautilus.minecraft.core.log;
|
||||
|
||||
public class LogManager
|
||||
{
|
||||
|
||||
}
|
@ -1,163 +0,0 @@
|
||||
package nautilus.minecraft.core.player;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
|
||||
public class Home
|
||||
{
|
||||
private String _name;
|
||||
private Location _location;
|
||||
|
||||
public Home(String name, Location location)
|
||||
{
|
||||
_name = name;
|
||||
_location = location;
|
||||
}
|
||||
|
||||
public Home(String name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
public String GetName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public Location GetLocation()
|
||||
{
|
||||
return _location;
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
BufferedWriter fout = null;
|
||||
|
||||
try
|
||||
{
|
||||
StringBuilder packedContents = new StringBuilder();
|
||||
|
||||
packedContents.append("home:");
|
||||
packedContents.append(_location.getX() + ":" + _location.getY() + ":" + _location.getZ());
|
||||
packedContents.append(":" + _location.getYaw() + ":" + _location.getPitch());
|
||||
packedContents.append(":" + (_location.getWorld().getEnvironment() == Environment.NORMAL ? "world" : "nether") + "\n");
|
||||
|
||||
fout = new BufferedWriter(new FileWriter("homes\\" + _name + ".txt"));
|
||||
|
||||
fout.write(packedContents.toString());
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (fout != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
fout.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Load()
|
||||
{
|
||||
BufferedReader fileIn = null;
|
||||
|
||||
try
|
||||
{
|
||||
fileIn = new BufferedReader(new FileReader("homes\\" + _name + ".txt"));
|
||||
|
||||
String line = fileIn.readLine();
|
||||
|
||||
line = line.substring(line.indexOf(':') + 1);
|
||||
|
||||
_location = ParseLocation(line);
|
||||
|
||||
fileIn.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (fileIn != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
fileIn.close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Location ParseLocation(String line)
|
||||
{
|
||||
try
|
||||
{
|
||||
String [] parts = line.split(":");
|
||||
double x = Double.parseDouble(parts[0]);
|
||||
double y = Double.parseDouble(parts[1]);
|
||||
double z = Double.parseDouble(parts[2]);
|
||||
float rotX = 0;
|
||||
float rotY = 0;
|
||||
org.bukkit.World world;
|
||||
|
||||
if (parts.length > 3)
|
||||
{
|
||||
rotX = Float.parseFloat(parts[3]);
|
||||
rotY = Float.parseFloat(parts[4]);
|
||||
}
|
||||
|
||||
List<World> worlds = Bukkit.getServer().getWorlds();
|
||||
World normalWorld = worlds.get(0);
|
||||
World netherWorld = worlds.get(0);
|
||||
|
||||
for (World serverWorld : worlds)
|
||||
{
|
||||
if (serverWorld.getEnvironment() == Environment.NORMAL)
|
||||
normalWorld = serverWorld;
|
||||
else if (serverWorld.getEnvironment() == Environment.NETHER)
|
||||
netherWorld = serverWorld;
|
||||
}
|
||||
|
||||
|
||||
if(parts.length == 6 && parts[5].contains("nether"))
|
||||
{
|
||||
world = netherWorld;
|
||||
}
|
||||
else
|
||||
{
|
||||
world = normalWorld;
|
||||
}
|
||||
|
||||
return new Location(world, x, y, z, rotX, rotY);
|
||||
}
|
||||
catch(NumberFormatException ex)
|
||||
{
|
||||
System.out.println("Can't parse location for line:" + line);
|
||||
// Gulp, that was good.
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package nautilus.minecraft.core.player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class HomeManager
|
||||
{
|
||||
private HashMap<String, Home> _playerHomes;
|
||||
|
||||
public HomeManager()
|
||||
{
|
||||
_playerHomes = new HashMap<String, Home>();
|
||||
LoadHomes();
|
||||
}
|
||||
|
||||
public void SetHome(Player player)
|
||||
{
|
||||
String homeName = player.getName().toLowerCase();
|
||||
Home playerHome = new Home(homeName, player.getLocation());
|
||||
|
||||
_playerHomes.put(homeName, playerHome);
|
||||
playerHome.Save();
|
||||
}
|
||||
|
||||
public Home GetHome(Player player)
|
||||
{
|
||||
return _playerHomes.get(player.getName().toLowerCase());
|
||||
}
|
||||
|
||||
public void LoadHomes()
|
||||
{
|
||||
File homeDir = new File("homes/");
|
||||
|
||||
if (!homeDir.exists())
|
||||
{
|
||||
homeDir.mkdir();
|
||||
}
|
||||
|
||||
for (File f : homeDir.listFiles())
|
||||
{
|
||||
String fileName = f.getName();
|
||||
System.out.println(fileName);
|
||||
Home home = new Home(fileName.substring(0, fileName.indexOf('.')));
|
||||
|
||||
home.Load();
|
||||
|
||||
_playerHomes.put(home.GetName(), home);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package nautilus.minecraft.core.utils;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ColorUtil
|
||||
{
|
||||
private static transient final Pattern REPLACE_COLOR_PATTERN = Pattern.compile("&([0-9a-f])");
|
||||
|
||||
public static String formatString(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return REPLACE_COLOR_PATTERN.matcher(input).replaceAll("\u00a7$1");
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package nautilus.minecraft.core.utils;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class GenericActionListener<T> implements ActionListener
|
||||
{
|
||||
protected T Object;
|
||||
|
||||
public GenericActionListener(T t)
|
||||
{
|
||||
Object = t;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package nautilus.minecraft.core.utils;
|
||||
|
||||
public class GenericRunnable3<T1, T2, T3> implements Runnable
|
||||
{
|
||||
protected T1 t1;
|
||||
protected T2 t2;
|
||||
protected T3 t3;
|
||||
|
||||
public GenericRunnable3(T1 t1, T2 t2, T3 t3)
|
||||
{
|
||||
this.t1 = t1;
|
||||
this.t2 = t2;
|
||||
this.t3 = t3;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -1,234 +0,0 @@
|
||||
package nautilus.minecraft.core.utils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.v1_6_R3.DataWatcher;
|
||||
import net.minecraft.server.v1_6_R3.MathHelper;
|
||||
import net.minecraft.server.v1_6_R3.Packet20NamedEntitySpawn;
|
||||
import net.minecraft.server.v1_6_R3.Packet24MobSpawn;
|
||||
import net.minecraft.server.v1_6_R3.Packet29DestroyEntity;
|
||||
import net.minecraft.server.v1_6_R3.Packet5EntityEquipment;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PacketUtils
|
||||
{
|
||||
public static void killCarcass(Player p1)
|
||||
{
|
||||
CraftPlayer p22 = (CraftPlayer) p1;
|
||||
Packet29DestroyEntity p29 = new Packet29DestroyEntity(p22.getEntityId());
|
||||
|
||||
for (Player p2 : Bukkit.getServer().getOnlinePlayers())
|
||||
{
|
||||
if (p2.getName().equals(p1.getName()))
|
||||
continue;
|
||||
|
||||
((CraftPlayer) p2).getHandle().playerConnection.sendPacket(p29);
|
||||
|
||||
System.out.println("Killing carcass of '" + p1.getName() + "'");
|
||||
}
|
||||
}
|
||||
|
||||
public static void undisguiseToAll(Player p1)
|
||||
{
|
||||
// Make packets out of loop!
|
||||
CraftPlayer p22 = (CraftPlayer) p1;
|
||||
Packet29DestroyEntity p29 = new Packet29DestroyEntity(p22.getEntityId());
|
||||
Packet20NamedEntitySpawn p20 = new Packet20NamedEntitySpawn(p22.getHandle());
|
||||
|
||||
if (p1.getItemInHand() != null && p1.getItemInHand().getType() != Material.FISHING_ROD)
|
||||
p20.h = p1.getItemInHand().getTypeId();
|
||||
|
||||
List<Packet5EntityEquipment> p5 = new ArrayList<Packet5EntityEquipment>();
|
||||
net.minecraft.server.v1_6_R3.ItemStack[] armorContents = ((net.minecraft.server.v1_6_R3.Entity)p22.getHandle()).getEquipment();
|
||||
|
||||
for (short i=0; i < armorContents.length; i++)
|
||||
{
|
||||
net.minecraft.server.v1_6_R3.ItemStack armorSlot = armorContents[i];
|
||||
|
||||
if (armorSlot != null)
|
||||
{
|
||||
p5.add(new Packet5EntityEquipment(p22.getEntityId(), i, armorSlot));
|
||||
}
|
||||
}
|
||||
|
||||
for (Player p2 : Bukkit.getServer().getOnlinePlayers())
|
||||
{
|
||||
if (!p1.getWorld().equals(p2.getWorld()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (p2 == p1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
((CraftPlayer) p2).getHandle().playerConnection.sendPacket(p29);
|
||||
((CraftPlayer) p2).getHandle().playerConnection.sendPacket(p20);
|
||||
|
||||
for (Packet5EntityEquipment equipPacket : p5)
|
||||
((CraftPlayer) p2).getHandle().playerConnection.sendPacket(equipPacket);
|
||||
}
|
||||
}
|
||||
|
||||
public static void disguiseToAll(Player p1, Byte id)
|
||||
{
|
||||
DataWatcher metadata = new DataWatcher();
|
||||
metadata.a(0, (byte) 0);
|
||||
metadata.a(12, 0);
|
||||
if (id == EntityType.SHEEP.getTypeId() || id == EntityType.PIG.getTypeId() || id == EntityType.ENDERMAN.getTypeId()) {
|
||||
metadata.a(16, (byte) 0);
|
||||
} else if (id == EntityType.SLIME.getTypeId()) {
|
||||
metadata.a(16, (byte) 3);
|
||||
} else if (id == EntityType.VILLAGER.getTypeId()) {
|
||||
metadata.a(16, 0);
|
||||
}
|
||||
|
||||
if (id == EntityType.CREEPER.getTypeId() || id == EntityType.ENDERMAN.getTypeId()) {
|
||||
metadata.a(17, (byte) 0);
|
||||
}
|
||||
if (id == EntityType.OCELOT.getTypeId()) {
|
||||
metadata.a(18, (byte) 0);
|
||||
}
|
||||
|
||||
// Make packets out of loop!
|
||||
Packet24MobSpawn p24 = packetMaker(p1, id, metadata);
|
||||
|
||||
for (Player p2 : Bukkit.getServer().getOnlinePlayers())
|
||||
{
|
||||
disguiseToPlayer(p2, p1, id, metadata, p24);
|
||||
}
|
||||
}
|
||||
|
||||
public static void disguiseToPlayer(Player p1, Player disguised, Byte id)
|
||||
{
|
||||
DataWatcher metadata = new DataWatcher();
|
||||
metadata.a(0, (byte) 0);
|
||||
metadata.a(12, 0);
|
||||
if (id == EntityType.SHEEP.getTypeId() || id == EntityType.PIG.getTypeId() || id == EntityType.ENDERMAN.getTypeId()) {
|
||||
metadata.a(16, (byte) 0);
|
||||
} else if (id == EntityType.SLIME.getTypeId()) {
|
||||
metadata.a(16, (byte) 3);
|
||||
} else if (id == EntityType.VILLAGER.getTypeId()) {
|
||||
metadata.a(16, 0);
|
||||
}
|
||||
|
||||
if (id == EntityType.CREEPER.getTypeId() || id == EntityType.ENDERMAN.getTypeId()) {
|
||||
metadata.a(17, (byte) 0);
|
||||
}
|
||||
if (id == EntityType.OCELOT.getTypeId()) {
|
||||
metadata.a(18, (byte) 0);
|
||||
}
|
||||
|
||||
// Make packets out of loop!
|
||||
Packet24MobSpawn p24 = packetMaker(p1, id, metadata);
|
||||
|
||||
disguiseToPlayer(p1, disguised, id, metadata, p24);
|
||||
}
|
||||
|
||||
public static void disguiseToPlayer(Player p1, Player disguised, Byte id, DataWatcher metadata, Packet24MobSpawn p24)
|
||||
{
|
||||
if (p1 == disguised)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
((CraftPlayer) p1).getHandle().playerConnection.sendPacket(p24);
|
||||
}
|
||||
|
||||
// Begin code for p2p disguising
|
||||
public static void disguisep2pToAll(Player p, String name)
|
||||
{
|
||||
if (name.length() > 16) name = name.substring(0, 16);
|
||||
|
||||
Packet20NamedEntitySpawn spawnPacket = packetMaker(p, name);
|
||||
Packet29DestroyEntity killPacket = new Packet29DestroyEntity(p.getEntityId());
|
||||
|
||||
for (Player p1 : Bukkit.getServer().getOnlinePlayers())
|
||||
{
|
||||
disguisep2pToPlayer(p1, p, killPacket, spawnPacket);
|
||||
}
|
||||
}
|
||||
|
||||
public static void disguisep2pToPlayer(Player p1, Player disguised, String name)
|
||||
{
|
||||
if (name.length() > 16) name = name.substring(0, 16);
|
||||
|
||||
disguisep2pToPlayer(p1, disguised, new Packet29DestroyEntity(disguised.getEntityId()), packetMaker(disguised, name));
|
||||
}
|
||||
|
||||
public static void disguisep2pToPlayer(Player p1, Player disguised, Packet29DestroyEntity killPacket, Packet20NamedEntitySpawn spawnPacket)
|
||||
{
|
||||
if (p1.getName().equals(disguised.getName()))
|
||||
return;
|
||||
|
||||
((CraftPlayer) p1).getHandle().playerConnection.sendPacket(killPacket);
|
||||
((CraftPlayer) p1).getHandle().playerConnection.sendPacket(spawnPacket);
|
||||
System.out.println("Disguising '" + disguised.getName() + "' as '" + spawnPacket.b + "' for '" + p1.getName() + "'");
|
||||
}
|
||||
|
||||
public static void undisguisep2pToAll(Player p)
|
||||
{
|
||||
Packet20NamedEntitySpawn p20 = packetMaker(p, p.getName());
|
||||
Packet29DestroyEntity p29 = new Packet29DestroyEntity(p.getEntityId());
|
||||
|
||||
for (Player p1 : Bukkit.getServer().getOnlinePlayers())
|
||||
{
|
||||
if (p1.getName().equals(p.getName()))
|
||||
continue;
|
||||
|
||||
((CraftPlayer) p1).getHandle().playerConnection.sendPacket(p29);
|
||||
((CraftPlayer) p1).getHandle().playerConnection.sendPacket(p20);
|
||||
System.out.println("Revealing '" + p.getName() + "' for '" + p1.getName() + "'");
|
||||
}
|
||||
}
|
||||
|
||||
public static Packet20NamedEntitySpawn packetMaker(Player p, String name)
|
||||
{
|
||||
Packet20NamedEntitySpawn packet = new Packet20NamedEntitySpawn(((CraftPlayer)p).getHandle());
|
||||
packet.b = name;
|
||||
return packet;
|
||||
}
|
||||
|
||||
public static Packet24MobSpawn packetMaker(Player p1, Byte id, DataWatcher metadata)
|
||||
{
|
||||
Location loc = p1.getLocation();
|
||||
int x = MathHelper.floor(loc.getX() *32D);
|
||||
int y = MathHelper.floor(loc.getY() *32D);
|
||||
int z = MathHelper.floor(loc.getZ() *32D);
|
||||
|
||||
Packet24MobSpawn packet = new Packet24MobSpawn();
|
||||
packet.a = p1.getEntityId();
|
||||
packet.b = id;
|
||||
packet.c = (int) x;
|
||||
packet.d = (int) y;
|
||||
packet.e = (int) z;
|
||||
packet.f = (byte) ((int) loc.getYaw() * 256.0F / 360.0F);
|
||||
packet.g = (byte) ((int) (loc.getPitch() * 256.0F / 360.0F));
|
||||
packet.h = packet.f;
|
||||
try {
|
||||
Field metadataField = packet.getClass().getDeclaredField("i");
|
||||
metadataField.setAccessible(true);
|
||||
metadataField.set(packet, metadata);
|
||||
} catch (Exception e) {
|
||||
System.out.println("unable to set the metadata for a disguise!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Chicken fix
|
||||
if (id == EntityType.CHICKEN.getTypeId())
|
||||
{
|
||||
packet.g = (byte) (packet.g * -1);
|
||||
}
|
||||
|
||||
return packet;
|
||||
}
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
package nautilus.minecraft.core.utils;
|
||||
|
||||
import net.minecraft.server.v1_6_R3.MathHelper;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftEntity;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
public class TntUtil
|
||||
{
|
||||
public static void BypassWaterInExplosionEvent(EntityExplodeEvent event)
|
||||
{
|
||||
double d0;
|
||||
double d1;
|
||||
double d2;
|
||||
|
||||
event.blockList().clear();
|
||||
|
||||
World world = event.getLocation().getWorld();
|
||||
|
||||
for (int i = 0; i < 16; ++i)
|
||||
{
|
||||
for (int j = 0; j < 16; ++j)
|
||||
{
|
||||
for (int k = 0; k < 16; ++k)
|
||||
{
|
||||
if (i == 0 || i == 15 || j == 0 || j == 15 || k == 0 || k == 15)
|
||||
{
|
||||
double d3 = (double) ((float) i / ((float) 16 - 1.0F) * 2.0F - 1.0F);
|
||||
double d4 = (double) ((float) j / ((float) 16 - 1.0F) * 2.0F - 1.0F);
|
||||
double d5 = (double) ((float) k / ((float) 16 - 1.0F) * 2.0F - 1.0F);
|
||||
double d6 = Math.sqrt(d3 * d3 + d4 * d4 + d5 * d5);
|
||||
|
||||
d3 /= d6;
|
||||
d4 /= d6;
|
||||
d5 /= d6;
|
||||
float f1 = 4 * (0.7F + ((CraftWorld)world).getHandle().random.nextFloat() * 0.6F);
|
||||
|
||||
d0 = event.getLocation().getX();
|
||||
d1 = event.getLocation().getY();
|
||||
d2 = event.getLocation().getZ();
|
||||
|
||||
for (float f2 = 0.3F; f1 > 0.0F; f1 -= f2 * 0.75F)
|
||||
{
|
||||
int l = MathHelper.floor(d0);
|
||||
int i1 = MathHelper.floor(d1);
|
||||
int j1 = MathHelper.floor(d2);
|
||||
int k1 = world.getBlockTypeIdAt(l, i1, j1);
|
||||
|
||||
if (k1 > 0 && k1 != 8 && k1 != 9 && k1 != 10 && k1 != 11)
|
||||
{
|
||||
f1 -= (net.minecraft.server.v1_6_R3.Block.byId[k1].a(((CraftEntity)event.getEntity()).getHandle()) + 0.3F) * f2;
|
||||
}
|
||||
|
||||
if (f1 > 0.0F && i1 < 256 && i1 >= 0 && k1 != 8 && k1 != 9 && k1 != 10 && k1 != 11)
|
||||
{
|
||||
org.bukkit.block.Block block = world.getBlockAt(l, i1, j1);
|
||||
|
||||
if (block.getType() != org.bukkit.Material.AIR && !event.blockList().contains(block))
|
||||
{
|
||||
event.blockList().add(block);
|
||||
}
|
||||
}
|
||||
|
||||
d0 += d3 * (double) f2;
|
||||
d1 += d4 * (double) f2;
|
||||
d2 += d5 * (double) f2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
package nautilus.minecraft.core.utils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import net.minecraft.server.v1_6_R3.*;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_6_R3.entity.CraftZombie;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
|
||||
public class ZombieSpeedUtil
|
||||
{
|
||||
@EventHandler
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof CraftZombie)
|
||||
{
|
||||
EntityZombie zombie = ((CraftZombie)event.getEntity()).getHandle();
|
||||
|
||||
try
|
||||
{
|
||||
Field metadataField = EntityInsentient.class.getDeclaredField("goalSelector");
|
||||
metadataField.setAccessible(true);
|
||||
|
||||
// Original speed is .23F
|
||||
float modifier = 1.5F;
|
||||
float modifiedSpeed = 0.23F * modifier;
|
||||
|
||||
PathfinderGoalSelector goalSelector = new PathfinderGoalSelector(zombie.world != null && zombie.world.methodProfiler != null ? zombie.world.methodProfiler : null);
|
||||
goalSelector.a(0, new PathfinderGoalFloat(zombie));
|
||||
goalSelector.a(1, new PathfinderGoalBreakDoor(zombie));
|
||||
goalSelector.a(2, new PathfinderGoalMeleeAttack(zombie, EntityHuman.class, modifiedSpeed, false));
|
||||
goalSelector.a(3, new PathfinderGoalMeleeAttack(zombie, EntityVillager.class, modifiedSpeed, true));
|
||||
goalSelector.a(4, new PathfinderGoalMoveTowardsRestriction(zombie, 0.23F));
|
||||
goalSelector.a(5, new PathfinderGoalMoveThroughVillage(zombie, 0.23F, false));
|
||||
goalSelector.a(6, new PathfinderGoalRandomStroll(zombie, 0.23F));
|
||||
goalSelector.a(7, new PathfinderGoalLookAtPlayer(zombie, EntityHuman.class, 8.0F));
|
||||
goalSelector.a(7, new PathfinderGoalRandomLookaround(zombie));
|
||||
|
||||
metadataField.set(zombie, goalSelector);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.out.println("Unable to modify goal selector");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package nautilus.minecraft.core.webserver.token.Wiki;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GameClassWikiToken
|
||||
{
|
||||
public List<WikiRevisionToken> Revisions;
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package nautilus.minecraft.core.webserver.token.Wiki;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ItemWikiToken
|
||||
{
|
||||
public short TypeId;
|
||||
public short Data;
|
||||
|
||||
public List<WikiRevisionToken> Revisions;
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package nautilus.minecraft.core.webserver.token.Wiki;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ServerWikiToken
|
||||
{
|
||||
public List<GameClassWikiToken> GameClassWikis;
|
||||
public List<ItemWikiToken> ItemWikis;
|
||||
public List<SkillWikiToken> SkillWikis;
|
||||
public List<WeaponWikiToken> WeaponWikis;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package nautilus.minecraft.core.webserver.token.Wiki;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SkillWikiToken
|
||||
{
|
||||
public List<WikiRevisionToken> Revisions;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package nautilus.minecraft.core.webserver.token.Wiki;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class WeaponWikiToken
|
||||
{
|
||||
public List<WikiRevisionToken> Revisions;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user