Added delete benefit call for repository.
Added failsafe in case inventory update didn't apply Removed 43k benefit.
This commit is contained in:
parent
3ef33bd9c5
commit
c719d693dd
@ -31,7 +31,7 @@ public class BenefitManager extends MiniDbClientPlugin<BenefitData>
|
|||||||
|
|
||||||
//_benefits.add(new Christmas2014(plugin, _repository, inventoryManager));
|
//_benefits.add(new Christmas2014(plugin, _repository, inventoryManager));
|
||||||
//_benefits.add(new Thanksgiving2014(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)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
@ -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 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 INSERT_BENEFIT = "INSERT INTO rankBenefits (accountId, benefit) VALUES (?, ?);";
|
||||||
|
private static String DELETE_BENEFIT = "DELETE FROM rankBenefits WHERE accountId = ? AND benefit = ?;";
|
||||||
|
|
||||||
public BenefitManagerRepository(JavaPlugin plugin)
|
public BenefitManagerRepository(JavaPlugin plugin)
|
||||||
{
|
{
|
||||||
@ -50,4 +51,9 @@ public class BenefitManagerRepository extends RepositoryBase
|
|||||||
|
|
||||||
return playerBenefit;
|
return playerBenefit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeBenefit(int accountId, String benefit)
|
||||||
|
{
|
||||||
|
executeUpdate(DELETE_BENEFIT, new ColumnInt("accountId", accountId), new ColumnVarChar("benefit", 100, benefit));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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()
|
public String getName()
|
||||||
{
|
{
|
||||||
return _name;
|
return _name;
|
||||||
|
@ -39,6 +39,10 @@ public class Players43k extends BenefitBase
|
|||||||
UtilPlayer.message(player, "");
|
UtilPlayer.message(player, "");
|
||||||
UtilPlayer.message(player, C.cGold + C.Strike + "=============================================");
|
UtilPlayer.message(player, C.cGold + C.Strike + "=============================================");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
removeBenefit(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, player, "Ancient Chest", 3);
|
}, player, "Ancient Chest", 3);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user