Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex

This commit is contained in:
CoderTim 2014-10-15 20:44:50 -04:00
commit 233e6d0b46
7 changed files with 92 additions and 13 deletions

View File

@ -107,6 +107,7 @@
<zipfileset src="../Libraries/commons-logging-1.1.1.jar" />
<zipfileset src="../Libraries/commons-io-2.4.jar" />
<zipfileset src="../Libraries/commons-codec-1.6.jar" />
<zipfileset src="../Libraries/jooq-3.4.2.jar" />
<zipfileset src="../Libraries/jedis-2.4.2.jar" />
<zipfileset src="../Libraries/commons-pool2-2.2.jar" />
</jar>

View File

@ -3,6 +3,7 @@ package mineplex.core;
import java.lang.reflect.Field;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import mineplex.core.common.DummyEntity;
import mineplex.core.common.util.NautHashMap;
@ -35,6 +36,8 @@ import org.bukkit.plugin.java.JavaPlugin;
public class CustomTagFix extends MiniPlugin implements IPacketHandler
{
private NautHashMap<Player, NautHashMap<Integer, Integer>> _entityMap = new NautHashMap<Player, NautHashMap<Integer, Integer>>();
private NautHashMap<Player, NautHashMap<Integer, String>> _entityNameMap = new NautHashMap<Player, NautHashMap<Integer, String>>();
private NautHashMap<Player, NautHashMap<Integer, Integer>> _entityVehicleMap = new NautHashMap<Player, NautHashMap<Integer, Integer>>();
private NautHashMap<Player, Long> _loggedIn = new NautHashMap<Player, Long>();
private Field _destroyId;
@ -98,6 +101,8 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
if (owner.isOnline() && !_entityMap.containsKey(owner))
{
_entityMap.put(owner, new NautHashMap<Integer, Integer>());
_entityNameMap.put(owner, new NautHashMap<Integer, String>());
_entityVehicleMap.put(owner, new NautHashMap<Integer, Integer>());
_loggedIn.put(owner, System.currentTimeMillis());
}
@ -113,12 +118,15 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
for (WatchableObject watchable : (List<WatchableObject>)spawnPacket.l.c())
{
if ((watchable.a() == 11 || watchable.a() == 3) && watchable.b() instanceof Byte)
if ((watchable.a() == 11 || watchable.a() == 3) && watchable.b() instanceof Byte && ((Byte)watchable.b()) == 1)
{
final String entityName = spawnPacket.l.getString(10);
if (entityName.isEmpty())
{
_entityNameMap.get(owner).remove(spawnPacket.a);
return;
}
if (_entityMap.get(owner).containsKey(spawnPacket.a))
{
@ -128,6 +136,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
int newId = UtilEnt.getNewEntityId();
sendProtocolPackets(owner, spawnPacket.a, newId, entityName, verifier);
_entityMap.get(owner).put(spawnPacket.a, newId);
_entityNameMap.get(owner).put(spawnPacket.a, entityName);
break;
}
@ -140,19 +149,30 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
if (!_entityMap.get(owner).containsKey(metaPacket.a) && metaPacket.a != 777777)
{
String entityName = "";
boolean nameShowing = false;
for (WatchableObject watchable : (List<WatchableObject>)metaPacket.b)
{
if ((watchable.a() == 11 || watchable.a() == 3) && watchable.b() instanceof Byte && ((Byte)watchable.b()) == 1)
{
nameShowing = true;
}
if ((watchable.a() == 10 || watchable.a() == 2) && watchable.b() instanceof String)
{
entityName = (String)watchable.b();
}
}
if (!entityName.isEmpty())
if (nameShowing && !entityName.isEmpty())
{
int newId = UtilEnt.getNewEntityId();
sendProtocolPackets(owner, metaPacket.a, newId, entityName, verifier);
_entityMap.get(owner).put(metaPacket.a, newId);
_entityNameMap.get(owner).put(metaPacket.a, entityName);
}
else if (!entityName.isEmpty())
{
_entityNameMap.get(owner).remove(metaPacket.a);
}
}
}
@ -166,6 +186,8 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
{
verifier.bypassProcess(new PacketPlayOutEntityDestroy(_entityMap.get(owner).get(id)));
_entityMap.get(owner).remove(id);
_entityVehicleMap.get(owner).remove(id);
_entityNameMap.get(owner).remove(id);
}
}
}
@ -178,9 +200,33 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
{
PacketPlayOutAttachEntity attachPacket = (PacketPlayOutAttachEntity)packet;
/* TODO dynamic attach handling?
if (attachPacket.c == -1)
{
if (_entityVehicleMap.get(owner).containsKey(attachPacket.b) && _entityNameMap.get(owner).containsKey(_entityVehicleMap.get(owner).get(attachPacket.b)))
{
int newId = UtilEnt.getNewEntityId();
sendProtocolPackets(owner, _entityVehicleMap.get(owner).get(attachPacket.b), newId, _entityNameMap.get(owner).get(_entityVehicleMap.get(owner).get(attachPacket.b)), verifier);
_entityMap.get(owner).put(attachPacket.b, newId);
_entityVehicleMap.get(owner).remove(attachPacket.b);
packetInfo.setCancelled(true);
}
}
else
{
_entityVehicleMap.get(owner).put(attachPacket.b, attachPacket.c);
}
if (_entityMap.get(owner).containsKey(attachPacket.c))
{
verifier.bypassProcess(new PacketPlayOutEntityDestroy(_entityMap.get(owner).get(attachPacket.c)));
_entityMap.get(owner).remove(attachPacket.c);
}
else
*/
if (attachPacket.c == owner.getEntityId())
{
System.out.println("Yea, adding patch mount item.");
if (_entityMap.get(owner).containsKey(attachPacket.b))
{
verifier.bypassProcess(new PacketPlayOutEntityDestroy(_entityMap.get(owner).get(attachPacket.b)));
@ -371,6 +417,22 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
vehiclePacket.c = entityId;
packetList.bypassProcess(vehiclePacket);
/* TODO dynamic attach handling?
if (_entityVehicleMap.get(owner).containsValue(entityId))
{
vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0;
for (Entry<Integer, Integer> entry : _entityVehicleMap.get(owner).entrySet())
{
if (entry.getValue() == entityId)
vehiclePacket.b = entry.getKey();
}
vehiclePacket.c = packet.a;
}
*/
}
});
}

View File

@ -182,7 +182,7 @@ public class CoreClientManager extends MiniPlugin
});
// JSON sql response
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response));
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
// Load client in miniplugins
Bukkit.getServer().getPluginManager().callEvent(new AsyncClientLoadEvent(token, client));
@ -239,7 +239,7 @@ public class CoreClientManager extends MiniPlugin
_repository.updateMysqlRank(uuid.toString(), token.Rank, token.RankPerm, new Timestamp(Date.parse(token.RankExpire)).toString());
// JSON sql response
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response));
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
// Load client in miniplugins
Bukkit.getServer().getPluginManager().callEvent(new AsyncClientLoadEvent(token, client));

View File

@ -1,5 +1,7 @@
package mineplex.core.account.event;
import java.util.UUID;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@ -8,10 +10,12 @@ public class ClientWebResponseEvent extends Event
private static final HandlerList handlers = new HandlerList();
private String _response;
private UUID _uuid;
public ClientWebResponseEvent(String response)
public ClientWebResponseEvent(String response, UUID uuid)
{
_response = response;
_uuid = uuid;
}
public String GetResponse()
@ -28,4 +32,9 @@ public class ClientWebResponseEvent extends Event
{
return handlers;
}
public UUID getUniqueId()
{
return _uuid;
}
}

View File

@ -48,7 +48,7 @@ public class DonationManager extends MiniPlugin
public void OnClientWebResponse(ClientWebResponseEvent event)
{
DonorTokenWrapper token = new Gson().fromJson(event.GetResponse(), DonorTokenWrapper.class);
LoadDonor(token);
LoadDonor(token, event.getUniqueId());
}
@EventHandler
@ -60,12 +60,12 @@ public class DonationManager extends MiniPlugin
}
}
private void LoadDonor(DonorTokenWrapper token)
private void LoadDonor(DonorTokenWrapper token, UUID uuid)
{
synchronized (_donorLock)
{
_donors.put(token.Name, new Donor(token.DonorToken));
_repository.updateGemsAndCoins(token.Name, Get(token.Name).GetGems(), Get(token.Name).getCoins());
_repository.updateGemsAndCoins(uuid, Get(token.Name).GetGems(), Get(token.Name).getCoins());
}
}

View File

@ -1,5 +1,7 @@
package mineplex.core.donation.repository;
import java.util.UUID;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.Callback;
@ -172,13 +174,13 @@ public class DonationRepository extends RepositoryBase
{
}
public void updateGemsAndCoins(final String name, final int gems, final int coins)
public void updateGemsAndCoins(final UUID uuid, final int gems, final int coins)
{
handleDatabaseCall(new DatabaseRunnable(new Runnable()
{
public void run()
{
executeUpdate(UPDATE_NULL_ACCOUNT_GEMS_AND_COINS_, new ColumnInt("gems", gems), new ColumnInt("coins", coins), new ColumnVarChar("uuid", 100, UUIDFetcher.getUUIDOf(name).toString()));
executeUpdate(UPDATE_NULL_ACCOUNT_GEMS_AND_COINS_, new ColumnInt("gems", gems), new ColumnInt("coins", coins), new ColumnVarChar("uuid", 100, uuid.toString()));
}
}), "Error updating player's null gems and coins DonationRepository : ");
}

View File

@ -25,11 +25,16 @@ public class GemHunterCommand extends CommandBase<SalesPackageManager>
String playerName = args[0];
int amount = Integer.parseInt(args[1]);
int experience = 0;
UUID uuid = UUIDFetcher.getUUIDOf(playerName);
if (amount == 4)
experience = 70000;
else if (amount == 8)
experience = 220000;
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, uuid, "Gem Hunter Level " + amount, false, 0, false);
Plugin.getStatsManager().incrementStat(uuid.toString(), "Global.GemsEarned", 5000 + (amount * 5000));
Plugin.getStatsManager().incrementStat(uuid.toString(), "Global.GemsEarned", experience);
caller.sendMessage(F.main(Plugin.GetName(), "Added Level " + amount + " Gem Hunter to " + playerName + "'s account!"));
}
}