Finish GoldToken integration for cashing in. Re-implement fixed hidden JSON lore encoding. Fix damage reduction attributes where entity types weren't being properly initialized. Prevent players from breaking blocks in temporary Spawn regions.

This commit is contained in:
Ty Sayers 2015-06-02 20:01:42 -04:00
parent 155b078c49
commit 1fa919e954
9 changed files with 28 additions and 13 deletions

View File

@ -15,6 +15,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.game.clans.items.economy.GoldToken;
import mineplex.core.MiniPlugin;
import mineplex.core.common.CurrencyType;
import mineplex.core.common.util.C;
@ -93,6 +94,13 @@ public class GoldManager extends MiniPlugin
{
addGold(player, -amount);
}
public void cashIn(Player player, GoldToken token)
{
int value = token.getGoldValue();
addGold(player, value);
notify(player, String.format("You have cashed in a gold token worth %dg!", value));
}
private Donor getDonor(Player player)
{

View File

@ -67,7 +67,7 @@ public class LoggingManager extends MiniPlugin
public static final long REJOIN_TIME = 60000;
//Track Offline Players
private HashMap<String, LogoutData> _logouts = new HashMap<String, LogoutData>();
private HashMap<String, LogoutData> _logouts;
public LoggingManager(JavaPlugin plugin)
{

View File

@ -87,11 +87,11 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
_playerGears = new HashMap<String, PlayerGear>();
// TODO: Introduce configurable non-hardcoded values for generation weights?
_attributeWeights = new WeightSet<Integer>(new Weight<Integer>(3, 3), new Weight<Integer>(20, 2), new Weight<Integer>(77, 1), new Weight<Integer>(80, 0));
_typeWeights = new WeightSet<ItemType>(new Weight<ItemType>(1000, ItemType.LEGENDARY),
_attributeWeights = new WeightSet<Integer>(new Weight<Integer>(3, 3), new Weight<Integer>(20, 2), new Weight<Integer>(77, 1));
_typeWeights = new WeightSet<ItemType>(new Weight<ItemType>(10, ItemType.LEGENDARY),
new Weight<ItemType>(45, ItemType.ARMOUR),
new Weight<ItemType>(22, ItemType.WEAPON),
new Weight<ItemType>(22, ItemType.BOW));
new Weight<ItemType>(0, ItemType.BOW));
// Weapon-based attributes
_weaponAttributes = new WeightSet<Class<? extends ItemAttribute>>(FrostedAttribute.class, SharpAttribute.class,
@ -370,10 +370,8 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
ItemMeta newMeta = newCopy.getItemMeta();
newMeta.setLore(lore);
newCopy.setItemMeta(newMeta);
//slotPacket.c = newItem;
slotPacket.c = newItem;
//CraftItemStack.setItemMeta(slotPacket.c, meta);
System.out.println("Successfully intercepted item packet! " + CraftItemStack.getItemMeta(original).getLore().size() + " -- " + CraftItemStack.getItemMeta(newItem).getLore().size());
// TODO: Modify spigot build so that slotPacket's itemstack lore can be modified
// to 'hide' json-encoded lore from players.
}

View File

@ -33,6 +33,11 @@ public abstract class ReductionAttribute extends ItemAttribute
double damage = event.GetDamage();
double reduction = getDamageReduction(damage);
event.AddMod("Reduction Armor", reduction);
System.out.println("Reduced damage by " + reduction);
}
else
{
System.out.println("Armour doesn't reduce " + cause);
}
}

View File

@ -41,6 +41,6 @@ public class ReductionConfig
public boolean reducesDamage(DamageCause cause, Entity attacker)
{
return _reducedCauses.contains(cause) || _reducedAttackers.contains(attacker.getType());
return _reducedCauses.contains(cause) || (attacker != null && _reducedAttackers.contains(attacker.getType()));
}
}

View File

@ -1,6 +1,7 @@
package mineplex.game.clans.items.attributes.weapon;
import mineplex.game.clans.items.attributes.ItemAttribute;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import org.bukkit.entity.Entity;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -25,14 +26,15 @@ public abstract class AttackAttribute extends ItemAttribute
_attackCount = 0;
}
public void onAttack(EntityDamageByEntityEvent event)
@Override
public void onAttack(CustomDamageEvent event)
{
_attackCount++;
System.out.println("Attack count " + _attackCount + " - " + _attackLimit);
if (_attackCount >= _attackLimit)
{
_attackCount = 0;
triggerAttack(event.getDamager(), event.getEntity());
triggerAttack(event.GetDamagerEntity(true), event.GetDamageeEntity());
}
}

View File

@ -26,6 +26,7 @@ public class PvpShopButton<PageType extends ShopPageBase<ClansManager, ?>> imple
Item = item;
}
@Override
public void onClick(final Player player, ClickType clickType)
{

View File

@ -50,11 +50,11 @@ public class Spawn extends MiniPlugin
{
if (isInSpawn(event.getBlock().getLocation()))
{
event.setCancelled(true);
}
else if (isInSpawn(event.getPlayer()))
{
event.setCancelled(true);
}
}

View File

@ -32,6 +32,7 @@ import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
/**
* Adapts values whose runtime type may differ from their declaration type. This
* is necessary when a field's type is not the same type that GSON should create