Skip to content

Commit

Permalink
Added snowball limit
Browse files Browse the repository at this point in the history
  • Loading branch information
itzCrih committed Dec 21, 2024
1 parent f0b51e6 commit 400dac0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>it.itzcrih</groupId>
<artifactId>CoralWinter</artifactId>
<version>1.8-SNAPSHOT-DEV3</version>
<version>1.8-SNAPSHOT</version>
<packaging>jar</packaging>

<name>CoralWinter</name>
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/it/itzcrih/coralwinter/utils/SnowUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@ public static boolean canBreakSnowBlock(Player player, Block block) {
}

public static void giveSnowball(Player player) {
if (CoralWinter.getConfigLoader().getConfig().getBoolean("snowball.enable_limit")) {
int totalSnowballs = 0;
for (ItemStack item : player.getInventory().getContents()) {
if (item != null && item.getType() == Material.SNOW_BALL) {
totalSnowballs += item.getAmount();
}
}

double maxLimit = CoralWinter.getConfigLoader().getConfig().getDouble("snowball.max_limit");
if (totalSnowballs >= maxLimit) {
player.sendMessage(ChatUtils.colorize(CoralWinter.getConfigLoader().getMessages().getString("errors.maximum_amount")));
return;
}
}

player.playSound(player.getLocation(), Sound.DIG_SNOW, 1.0f, 1.0f);
player.playSound(player.getLocation(),
Sound.valueOf(CoralWinter.getConfigLoader().getConfig().getString("santashovel.sound_when_breaking")),
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ errors:
no_perm: "&cSorry, but you don't have permission to use this command."
command_disabled: "&cThis command has been disabled from the configuration!"
player_not_found: "&cPlayer '%target%' not found!"
maximum_amount: "&cYou have reached the maximum amount of snowballs!"

commands:
reloaded_successfully: "&7The &bconfigurations &7has been &breloaded &7successfully!"
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ snowball:
- "&7(Click &bRight-click &7to throw it)"
# Should we enchant the snowball for a glow effect?
enable_glow: true
# Should we enable limit for snowballs in player's inventory?
enable_limit: true
# How many snowballs should the player have as maximum amount?
max_limit: 16
# Whenever you get hit by a snowball knockback values
snowball_knockback:
enabled: true
Expand Down

0 comments on commit 400dac0

Please sign in to comment.