Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
7402eb2f91
Binary file not shown.
@ -0,0 +1,6 @@
|
|||||||
|
package mineplex.core.common.util;
|
||||||
|
|
||||||
|
public interface RunnableStatus
|
||||||
|
{
|
||||||
|
public boolean run();
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package mineplex.core.cosmetic.ui.button;
|
package mineplex.core.cosmetic.ui.button;
|
||||||
|
|
||||||
import mineplex.core.cosmetic.ui.page.Menu;
|
import mineplex.core.cosmetic.ui.page.Menu;
|
||||||
import mineplex.core.cosmetic.ui.page.MorphPage;
|
import mineplex.core.cosmetic.ui.page.MountPage;
|
||||||
import mineplex.core.shop.item.SingleButton;
|
import mineplex.core.shop.item.SingleButton;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -18,6 +18,6 @@ public class OpenMounts extends SingleButton
|
|||||||
@Override
|
@Override
|
||||||
public void Clicked(Player player)
|
public void Clicked(Player player)
|
||||||
{
|
{
|
||||||
_page.getShop().OpenPageForPlayer(player, new MorphPage(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), "Mounts", player));
|
_page.getShop().OpenPageForPlayer(player, new MountPage(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), "Mounts", player));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package mineplex.core.cosmetic.ui.button;
|
package mineplex.core.cosmetic.ui.button;
|
||||||
|
|
||||||
import mineplex.core.cosmetic.ui.page.Menu;
|
import mineplex.core.cosmetic.ui.page.Menu;
|
||||||
import mineplex.core.cosmetic.ui.page.MorphPage;
|
import mineplex.core.cosmetic.ui.page.ParticlePage;
|
||||||
import mineplex.core.shop.item.SingleButton;
|
import mineplex.core.shop.item.SingleButton;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -18,6 +18,6 @@ public class OpenParticles extends SingleButton
|
|||||||
@Override
|
@Override
|
||||||
public void Clicked(Player player)
|
public void Clicked(Player player)
|
||||||
{
|
{
|
||||||
_page.getShop().OpenPageForPlayer(player, new MorphPage(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), "Particles", player));
|
_page.getShop().OpenPageForPlayer(player, new ParticlePage(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), "Particles", player));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package mineplex.core.cosmetic.ui.button;
|
package mineplex.core.cosmetic.ui.button;
|
||||||
|
|
||||||
import mineplex.core.cosmetic.ui.page.Menu;
|
import mineplex.core.cosmetic.ui.page.Menu;
|
||||||
import mineplex.core.cosmetic.ui.page.MorphPage;
|
import mineplex.core.cosmetic.ui.page.PetPage;
|
||||||
import mineplex.core.shop.item.SingleButton;
|
import mineplex.core.shop.item.SingleButton;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -17,6 +17,6 @@ public class OpenPets extends SingleButton
|
|||||||
@Override
|
@Override
|
||||||
public void Clicked(Player player)
|
public void Clicked(Player player)
|
||||||
{
|
{
|
||||||
_page.getShop().OpenPageForPlayer(player, new MorphPage(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), "Pets", player));
|
_page.getShop().OpenPageForPlayer(player, new PetPage(_page.getPlugin(), _page.getShop(), _page.getClientManager(), _page.getDonationManager(), "Pets", player));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,7 +11,6 @@ import java.util.Iterator;
|
|||||||
import mineplex.core.common.util.NautHashMap;
|
import mineplex.core.common.util.NautHashMap;
|
||||||
import mineplex.core.database.column.Column;
|
import mineplex.core.database.column.Column;
|
||||||
import mineplex.core.logger.Logger;
|
import mineplex.core.logger.Logger;
|
||||||
import mineplex.core.timing.TimingManager;
|
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
|
||||||
@ -229,14 +228,7 @@ public abstract class RepositoryBase implements Listener
|
|||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
Logger.Instance.log(errorMessage + exception.getMessage());
|
processFailedDatabaseCall(databaseRunnable, exception.getMessage(), errorMessage);
|
||||||
|
|
||||||
databaseRunnable.incrementFailCount();
|
|
||||||
|
|
||||||
synchronized (_queueLock)
|
|
||||||
{
|
|
||||||
_failedQueue.put(databaseRunnable, errorMessage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -244,6 +236,25 @@ public abstract class RepositoryBase implements Listener
|
|||||||
asyncThread.start();
|
asyncThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void processFailedDatabaseCall(DatabaseRunnable databaseRunnable, String errorPreMessage, String runnableMessage)
|
||||||
|
{
|
||||||
|
if (databaseRunnable.getFailedCounts() < 4)
|
||||||
|
{
|
||||||
|
databaseRunnable.incrementFailCount();
|
||||||
|
|
||||||
|
synchronized (_queueLock)
|
||||||
|
{
|
||||||
|
_failedQueue.put(databaseRunnable, runnableMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.Instance.log(errorPreMessage + runnableMessage);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Logger.Instance.log("Abandoning database call : " + runnableMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void processDatabaseQueue(UpdateEvent event)
|
public void processDatabaseQueue(UpdateEvent event)
|
||||||
{
|
{
|
||||||
@ -259,37 +270,8 @@ public abstract class RepositoryBase implements Listener
|
|||||||
{
|
{
|
||||||
for (Iterator<DatabaseRunnable> runnablesIterator = _failedQueue.keySet().iterator(); runnablesIterator.hasNext();)
|
for (Iterator<DatabaseRunnable> runnablesIterator = _failedQueue.keySet().iterator(); runnablesIterator.hasNext();)
|
||||||
{
|
{
|
||||||
final DatabaseRunnable databaseRunnable = runnablesIterator.next();
|
DatabaseRunnable databaseRunnable = runnablesIterator.next();
|
||||||
|
handleDatabaseCall(databaseRunnable, _failedQueue.get(databaseRunnable));
|
||||||
Thread asyncThread = new Thread(new Runnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
databaseRunnable.run();
|
|
||||||
}
|
|
||||||
catch (Exception exception)
|
|
||||||
{
|
|
||||||
Logger.Instance.log(_failedQueue.get(databaseRunnable) + exception.getMessage());
|
|
||||||
|
|
||||||
if (databaseRunnable.getFailedCounts() < 4)
|
|
||||||
{
|
|
||||||
synchronized (_queueLock)
|
|
||||||
{
|
|
||||||
_failedQueue.put(databaseRunnable, _failedQueue.get(databaseRunnable));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Logger.Instance.log("Abandoning database call : " + _failedQueue.get(databaseRunnable));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
runnablesIterator.remove();
|
|
||||||
asyncThread.start();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,7 @@ public class DonationManager extends MiniPlugin
|
|||||||
|
|
||||||
private NautHashMap<Player, NautHashMap<String, Integer>> _gemQueue = new NautHashMap<Player, NautHashMap<String, Integer>>();
|
private NautHashMap<Player, NautHashMap<String, Integer>> _gemQueue = new NautHashMap<Player, NautHashMap<String, Integer>>();
|
||||||
private NautHashMap<Player, NautHashMap<String, Integer>> _coinQueue = new NautHashMap<Player, NautHashMap<String, Integer>>();
|
private NautHashMap<Player, NautHashMap<String, Integer>> _coinQueue = new NautHashMap<Player, NautHashMap<String, Integer>>();
|
||||||
|
private NautHashMap<Player, NautHashMap<String, Integer>> _goldQueue = new NautHashMap<Player, NautHashMap<String, Integer>>();
|
||||||
|
|
||||||
public DonationManager(JavaPlugin plugin, String webAddress)
|
public DonationManager(JavaPlugin plugin, String webAddress)
|
||||||
{
|
{
|
||||||
@ -301,6 +302,88 @@ public class DonationManager extends MiniPlugin
|
|||||||
//Clean
|
//Clean
|
||||||
_coinQueue.clear();
|
_coinQueue.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RewardGold(Callback<Boolean> callback, String caller, String name, UUID uuid, int amount)
|
||||||
|
{
|
||||||
|
RewardGold(callback, caller, name, uuid, amount, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RewardGold(final Callback<Boolean> callback, final String caller, final String name, final UUID uuid, final int amount, final boolean updateTotal)
|
||||||
|
{
|
||||||
|
_repository.rewardGold(new Callback<Boolean>()
|
||||||
|
{
|
||||||
|
public void run(Boolean success)
|
||||||
|
{
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
if (updateTotal)
|
||||||
|
{
|
||||||
|
Donor donor = Get(name);
|
||||||
|
|
||||||
|
if (donor != null)
|
||||||
|
{
|
||||||
|
donor.addGold(amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (callback != null)
|
||||||
|
callback.run(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, caller, name, uuid.toString(), amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RewardGoldLater(final String caller, final Player player, final int amount)
|
||||||
|
{
|
||||||
|
if (!_goldQueue.containsKey(player))
|
||||||
|
_goldQueue.put(player, new NautHashMap<String, Integer>());
|
||||||
|
|
||||||
|
int totalAmount = amount;
|
||||||
|
|
||||||
|
if (_goldQueue.get(player).containsKey(caller))
|
||||||
|
totalAmount += _goldQueue.get(player).get(caller);
|
||||||
|
|
||||||
|
_goldQueue.get(player).put(caller, totalAmount);
|
||||||
|
|
||||||
|
//Do Temp Change
|
||||||
|
Donor donor = Get(player.getName());
|
||||||
|
|
||||||
|
if (donor != null)
|
||||||
|
donor.addGold(amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void UpdateGoldQueue(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.SLOWER)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (Player player : _goldQueue.keySet())
|
||||||
|
{
|
||||||
|
String caller = null;
|
||||||
|
int total = 0;
|
||||||
|
|
||||||
|
for (String curCaller : _goldQueue.get(player).keySet())
|
||||||
|
{
|
||||||
|
caller = curCaller;
|
||||||
|
total += _goldQueue.get(player).get(curCaller);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (caller == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
//Actually Add Gold
|
||||||
|
RewardGold(null, caller, player.getName(), player.getUniqueId(), total, false);
|
||||||
|
|
||||||
|
System.out.println("Queue Added [" + player + "] with Gold [" + total + "] for [" + caller + "]");
|
||||||
|
|
||||||
|
//Clean
|
||||||
|
_goldQueue.get(player).clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Clean
|
||||||
|
_goldQueue.clear();
|
||||||
|
}
|
||||||
|
|
||||||
public void applyKits(String playerName)
|
public void applyKits(String playerName)
|
||||||
{
|
{
|
||||||
|
@ -12,6 +12,7 @@ public class Donor
|
|||||||
{
|
{
|
||||||
private int _gems;
|
private int _gems;
|
||||||
private int _coins;
|
private int _coins;
|
||||||
|
private int _gold;
|
||||||
private boolean _donated;
|
private boolean _donated;
|
||||||
private List<Integer> _salesPackagesOwned;
|
private List<Integer> _salesPackagesOwned;
|
||||||
private List<String> _unknownSalesPackagesOwned;
|
private List<String> _unknownSalesPackagesOwned;
|
||||||
@ -159,9 +160,19 @@ public class Donor
|
|||||||
{
|
{
|
||||||
_coins += amount;
|
_coins += amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addGold(int amount)
|
||||||
|
{
|
||||||
|
_gold += amount;
|
||||||
|
}
|
||||||
|
|
||||||
public List<CoinTransactionToken> getCoinTransactions()
|
public List<CoinTransactionToken> getCoinTransactions()
|
||||||
{
|
{
|
||||||
return _coinTransactions;
|
return _coinTransactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getGold()
|
||||||
|
{
|
||||||
|
return _gold;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import mineplex.core.database.column.ColumnVarChar;
|
|||||||
import mineplex.core.donation.repository.token.GemRewardToken;
|
import mineplex.core.donation.repository.token.GemRewardToken;
|
||||||
import mineplex.core.donation.repository.token.PurchaseToken;
|
import mineplex.core.donation.repository.token.PurchaseToken;
|
||||||
import mineplex.core.donation.repository.token.UnknownPurchaseToken;
|
import mineplex.core.donation.repository.token.UnknownPurchaseToken;
|
||||||
|
import mineplex.core.logger.Logger;
|
||||||
import mineplex.core.server.remotecall.AsyncJsonWebCall;
|
import mineplex.core.server.remotecall.AsyncJsonWebCall;
|
||||||
import mineplex.core.server.remotecall.JsonWebCall;
|
import mineplex.core.server.remotecall.JsonWebCall;
|
||||||
import mineplex.core.server.util.TransactionResponse;
|
import mineplex.core.server.util.TransactionResponse;
|
||||||
@ -23,6 +24,7 @@ public class DonationRepository extends RepositoryBase
|
|||||||
private static String CREATE_GEM_TRANSACTION_TABLE = "CREATE TABLE IF NOT EXISTS accountGemTransactions (id INT NOT NULL AUTO_INCREMENT, accounts_uuid VARCHAR(100), reason VARCHAR(100), gems INT, PRIMARY KEY (id), FOREIGN KEY (accounts_uuid) REFERENCES accounts(uuid), INDEX gemUuidIndex (accounts_uuid));";
|
private static String CREATE_GEM_TRANSACTION_TABLE = "CREATE TABLE IF NOT EXISTS accountGemTransactions (id INT NOT NULL AUTO_INCREMENT, accounts_uuid VARCHAR(100), reason VARCHAR(100), gems INT, PRIMARY KEY (id), FOREIGN KEY (accounts_uuid) REFERENCES accounts(uuid), INDEX gemUuidIndex (accounts_uuid));";
|
||||||
private static String INSERT_COIN_TRANSACTION = "INSERT INTO accountCoinTransactions(accounts_uuid, reason, coins) VALUES(?, ?, ?);";
|
private static String INSERT_COIN_TRANSACTION = "INSERT INTO accountCoinTransactions(accounts_uuid, reason, coins) VALUES(?, ?, ?);";
|
||||||
private static String UPDATE_ACCOUNT_COINS = "UPDATE accounts SET coins = coins + ? WHERE uuid = ?;";
|
private static String UPDATE_ACCOUNT_COINS = "UPDATE accounts SET coins = coins + ? WHERE uuid = ?;";
|
||||||
|
private static String UPDATE_ACCOUNT_GOLD = "UPDATE accounts SET gold = gold + ? WHERE uuid = ?;";
|
||||||
private static String UPDATE_NULL_ACCOUNT_GEMS_AND_COINS_ = "UPDATE accounts SET gems = ?, coins = ? WHERE uuid = ? AND gems IS NULL AND coins IS NULL;";
|
private static String UPDATE_NULL_ACCOUNT_GEMS_AND_COINS_ = "UPDATE accounts SET gems = ?, coins = ? WHERE uuid = ? AND gems IS NULL AND coins IS NULL;";
|
||||||
|
|
||||||
private String _webAddress;
|
private String _webAddress;
|
||||||
@ -174,6 +176,25 @@ public class DonationRepository extends RepositoryBase
|
|||||||
}
|
}
|
||||||
}), "Error updating player coin amount in DonationRepository : ");
|
}), "Error updating player coin amount in DonationRepository : ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void rewardGold(final Callback<Boolean> callback, final String giver, final String name, final String uuid, final int gold)
|
||||||
|
{
|
||||||
|
final GemRewardToken token = new GemRewardToken();
|
||||||
|
token.Source = giver;
|
||||||
|
token.Name = name;
|
||||||
|
token.Amount = gold;
|
||||||
|
|
||||||
|
handleDatabaseCall(new DatabaseRunnable(new Runnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if (executeUpdate(UPDATE_ACCOUNT_GOLD, new ColumnInt("gold", gold), new ColumnVarChar("uuid", 100, uuid)) < 1)
|
||||||
|
{
|
||||||
|
Logger.Instance.log("Account gold wasn't updated for " + name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}), "Error updating player gold amount in DonationRepository : ");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initialize()
|
protected void initialize()
|
||||||
|
@ -123,6 +123,7 @@ public class ConfirmationPage<PluginType extends MiniPlugin, ShopType extends Sh
|
|||||||
{
|
{
|
||||||
for (int i=_okSquareSlotStart; i < 54; i++)
|
for (int i=_okSquareSlotStart; i < 54; i++)
|
||||||
{
|
{
|
||||||
|
ButtonMap.remove(i);
|
||||||
clear(i);
|
clear(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package mineplex.game.clans.shop;
|
package mineplex.game.clans.shop;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.shop.page.ShopPageBase;
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
@ -15,6 +17,7 @@ public class BuildingPage extends ShopPageBase<ClansManager, BuildingShop>
|
|||||||
@Override
|
@Override
|
||||||
protected void BuildPage()
|
protected void BuildPage()
|
||||||
{
|
{
|
||||||
|
PvpItem item = new PvpItem(Material.STONE, (byte)0, 1, "Stone", 25, 64);
|
||||||
|
AddButton(1, item, new PvpShopButton<BuildingPage>(this, item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
package mineplex.game.clans.shop;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
import mineplex.core.common.util.C;
|
||||||
|
import mineplex.core.shop.item.ShopItem;
|
||||||
|
|
||||||
|
public class PvpItem extends ShopItem
|
||||||
|
{
|
||||||
|
private static String LEFT_CLICK_BUY = C.cWhite + "Left-Click to Buy 1";
|
||||||
|
|
||||||
|
public PvpItem(Material type, byte data, int displayAmount, String name, int price, int bulkCount)
|
||||||
|
{
|
||||||
|
super(type, data, name, new String[]
|
||||||
|
{
|
||||||
|
C.cYellow + C.Bold + name,
|
||||||
|
C.cWhite + " ",
|
||||||
|
LEFT_CLICK_BUY,
|
||||||
|
C.cWhite + "Costs " + C.cGreen + "$" + price,
|
||||||
|
C.cWhite + " ",
|
||||||
|
C.cWhite + "Shift Left-Click to Buy " + bulkCount,
|
||||||
|
C.cWhite + "Costs " + C.cGreen + "$" + (price * bulkCount),
|
||||||
|
}, 0, false, false);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package mineplex.game.clans.shop;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import mineplex.core.shop.item.ComplexButton;
|
||||||
|
import mineplex.core.shop.page.ShopPageBase;
|
||||||
|
import mineplex.game.clans.clans.ClansManager;
|
||||||
|
|
||||||
|
public class PvpShopButton<PageType extends ShopPageBase<ClansManager, BuildingShop>> extends ComplexButton
|
||||||
|
{
|
||||||
|
protected PageType Page;
|
||||||
|
protected PvpItem Item;
|
||||||
|
|
||||||
|
public PvpShopButton(PageType page, PvpItem item)
|
||||||
|
{
|
||||||
|
Page = page;
|
||||||
|
Item = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ClickedLeft(Player player)
|
||||||
|
{
|
||||||
|
int balance = Page.getDonationManager().Get(player.getName()).getGold();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ClickedShiftLeft(Player player)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ClickedRight(Player player)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void ClickedShiftRight(Player player)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
@ -224,7 +224,7 @@ public class PvpClass implements IPvpClass
|
|||||||
{
|
{
|
||||||
_classes.Get(player).SetGameClass(null);
|
_classes.Get(player).SetGameClass(null);
|
||||||
|
|
||||||
UtilPlayer.message(player, F.main("Class", "Armor Class: " + F.oo("None", false)));
|
// UtilPlayer.message(player, F.main("Class", "Armor Class: " + F.oo("None", false)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -50,13 +50,15 @@ public class BlockForm extends Form
|
|||||||
private Location _loc;
|
private Location _loc;
|
||||||
private int _selfEntityId1;
|
private int _selfEntityId1;
|
||||||
private int _selfEntityId2;
|
private int _selfEntityId2;
|
||||||
private Location _lastSaw;
|
private Vector _lastSaw;
|
||||||
private Vector _sawDiff = new Vector();
|
private Vector _sawDiff = new Vector();
|
||||||
|
private boolean _is18;
|
||||||
|
|
||||||
public BlockForm(HideSeek host, Player player, Material mat)
|
public BlockForm(HideSeek host, Player player, Material mat)
|
||||||
{
|
{
|
||||||
super(host, player);
|
super(host, player);
|
||||||
|
|
||||||
|
_is18 = UtilPlayer.is1_8(player);
|
||||||
_mat = mat;
|
_mat = mat;
|
||||||
_loc = player.getLocation();
|
_loc = player.getLocation();
|
||||||
_selfEntityId1 = UtilEnt.getNewEntityId();
|
_selfEntityId1 = UtilEnt.getNewEntityId();
|
||||||
@ -88,27 +90,42 @@ public class BlockForm extends Form
|
|||||||
// Apply Falling Block
|
// Apply Falling Block
|
||||||
FallingBlockCheck();
|
FallingBlockCheck();
|
||||||
|
|
||||||
PacketPlayOutSpawnEntityLiving packet1 = new PacketPlayOutSpawnEntityLiving();
|
// Spawn the falling block that's visible to the disguised player only.
|
||||||
packet1.a = _selfEntityId1;
|
|
||||||
packet1.b = EntityType.SILVERFISH.getTypeId();
|
Packet[] packets = new Packet[3];
|
||||||
packet1.c = (int) Math.floor(_lastSaw.getX() * 32);
|
|
||||||
packet1.d = (int) Math.floor(_lastSaw.getY() * 32);
|
if (_is18)
|
||||||
packet1.e = (int) Math.floor(_lastSaw.getZ() * 32);
|
{
|
||||||
DataWatcher watcher = new DataWatcher(null);
|
PacketPlayOutSpawnEntityLiving packet1 = new PacketPlayOutSpawnEntityLiving();
|
||||||
watcher.a(0, (byte) 32);
|
packet1.a = _selfEntityId1;
|
||||||
watcher.a(1, 0);
|
packet1.b = EntityType.SILVERFISH.getTypeId();
|
||||||
packet1.l = watcher;
|
packet1.c = (int) Math.floor(_lastSaw.getX() * 32);
|
||||||
player.playerConnection.sendPacket(packet1);
|
packet1.d = (int) Math.floor(_lastSaw.getY() * 32);
|
||||||
|
packet1.e = (int) Math.floor(_lastSaw.getZ() * 32);
|
||||||
|
DataWatcher watcher = new DataWatcher(null);
|
||||||
|
watcher.a(0, (byte) 32);
|
||||||
|
watcher.a(1, 0);
|
||||||
|
packet1.l = watcher;
|
||||||
|
packets[0] = packet1;
|
||||||
|
|
||||||
|
PacketPlayOutAttachEntity packet3 = new PacketPlayOutAttachEntity();
|
||||||
|
|
||||||
|
packet3.b = _selfEntityId2;
|
||||||
|
packet3.c = _selfEntityId1;
|
||||||
|
packets[2] = packet3;
|
||||||
|
}
|
||||||
|
|
||||||
PacketPlayOutSpawnEntity packet2 = new PacketPlayOutSpawnEntity(player, 70, _mat.getId());
|
PacketPlayOutSpawnEntity packet2 = new PacketPlayOutSpawnEntity(player, 70, _mat.getId());
|
||||||
packet2.a = _selfEntityId2;
|
packet2.a = _is18 ? _selfEntityId2 : _selfEntityId1;
|
||||||
player.playerConnection.sendPacket(packet2);
|
packets[1] = packet2;
|
||||||
|
|
||||||
PacketPlayOutAttachEntity packet3 = new PacketPlayOutAttachEntity();
|
for (Packet packet : packets)
|
||||||
|
{
|
||||||
packet3.b = _selfEntityId2;
|
if (packet != null)
|
||||||
packet3.c = _selfEntityId1;
|
{
|
||||||
player.playerConnection.sendPacket(packet3);
|
player.playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Inform
|
// Inform
|
||||||
String blockName = F.elem(ItemStackFactory.Instance.GetName(_mat, (byte) 0, false));
|
String blockName = F.elem(ItemStackFactory.Instance.GetName(_mat, (byte) 0, false));
|
||||||
@ -209,6 +226,26 @@ public class BlockForm extends Form
|
|||||||
|
|
||||||
// Sound
|
// Sound
|
||||||
Player.playSound(Player.getLocation(), Sound.NOTE_PLING, 1f, 2f);
|
Player.playSound(Player.getLocation(), Sound.NOTE_PLING, 1f, 2f);
|
||||||
|
|
||||||
|
// Teleport falling block to the position.
|
||||||
|
Vector blockLoc = _block.getLocation().add(0.5, _is18 ? -.21875 : 0, 0.5).toVector();
|
||||||
|
|
||||||
|
_sawDiff.add(blockLoc.clone().subtract(_lastSaw));
|
||||||
|
|
||||||
|
Packet packet = this.getPacket(_sawDiff, blockLoc);
|
||||||
|
|
||||||
|
_lastSaw = Player.getLocation().toVector().subtract(new Vector(0, _is18 ? 0.15625 : 0, 0));
|
||||||
|
_sawDiff = _lastSaw.clone().subtract(blockLoc);
|
||||||
|
|
||||||
|
if (packet != null)
|
||||||
|
{
|
||||||
|
if (packet instanceof PacketPlayOutEntityTeleport)
|
||||||
|
{
|
||||||
|
_sawDiff = new Vector();
|
||||||
|
}
|
||||||
|
|
||||||
|
((CraftPlayer) Player).getHandle().playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -269,7 +306,6 @@ public class BlockForm extends Form
|
|||||||
// Self
|
// Self
|
||||||
Player.sendBlockChange(Player.getLocation(), 36, (byte) 0);
|
Player.sendBlockChange(Player.getLocation(), 36, (byte) 0);
|
||||||
|
|
||||||
FallingBlockCheck();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FallingBlockCheck()
|
public void FallingBlockCheck()
|
||||||
@ -295,50 +331,73 @@ public class BlockForm extends Form
|
|||||||
Player.setPassenger(block);
|
Player.setPassenger(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure Falling doesnt Despawn
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Ensure Falling doesnt Despawn
|
||||||
((CraftFallingSand) Player.getPassenger()).getHandle().ticksLived = 1;
|
((CraftFallingSand) Player.getPassenger()).getHandle().ticksLived = 1;
|
||||||
Player.getPassenger().setTicksLived(1);
|
Player.getPassenger().setTicksLived(1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (_lastSaw == null || _lastSaw.getWorld() != Player.getWorld())
|
// Tell falling block to move around
|
||||||
{
|
|
||||||
_lastSaw = Player.getLocation();
|
if (_lastSaw != null)
|
||||||
}
|
{
|
||||||
this._sawDiff.add(Player.getLocation().subtract(_lastSaw).toVector());
|
this._sawDiff.add(Player.getLocation().subtract(0, _is18 ? 0.15625 : 0, 0).toVector().subtract(_lastSaw));
|
||||||
_lastSaw = Player.getLocation();
|
}
|
||||||
|
|
||||||
|
_lastSaw = Player.getLocation().subtract(0, _is18 ? 0.15625 : 0, 0).toVector();
|
||||||
|
|
||||||
|
Packet packet = this.getPacket(_sawDiff, _lastSaw);
|
||||||
|
|
||||||
|
if (packet != null)
|
||||||
|
{
|
||||||
|
if (packet instanceof PacketPlayOutRelEntityMove)
|
||||||
|
{
|
||||||
|
PacketPlayOutRelEntityMove relPacket = (PacketPlayOutRelEntityMove) packet;
|
||||||
|
_sawDiff.subtract(new Vector(relPacket.b / 32D, relPacket.c / 32D, relPacket.d / 32D));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_sawDiff = new Vector();
|
||||||
|
}
|
||||||
|
|
||||||
|
player.playerConnection.sendPacket(packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Packet getPacket(Vector blocksFromNewPosition, Vector newPosition)
|
||||||
|
{
|
||||||
|
int x = (int) Math.floor(blocksFromNewPosition.getX() * 32);
|
||||||
|
int y = (int) Math.floor(blocksFromNewPosition.getY() * 32);
|
||||||
|
int z = (int) Math.floor(blocksFromNewPosition.getZ() * 32);
|
||||||
|
|
||||||
int x = (int) Math.floor(_sawDiff.getX() * 32);
|
|
||||||
int y = (int) Math.floor(_sawDiff.getY() * 32);
|
|
||||||
int z = (int) Math.floor(_sawDiff.getZ() * 32);
|
|
||||||
if (x != 0 || y != 0 || z != 0)
|
if (x != 0 || y != 0 || z != 0)
|
||||||
{
|
{
|
||||||
Packet packet;
|
|
||||||
if (x >= -128 && x <= 127 && y >= -128 && y <= 127 && z >= -128 && z <= 127)
|
if (x >= -128 && x <= 127 && y >= -128 && y <= 127 && z >= -128 && z <= 127)
|
||||||
{
|
{
|
||||||
_sawDiff.subtract(new Vector(x / 32D, y / 32D, z / 32D));
|
|
||||||
PacketPlayOutRelEntityMove relMove = new PacketPlayOutRelEntityMove();
|
PacketPlayOutRelEntityMove relMove = new PacketPlayOutRelEntityMove();
|
||||||
relMove.a = this._selfEntityId1;
|
relMove.a = this._selfEntityId1;
|
||||||
relMove.b = (byte) x;
|
relMove.b = (byte) x;
|
||||||
relMove.c = (byte) y;
|
relMove.c = (byte) y;
|
||||||
relMove.d = (byte) z;
|
relMove.d = (byte) z;
|
||||||
packet = relMove;
|
|
||||||
|
return relMove;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_sawDiff = new Vector();
|
|
||||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport();
|
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport();
|
||||||
teleportPacket.a = _selfEntityId1;
|
teleportPacket.a = _selfEntityId1;
|
||||||
teleportPacket.b = (int) Math.floor(32 * _lastSaw.getX());
|
teleportPacket.b = (int) Math.floor(32 * newPosition.getX());
|
||||||
teleportPacket.c = (int) Math.floor(32 * _lastSaw.getY());
|
teleportPacket.c = (int) Math.floor(32 * newPosition.getY());
|
||||||
teleportPacket.d = (int) Math.floor(32 * _lastSaw.getZ());
|
teleportPacket.d = (int) Math.floor(32 * newPosition.getZ());
|
||||||
packet = teleportPacket;
|
|
||||||
|
return teleportPacket;
|
||||||
}
|
}
|
||||||
player.playerConnection.sendPacket(packet);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Block GetBlock()
|
public Block GetBlock()
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user