Added delete benefit call for repository.

Added failsafe in case inventory update didn't apply
Removed 43k benefit.
This commit is contained in:
Jonathan Williams 2015-10-21 01:15:09 -05:00
parent 3ef33bd9c5
commit c719d693dd
4 changed files with 17 additions and 2 deletions

View File

@ -31,7 +31,7 @@ public class BenefitManager extends MiniDbClientPlugin<BenefitData>
//_benefits.add(new Christmas2014(plugin, _repository, inventoryManager));
//_benefits.add(new Thanksgiving2014(plugin, _repository, inventoryManager));
_benefits.add(new Players43k(this, _repository, inventoryManager));
//_benefits.add(new Players43k(this, _repository, inventoryManager));
}
@EventHandler(priority = EventPriority.LOWEST)

View File

@ -15,6 +15,7 @@ public class BenefitManagerRepository extends RepositoryBase
private static String CREATE_BENEFIT_TABLE = "CREATE TABLE IF NOT EXISTS rankBenefits (id INT NOT NULL AUTO_INCREMENT, accountId INT, benefit VARCHAR(100), PRIMARY KEY (id), FOREIGN KEY (accountId) REFERENCES accounts(id));";
private static String INSERT_BENEFIT = "INSERT INTO rankBenefits (accountId, benefit) VALUES (?, ?);";
private static String DELETE_BENEFIT = "DELETE FROM rankBenefits WHERE accountId = ? AND benefit = ?;";
public BenefitManagerRepository(JavaPlugin plugin)
{
@ -50,4 +51,9 @@ public class BenefitManagerRepository extends RepositoryBase
return playerBenefit;
}
public void removeBenefit(int accountId, String benefit)
{
executeUpdate(DELETE_BENEFIT, new ColumnInt("accountId", accountId), new ColumnVarChar("benefit", 100, benefit));
}
}

View File

@ -46,6 +46,11 @@ public abstract class BenefitBase
});
}
protected void removeBenefit(final Player player)
{
_repository.removeBenefit(_plugin.getClientManager().Get(player).getAccountId(), _name);
}
public String getName()
{
return _name;

View File

@ -39,6 +39,10 @@ public class Players43k extends BenefitBase
UtilPlayer.message(player, "");
UtilPlayer.message(player, C.cGold + C.Strike + "=============================================");
}
else
{
removeBenefit(player);
}
}
}, player, "Ancient Chest", 3);
}