How to use checkGreaterThanEqualTo0 method of be.seeseemelk.mockbukkit.statistic.StatisticsMock class

Best MockBukkit code snippet using be.seeseemelk.mockbukkit.statistic.StatisticsMock.checkGreaterThanEqualTo0

Source:StatisticsMock.java Github

copy

Full Screen

...19 * Implementation of {@link org.bukkit.OfflinePlayer#setStatistic(Statistic, int)}20 */21 public void setStatistic(@NotNull Statistic statistic, int amount)22 {23 checkGreaterThanEqualTo0(amount);24 Preconditions.checkArgument(statistic.getType() == Type.UNTYPED, "statistic must be provided with parameter");25 untypedStatistics.put(statistic, amount);26 }27 /**28 * Implementation of {@link org.bukkit.OfflinePlayer#setStatistic(Statistic, Material, int)}29 */30 public void setStatistic(@NotNull Statistic statistic, @NotNull Material material, int amount)31 {32 checkGreaterThanEqualTo0(amount);33 Preconditions.checkArgument(statistic.getType() == Type.ITEM || statistic.getType() == Type.BLOCK, "statistic must take a material parameter");34 materialStatistics.computeIfAbsent(statistic, k -> new EnumMap<>(Material.class)).put(material, amount);35 }36 /**37 * Implementation of {@link org.bukkit.OfflinePlayer#setStatistic(Statistic, EntityType, int)}38 */39 public void setStatistic(@NotNull Statistic statistic, @NotNull EntityType entity, int amount)40 {41 checkGreaterThanEqualTo0(amount);42 Preconditions.checkArgument(statistic.getType() == Type.ENTITY, "statistic must take an entity parameter");43 entityStatistics.computeIfAbsent(statistic, k -> new EnumMap<>(EntityType.class)).put(entity, amount);44 }45 /**46 * Implementation of {@link org.bukkit.OfflinePlayer#incrementStatistic(Statistic, int)}47 */48 public void incrementStatistic(@NotNull Statistic statistic, int amount)49 {50 checkGreaterThan0(amount);51 setStatistic(statistic, getStatistic(statistic) + amount);52 }53 /**54 * Implementation of {@link org.bukkit.OfflinePlayer#incrementStatistic(Statistic, Material, int)}55 */56 public void incrementStatistic(@NotNull Statistic statistic, @NotNull Material material, int amount)57 {58 checkGreaterThan0(amount);59 setStatistic(statistic, material, getStatistic(statistic, material) + amount);60 }61 /**62 * Implementation of {@link org.bukkit.OfflinePlayer#incrementStatistic(Statistic, EntityType, int)}63 */64 public void incrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entity, int amount)65 {66 checkGreaterThan0(amount);67 setStatistic(statistic, entity, getStatistic(statistic, entity) + amount);68 }69 /**70 * Implementation of {@link org.bukkit.OfflinePlayer#decrementStatistic(Statistic, int)}71 */72 public void decrementStatistic(@NotNull Statistic statistic, int amount)73 {74 checkGreaterThan0(amount);75 setStatistic(statistic, getStatistic(statistic) - amount);76 }77 /**78 * Implementation of {@link org.bukkit.OfflinePlayer#decrementStatistic(Statistic, Material, int)}79 */80 public void decrementStatistic(@NotNull Statistic statistic, @NotNull Material material, int amount)81 {82 checkGreaterThan0(amount);83 setStatistic(statistic, material, getStatistic(statistic, material) - amount);84 }85 /**86 * Implementation of {@link org.bukkit.OfflinePlayer#decrementStatistic(Statistic, EntityType, int)}87 */88 public void decrementStatistic(@NotNull Statistic statistic, @NotNull EntityType entity, int amount)89 {90 checkGreaterThan0(amount);91 setStatistic(statistic, entity, getStatistic(statistic, entity) - amount);92 }93 /**94 * Implementation of {@link org.bukkit.OfflinePlayer#getStatistic(Statistic)}95 */96 public int getStatistic(@NotNull Statistic statistic)97 {98 Preconditions.checkArgument(statistic.getType() == Type.UNTYPED, "statistic must be provided with parameter");99 return untypedStatistics.getOrDefault(statistic, 0);100 }101 /**102 * Implementation of {@link org.bukkit.OfflinePlayer#getStatistic(Statistic, Material)}103 */104 public int getStatistic(@NotNull Statistic statistic, @NotNull Material material)105 {106 Preconditions.checkArgument(statistic.getType() == Type.ITEM || statistic.getType() == Type.BLOCK, "statistic must take a material parameter");107 Map<Material, Integer> map = materialStatistics.get(statistic);108 if (map == null)109 {110 return 0;111 }112 return map.getOrDefault(material, 0);113 }114 /**115 * Implementation of {@link org.bukkit.OfflinePlayer#getStatistic(Statistic, EntityType)}116 */117 public int getStatistic(@NotNull Statistic statistic, @NotNull EntityType entity)118 {119 Preconditions.checkArgument(statistic.getType() == Type.ENTITY, "statistic must take an entity parameter");120 Map<EntityType, Integer> map = entityStatistics.get(statistic);121 if (map == null)122 {123 return 0;124 }125 return map.getOrDefault(entity, 0);126 }127 /**128 * Ensures that the provided amount is greater than129 *130 * @param amount the amount to check131 */132 private static void checkGreaterThan0(int amount)133 {134 Preconditions.checkArgument(amount > 0, "amount must be greater than 0");135 }136 /**137 * Ensures that the provided amount is greater than or equal to 0138 *139 * @param amount the amount to check140 */141 private static void checkGreaterThanEqualTo0(int amount)142 {143 Preconditions.checkArgument(amount >= 0, "amount must be greater than or equal to 0");144 }145}...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run MockBukkit automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful