Skip to content

Commit

Permalink
Fixed Doubles Being Parsed with Commas, Removed Old Debug Message, Fi…
Browse files Browse the repository at this point in the history
…xed Incorrect EXP Parsing (0.2.2)
  • Loading branch information
Kihsomray committed Jan 2, 2022
1 parent 262dfd3 commit ce62857
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -6,7 +6,7 @@

<groupId>net.zerotoil.dev</groupId>
<artifactId>CyberLevels</artifactId>
<version>0.2.1</version>
<version>0.2.2</version>
<packaging>jar</packaging>

<name>CyberLevels</name>
Expand Down
Expand Up @@ -27,7 +27,7 @@ public EXPListeners(CyberLevels main) {
}

// Works 1.7.10 - latest
@EventHandler (priority = EventPriority.MONITOR)
@EventHandler (priority = EventPriority.HIGHEST)
private void onDamage(EntityDamageByEntityEvent event) {
if (event.isCancelled()) return;
if (!(event.getDamager() instanceof Player)) return;
Expand All @@ -45,7 +45,7 @@ private void onDamage(EntityDamageByEntityEvent event) {
}

// Works 1.7.10 - latest
@EventHandler (priority = EventPriority.MONITOR)
@EventHandler (priority = EventPriority.HIGHEST)
private void onMobDeath(EntityDeathEvent event) {
if (event.getEntity().getLastDamageCause() == null) return;
EntityDamageEvent damageEvent = event.getEntity().getLastDamageCause();
Expand All @@ -67,28 +67,28 @@ private void onMobDeath(EntityDeathEvent event) {
}

// Works 1.10.x - latest
/* @EventHandler (priority = EventPriority.MONITOR)
/* @EventHandler (priority = EventPriority.HIGHEST)
private void onBreeding(EntityBreedEvent event) {
if (event.isCancelled()) return;
} */

// Works 1.7.10 - latest
@EventHandler (priority = EventPriority.MONITOR)
@EventHandler (priority = EventPriority.HIGHEST)
private void onPlacing(BlockPlaceEvent event) {
if (event.isCancelled()) return;
sendExp(event.getPlayer(), main.expCache().expEarnEvents().get("placing"), event.getBlock().getType().toString());

}

// Works 1.7.10 - latest
@EventHandler (priority = EventPriority.MONITOR)
@EventHandler (priority = EventPriority.HIGHEST)
private void onBreaking(BlockBreakEvent event) {
if (event.isCancelled()) return;
sendExp(event.getPlayer(), main.expCache().expEarnEvents().get("breaking"), event.getBlock().getType().toString());
}

// Works 1.7.10 - latest
@EventHandler (priority = EventPriority.MONITOR)
@EventHandler (priority = EventPriority.HIGHEST)
private void onCrafting(CraftItemEvent event) {
if (event.isCancelled()) return;
if (!(event.getWhoClicked() instanceof Player)) return;
Expand All @@ -98,18 +98,17 @@ private void onCrafting(CraftItemEvent event) {
}

// Works 1.7.10 - latest
@EventHandler (priority = EventPriority.MONITOR)
@EventHandler (priority = EventPriority.HIGHEST)
private void onFishing(PlayerFishEvent event) {
if (event.isCancelled()) return;
if (event.getCaught() == null) return;

sendExp(event.getPlayer(), main.expCache().expEarnEvents().get("fishing"), ((Item) event.getCaught()).getItemStack().getType().toString());
event.getPlayer().sendMessage(((Item) event.getCaught()).getItemStack().getType().toString());

}

// Works 1.16.1 - latest
/* @EventHandler (priority = EventPriority.MONITOR)
/* @EventHandler (priority = EventPriority.HIGHEST)
private void onHarvesting(PlayerHarvestBlockEvent event) {
if (event.isCancelled()) return;
} */
Expand Down
Expand Up @@ -56,7 +56,7 @@ private void loadGeneral(ConfigurationSection config) {
double tempMax = Math.max(Double.parseDouble(string[0]), Double.parseDouble(string[1]));
minEXP = tempMin;
maxEXP = tempMax;
} else maxEXP = minEXP = config.getDouble("exp");
} else maxEXP = minEXP = Double.parseDouble(exp);

config = config.getConfigurationSection("includes");
if (config == null) return; // if no section with includes, just stop
Expand Down Expand Up @@ -102,8 +102,8 @@ private void loadSpecific(ConfigurationSection config) {
specificMin.put(s.toUpperCase(), tempMin);
specificMax.put(s.toUpperCase(), tempMax);
} else {
specificMin.put(s.toUpperCase(), config.getDouble(s));
specificMax.put(s.toUpperCase(), config.getDouble(s));
specificMin.put(s.toUpperCase(), Double.parseDouble(val));
specificMax.put(s.toUpperCase(), Double.parseDouble(val));
}
}

Expand Down
Expand Up @@ -63,12 +63,12 @@ public String levelFormula(long level) {

public double roundDecimal(double value) {
if (decimalFormat == null) return value;
return Double.parseDouble(decimalFormat.format(value));
return Double.parseDouble(decimalFormat.format(value).replace(",", "."));
}

public String roundStringDecimal(double value) {
if (decimalFormat == null) return value + "";
return decimalFormat.format(value);
return decimalFormat.format(value).replace(",", ".");
}

public String progressBar(Double exp, Double requiredExp) {
Expand Down

0 comments on commit ce62857

Please sign in to comment.