Fixes to TnTGeneration

Fixes to Broadsword giving Generation and slowness 42 instead of 4
This commit is contained in:
phobia 2016-01-30 19:23:59 +11:00
parent fe01c9b8d5
commit aa0cfc7710
2 changed files with 50 additions and 31 deletions

View File

@ -4,6 +4,7 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
@ -167,42 +168,60 @@ public class TntGeneratorManager extends MiniPlugin
ClanInfo clan = getGenerator(event.getClickedBlock());
if (clan != null)
{
final TntGenerator generator = clan.getGenerator();
final int stock = generator.getStock();
interact(clan, event.getPlayer());
}else { //fix tnt gen issues
//Can only place one of these in a clan location. so it must be a generator
ClanInfo owner = _clansManager.getClanUtility().getOwner(event.getClickedBlock().getLocation());
if(owner == null) return; //Wilderness
TntGenerator generator = owner.getGenerator();
if (stock > 0)
{
generator.setStock(stock - 1);
_clansManager.getClanDataAccess().updateGenerator(clan, new Callback<Boolean>()
{
@Override
public void run(Boolean data)
{
if (data)
{
updateBrewingStand(generator);
dropItem(event.getClickedBlock(), new ItemStack(Material.TNT));
}
else
{
// failed
generator.setStock(stock);
}
}
});
}
else
{
int secondLeft = SECONDS_PER_TNT - generator.getTicks();
int msLeft = secondLeft * 1000;
UtilTextMiddle.display("", C.cRed + "Next TNT in " + C.cGold + UtilTime.convertString(msLeft, 1, UtilTime.TimeUnit.FIT), event.getPlayer());
}
//Create generator if not exist
if(generator == null || !generator.getBlock().equals(event.getClickedBlock())) {
generator = new TntGenerator(event.getClickedBlock());
generator.setStock(2);
clan.setGenerator(generator);
_clansManager.getClanDataAccess().updateGenerator(clan, null);
}
interact(owner, event.getPlayer());
}
event.setCancelled(true);
}
}
private void interact(ClanInfo clan, Player player) {
final TntGenerator generator = clan.getGenerator();
final int stock = generator.getStock();
if (stock > 0)
{
generator.setStock(stock - 1);
_clansManager.getClanDataAccess().updateGenerator(clan, new Callback<Boolean>()
{
@Override
public void run(Boolean data)
{
if (data)
{
updateBrewingStand(generator);
dropItem(generator.getBlock(), new ItemStack(Material.TNT));
}
else
{
// failed
generator.setStock(stock);
}
}
});
}
else
{
int secondLeft = SECONDS_PER_TNT - generator.getTicks();
int msLeft = secondLeft * 1000;
UtilTextMiddle.display("", C.cRed + "Next TNT in " + C.cGold + UtilTime.convertString(msLeft, 1, UtilTime.TimeUnit.FIT), player);
}
}
@EventHandler
public void onDelete(ClanDeleteEvent event)
{

View File

@ -62,7 +62,7 @@ public class GiantsBroadsword extends LegendaryItem
private void buffPlayer(Player player)
{
grantPotionEffect(player, PotionEffectType.SLOW, 40, 43);
grantPotionEffect(player, PotionEffectType.REGENERATION, 2, 43);
grantPotionEffect(player, PotionEffectType.SLOW, 40, 5);
grantPotionEffect(player, PotionEffectType.REGENERATION, 2, 5); //Regen 4
}
}