max amount of buyable claimblocks
This commit is contained in:
parent
b5b6ea3381
commit
75e47c6f0e
@ -17,6 +17,10 @@ Flan 1.7.0
|
|||||||
- Rewritten buy/sell system.
|
- Rewritten buy/sell system.
|
||||||
Its now possible to specify money, items or xp points as a "currency" value
|
Its now possible to specify money, items or xp points as a "currency" value
|
||||||
For more info see the https://github.com/Flemmli97/Flan/wiki/Config#buysell-handler
|
For more info see the https://github.com/Flemmli97/Flan/wiki/Config#buysell-handler
|
||||||
|
- maxBuyBlocks config:
|
||||||
|
Specify the max amount of claim blocks a player can buy.
|
||||||
|
giveClaimBlocks command bypasses this still
|
||||||
|
-1 = no limit
|
||||||
|
|
||||||
Flan 1.6.9
|
Flan 1.6.9
|
||||||
======================
|
======================
|
||||||
|
@ -37,6 +37,11 @@ public class BuySellHandler {
|
|||||||
message.accept(PermHelper.simpleColoredText(ConfigHandler.langManager.get("buyDisabled"), ChatFormatting.DARK_RED));
|
message.accept(PermHelper.simpleColoredText(ConfigHandler.langManager.get("buyDisabled"), ChatFormatting.DARK_RED));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
PlayerClaimData data = PlayerClaimData.get(player);
|
||||||
|
if(ConfigHandler.config.maxBuyBlocks >= 0 && data.getAdditionalClaims() + blocks > ConfigHandler.config.maxBuyBlocks) {
|
||||||
|
message.accept(PermHelper.simpleColoredText(ConfigHandler.langManager.get("buyLimit"), ChatFormatting.DARK_RED));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
switch (this.buyType) {
|
switch (this.buyType) {
|
||||||
case MONEY -> {
|
case MONEY -> {
|
||||||
return CommandCurrency.buyClaimBlocks(player, blocks, this.buyAmount, message);
|
return CommandCurrency.buyClaimBlocks(player, blocks, this.buyAmount, message);
|
||||||
@ -75,7 +80,6 @@ public class BuySellHandler {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlayerClaimData data = PlayerClaimData.get(player);
|
|
||||||
data.setAdditionalClaims(data.getAdditionalClaims() + blocks);
|
data.setAdditionalClaims(data.getAdditionalClaims() + blocks);
|
||||||
message.accept(PermHelper.simpleColoredText(String.format(ConfigHandler.langManager.get("buySuccessItem"), blocks, deduct)));
|
message.accept(PermHelper.simpleColoredText(String.format(ConfigHandler.langManager.get("buySuccessItem"), blocks, deduct)));
|
||||||
return true;
|
return true;
|
||||||
@ -84,7 +88,6 @@ public class BuySellHandler {
|
|||||||
int deduct = Mth.ceil(blocks * this.buyAmount);
|
int deduct = Mth.ceil(blocks * this.buyAmount);
|
||||||
if (deduct < totalXpPointsForLevel(player.experienceLevel) + player.experienceProgress * xpForLevel(player.experienceLevel + 1)) {
|
if (deduct < totalXpPointsForLevel(player.experienceLevel) + player.experienceProgress * xpForLevel(player.experienceLevel + 1)) {
|
||||||
player.giveExperiencePoints(-deduct);
|
player.giveExperiencePoints(-deduct);
|
||||||
PlayerClaimData data = PlayerClaimData.get(player);
|
|
||||||
data.setAdditionalClaims(data.getAdditionalClaims() + blocks);
|
data.setAdditionalClaims(data.getAdditionalClaims() + blocks);
|
||||||
message.accept(PermHelper.simpleColoredText(String.format(ConfigHandler.langManager.get("buySuccessXP"), blocks, deduct)));
|
message.accept(PermHelper.simpleColoredText(String.format(ConfigHandler.langManager.get("buySuccessXP"), blocks, deduct)));
|
||||||
return true;
|
return true;
|
||||||
@ -114,8 +117,8 @@ public class BuySellHandler {
|
|||||||
if (this.ingredient.getItems().length == 0) {
|
if (this.ingredient.getItems().length == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ItemStack stack = this.ingredient.getItems()[0];
|
|
||||||
int amount = Mth.floor(blocks * this.sellAmount);
|
int amount = Mth.floor(blocks * this.sellAmount);
|
||||||
|
ItemStack stack = this.ingredient.getItems()[0];
|
||||||
while (amount > 0) {
|
while (amount > 0) {
|
||||||
ItemStack toGive = stack.copy();
|
ItemStack toGive = stack.copy();
|
||||||
if (amount > 64) {
|
if (amount > 64) {
|
||||||
|
@ -48,6 +48,7 @@ public class Config {
|
|||||||
public int permissionLevel = 2;
|
public int permissionLevel = 2;
|
||||||
|
|
||||||
public BuySellHandler buySellHandler = new BuySellHandler();
|
public BuySellHandler buySellHandler = new BuySellHandler();
|
||||||
|
public int maxBuyBlocks = -1;
|
||||||
|
|
||||||
public boolean lenientBlockEntityCheck;
|
public boolean lenientBlockEntityCheck;
|
||||||
public List<String> breakBlockBlacklist = Lists.newArrayList(
|
public List<String> breakBlockBlacklist = Lists.newArrayList(
|
||||||
@ -167,6 +168,7 @@ public class Config {
|
|||||||
this.permissionLevel = ConfigHandler.fromJson(obj, "permissionLevel", this.permissionLevel);
|
this.permissionLevel = ConfigHandler.fromJson(obj, "permissionLevel", this.permissionLevel);
|
||||||
|
|
||||||
this.buySellHandler.fromJson(ConfigHandler.fromJson(obj, "buySellHandler"));
|
this.buySellHandler.fromJson(ConfigHandler.fromJson(obj, "buySellHandler"));
|
||||||
|
this.maxBuyBlocks = ConfigHandler.fromJson(obj, "maxBuyBlocks", this.maxBuyBlocks);
|
||||||
|
|
||||||
this.lenientBlockEntityCheck = ConfigHandler.fromJson(obj, "lenientBlockEntityCheck", this.lenientBlockEntityCheck);
|
this.lenientBlockEntityCheck = ConfigHandler.fromJson(obj, "lenientBlockEntityCheck", this.lenientBlockEntityCheck);
|
||||||
this.breakBlockBlacklist.clear();
|
this.breakBlockBlacklist.clear();
|
||||||
@ -261,6 +263,7 @@ public class Config {
|
|||||||
obj.addProperty("permissionLevel", this.permissionLevel);
|
obj.addProperty("permissionLevel", this.permissionLevel);
|
||||||
|
|
||||||
obj.add("buySellHandler", this.buySellHandler.toJson());
|
obj.add("buySellHandler", this.buySellHandler.toJson());
|
||||||
|
obj.addProperty("maxBuyBlocks", this.maxBuyBlocks);
|
||||||
|
|
||||||
obj.addProperty("lenientBlockEntityCheck", this.lenientBlockEntityCheck);
|
obj.addProperty("lenientBlockEntityCheck", this.lenientBlockEntityCheck);
|
||||||
JsonArray blocksBreak = new JsonArray();
|
JsonArray blocksBreak = new JsonArray();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user