!Format fixes

This commit is contained in:
HexedHero 2021-03-20 06:53:34 +00:00
parent f3a40b926e
commit ae175089df
13 changed files with 54 additions and 54 deletions

View File

@ -40,22 +40,20 @@ public class ArrowParticles extends BukkitRunnable {
return; return;
} }
// TODO Allow Note to be colored and allow BLOCK_DUST/ITEM_DUST to pick a block/item. // TODO Allow Note to be colored and allow BLOCK_DUST/ITEM_DUST to pick a block/item.
if (color != null) { if (color != null) {
if (particle == Particle.REDSTONE) { if (particle == Particle.REDSTONE) {
arrow.getWorld().spawnParticle(particle, arrow.getLocation().add(0, .25, 0), amount, offset, offset, offset, new Particle.DustOptions(color, 1)); arrow.getWorld().spawnParticle(particle, arrow.getLocation().add(0, .25, 0), amount, offset, offset, offset, new Particle.DustOptions(color, 1));
} } else if (particle == Particle.SPELL_MOB || particle == Particle.SPELL_MOB_AMBIENT) {
else if (particle == Particle.SPELL_MOB || particle == Particle.SPELL_MOB_AMBIENT) { // 0 for amount to allow colors (Thats why there is a for loop). Then the offsets are RGB values from 0.0 - 1.0, last 1 is the brightness.
// 0 for amount to allow colors (Thats why there is a for loop). Then the offsets are RGB values from 0.0 - 1.0, last 1 is the brightness. for (int i = 0; i < amount; i++) {
for (int i = 0; i < amount; i++) { arrow.getWorld().spawnParticle(particle, arrow.getLocation().add(0, .25, 0), 0, (float) color.getRed() / 255, (float) color.getGreen() / 255, (float) color.getBlue() / 255, 1);
arrow.getWorld().spawnParticle(particle, arrow.getLocation().add(0, .25, 0), 0, (float) color.getRed() / 255, (float) color.getGreen() / 255, (float) color.getBlue() / 255, 1); }
} }
} // else if (particle == Particle.NOTE) { Do Fancy Color Stuff Good Luck }
// else if (particle == Particle.NOTE) { Do Fancy Color Stuff Good Luck } // The above code semi-worked for note particles but I think there is a limited amount of colors so its harder and prob have to get the nearest one.
// The above code semi-worked for note particles but I think there is a limited amount of colors so its harder and prob have to get the nearest one. } else {
} arrow.getWorld().spawnParticle(particle, arrow.getLocation().add(0, .25, 0), amount, offset, offset, offset, speed);
else { }
arrow.getWorld().spawnParticle(particle, arrow.getLocation().add(0, .25, 0), amount, offset, offset, offset, speed);
}
} }
} }

View File

@ -30,8 +30,8 @@ public class ItemTier {
private final double chance; private final double chance;
private final NumericStatFormula capacity; private final NumericStatFormula capacity;
private static final Random random = new Random(); private static final Random RANDOM = new Random();
private static final boolean glow = Bukkit.getPluginManager().getPlugin("GlowAPI") != null; private static final boolean GLOW = Bukkit.getPluginManager().getPlugin("GlowAPI") != null;
public ItemTier(ConfigurationSection config) { public ItemTier(ConfigurationSection config) {
id = config.getName().toUpperCase().replace("-", "_"); id = config.getName().toUpperCase().replace("-", "_");
@ -41,7 +41,7 @@ public class ItemTier {
try { try {
hint = config.contains("item-glow") && config.getBoolean("item-glow.hint"); hint = config.contains("item-glow") && config.getBoolean("item-glow.hint");
color = config.contains("item-glow") ? new TierColor(config.getString("item-glow.color"), glow) : null; color = config.contains("item-glow") ? new TierColor(config.getString("item-glow.color"), GLOW) : null;
} catch (NoClassDefFoundError | IllegalAccessException | NoSuchFieldException | SecurityException exception) { } catch (NoClassDefFoundError | IllegalAccessException | NoSuchFieldException | SecurityException exception) {
throw new IllegalArgumentException("Could not load tier color: " + exception.getMessage()); throw new IllegalArgumentException("Could not load tier color: " + exception.getMessage());
} }
@ -138,7 +138,7 @@ public class ItemTier {
} }
public int[] calculateRange(int level) { public int[] calculateRange(int level) {
int min = (int) Math.max(1, (level - (double) range * random.nextDouble())); int min = (int) Math.max(1, (level - (double) range * RANDOM.nextDouble()));
return new int[] { min, min + range }; return new int[] { min, min + range };
} }
} }

View File

@ -29,7 +29,7 @@ public class SoulboundInfo {
/** /**
* Used to store which items must be given back to which player * Used to store which items must be given back to which player
*/ */
private static final Map<UUID, SoulboundInfo> info = new HashMap<>(); private static final Map<UUID, SoulboundInfo> INFO = new HashMap<>();
/** /**
* Instanced when a player dies if some souljbound items must be kept in the * Instanced when a player dies if some souljbound items must be kept in the
@ -53,7 +53,7 @@ public class SoulboundInfo {
} }
public void setup() { public void setup() {
info.put(player.getUniqueId(), this); INFO.put(player.getUniqueId(), this);
} }
public void giveItems() { public void giveItems() {
@ -67,9 +67,9 @@ public class SoulboundInfo {
} }
public static void read(Player player) { public static void read(Player player) {
if (info.containsKey(player.getUniqueId())) { if (INFO.containsKey(player.getUniqueId())) {
info.get(player.getUniqueId()).giveItems(); INFO.get(player.getUniqueId()).giveItems();
info.remove(player.getUniqueId()); INFO.remove(player.getUniqueId());
} }
} }
@ -78,6 +78,6 @@ public class SoulboundInfo {
* and yet have items cached in server RAM * and yet have items cached in server RAM
*/ */
public static Collection<SoulboundInfo> getAbandonnedInfo() { public static Collection<SoulboundInfo> getAbandonnedInfo() {
return info.values(); return INFO.values();
} }
} }

View File

@ -28,8 +28,10 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class UpgradeTemplate { public class UpgradeTemplate {
@NotNull private final String id; @NotNull
@NotNull private final Map<ItemStat, UpgradeInfo> perStatUpgradeInfos = new HashMap<>(); private final String id;
@NotNull
private final Map<ItemStat, UpgradeInfo> perStatUpgradeInfos = new HashMap<>();
/** /**
* Loads an Upgrade Template directly from the YML file. Neat! * Loads an Upgrade Template directly from the YML file. Neat!

View File

@ -58,7 +58,7 @@ public class GemStone extends UseItem {
// check for success rate // check for success rate
double successRate = getNBTItem().getStat(ItemStats.SUCCESS_RATE.getId()); double successRate = getNBTItem().getStat(ItemStats.SUCCESS_RATE.getId());
if (successRate != 0 && random.nextDouble() > successRate / 100) { if (successRate != 0 && RANDOM.nextDouble() > successRate / 100) {
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1); player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1);
Message.GEM_STONE_BROKE Message.GEM_STONE_BROKE
.format(ChatColor.RED, "#gem#", MMOUtils.getDisplayName(getItem()), "#item#", MMOUtils.getDisplayName(target.getItem())) .format(ChatColor.RED, "#gem#", MMOUtils.getDisplayName(getItem()), "#item#", MMOUtils.getDisplayName(target.getItem()))

View File

@ -72,7 +72,7 @@ public class ItemSkin extends UseItem {
// check for success rate // check for success rate
double successRate = getNBTItem().getStat(ItemStats.SUCCESS_RATE.getId()); double successRate = getNBTItem().getStat(ItemStats.SUCCESS_RATE.getId());
if (successRate != 0) if (successRate != 0)
if (random.nextDouble() < 1 - successRate / 100) { if (RANDOM.nextDouble() < 1 - successRate / 100) {
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1); player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1);
Message.SKIN_BROKE.format(ChatColor.RED, "#item#", MMOUtils.getDisplayName(target.getItem())) Message.SKIN_BROKE.format(ChatColor.RED, "#item#", MMOUtils.getDisplayName(target.getItem()))
.send(player); .send(player);

View File

@ -28,7 +28,7 @@ public class UseItem {
protected final PlayerData playerData; protected final PlayerData playerData;
protected final VolatileMMOItem mmoitem; protected final VolatileMMOItem mmoitem;
protected static final Random random = new Random(); protected static final Random RANDOM = new Random();
public UseItem(Player player, NBTItem nbtItem) { public UseItem(Player player, NBTItem nbtItem) {
this(PlayerData.get(player), nbtItem); this(PlayerData.get(player), nbtItem);

View File

@ -54,8 +54,8 @@ public class Musket extends UntargetedWeapon {
double a = Math.toRadians(getPlayer().getEyeLocation().getYaw() + 160); double a = Math.toRadians(getPlayer().getEyeLocation().getYaw() + 160);
Location loc = getPlayer().getEyeLocation().add(new Vector(Math.cos(a), 0, Math.sin(a)).multiply(.5)); Location loc = getPlayer().getEyeLocation().add(new Vector(Math.cos(a), 0, Math.sin(a)).multiply(.5));
loc.setPitch((float) (loc.getPitch() + (random.nextDouble() - .5) * 2 * recoil)); loc.setPitch((float) (loc.getPitch() + (RANDOM.nextDouble() - .5) * 2 * recoil));
loc.setYaw((float) (loc.getYaw() + (random.nextDouble() - .5) * 2 * recoil)); loc.setYaw((float) (loc.getYaw() + (RANDOM.nextDouble() - .5) * 2 * recoil));
Vector vec = loc.getDirection(); Vector vec = loc.getDirection();
MMORayTraceResult trace = MythicLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), vec, range, MMORayTraceResult trace = MythicLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), vec, range,

View File

@ -14,8 +14,8 @@ import net.Indyuce.mmoitems.stat.data.type.StatData;
public class NumericStatFormula implements RandomStatData { public class NumericStatFormula implements RandomStatData {
private final double base, scale, spread, maxSpread; private final double base, scale, spread, maxSpread;
private static final Random random = new Random(); private static final Random RANDOM = new Random();
private static final DecimalFormat digit = new DecimalFormat("0.####"); private static final DecimalFormat DIGIT = new DecimalFormat("0.####");
public static final NumericStatFormula ZERO = new NumericStatFormula(0, 0, 0, 0); public static final NumericStatFormula ZERO = new NumericStatFormula(0, 0, 0, 0);
@ -113,7 +113,7 @@ public class NumericStatFormula implements RandomStatData {
* maximum offset of {maxSpread}% (relative to average value) * maximum offset of {maxSpread}% (relative to average value)
*/ */
public double calculate(double x) { public double calculate(double x) {
return (base + scale * x) * (1 + Math.min(Math.max(random.nextGaussian() * spread, -maxSpread), maxSpread)); return (base + scale * x) * (1 + Math.min(Math.max(RANDOM.nextGaussian() * spread, -maxSpread), maxSpread));
} }
@Override @Override
@ -151,13 +151,13 @@ public class NumericStatFormula implements RandomStatData {
public String toString() { public String toString() {
if (scale == 0 && spread == 0) if (scale == 0 && spread == 0)
return digit.format(base); return DIGIT.format(base);
if (scale == 0) if (scale == 0)
return "[" + digit.format(base * (1 - maxSpread)) + " -> " + digit.format(base * (1 + maxSpread)) + "] (" + digit.format(spread * 100) return "[" + DIGIT.format(base * (1 - maxSpread)) + " -> " + DIGIT.format(base * (1 + maxSpread)) + "] (" + DIGIT.format(spread * 100)
+ "% Spread) (" + digit.format(base) + " Avg)"; + "% Spread) (" + DIGIT.format(base) + " Avg)";
return "{Base=" + digit.format(base) + (scale != 0 ? ",Scale=" + digit.format(scale) : "") + (spread != 0 ? ",Spread=" + spread : "") return "{Base=" + DIGIT.format(base) + (scale != 0 ? ",Scale=" + DIGIT.format(scale) : "") + (spread != 0 ? ",Spread=" + spread : "")
+ (maxSpread != 0 ? ",Max=" + maxSpread : "") + "}"; + (maxSpread != 0 ? ",Max=" + maxSpread : "") + "}";
} }

View File

@ -5,7 +5,7 @@ import java.util.Random;
public class RandomAmount { public class RandomAmount {
private final int min, max; private final int min, max;
private static final Random random = new Random(); private static final Random RANDOM = new Random();
public RandomAmount(int min, int max) { public RandomAmount(int min, int max) {
this.min = min; this.min = min;
@ -33,6 +33,6 @@ public class RandomAmount {
} }
public int getRandomAmount() { public int getRandomAmount() {
return max > 0 ? min + random.nextInt(max - min + 1) : min; return max > 0 ? min + RANDOM.nextInt(max - min + 1) : min;
} }
} }

View File

@ -27,7 +27,7 @@ import java.util.logging.Level;
public class CustomBlockListener implements Listener { public class CustomBlockListener implements Listener {
private static final Random random = new Random(); private static final Random RANDOM = new Random();
public CustomBlockListener() { public CustomBlockListener() {
if (MMOItems.plugin.getLanguage().replaceMushroomDrops) if (MMOItems.plugin.getLanguage().replaceMushroomDrops)
@ -53,7 +53,7 @@ public class CustomBlockListener implements Listener {
event.setExpToDrop(event.getPlayer().getGameMode() == GameMode.CREATIVE ? 0 event.setExpToDrop(event.getPlayer().getGameMode() == GameMode.CREATIVE ? 0
: CustomBlockListener.getPickaxePower(event.getPlayer()) >= block.getRequiredPower() : CustomBlockListener.getPickaxePower(event.getPlayer()) >= block.getRequiredPower()
? block.getMaxExpDrop() == 0 && block.getMinExpDrop() == 0 ? 0 ? block.getMaxExpDrop() == 0 && block.getMinExpDrop() == 0 ? 0
: random.nextInt((block.getMaxExpDrop() - block.getMinExpDrop()) + 1) + block.getMinExpDrop() : RANDOM.nextInt((block.getMaxExpDrop() - block.getMinExpDrop()) + 1) + block.getMinExpDrop()
: 0); : 0);
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)

View File

@ -11,28 +11,28 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
public class ElementListener implements Listener { public class ElementListener implements Listener {
private static final Map<Integer, Long> waterWeakness = new HashMap<>(); private static final Map<Integer, Long> WATER_WEAKNESS = new HashMap<>();
private static final long waterWeaknessDuration = 1000 * 6; private static final long WATER_WEAKNESS_DURATION = 1000 * 6;
private static final double waterWeaknessDamageIncrease = 0.3; private static final double WATER_WEAKNESS_DAMAGE_INCREASE = 0.3;
public static void weaken(Entity entity) { public static void weaken(Entity entity) {
waterWeakness.put(entity.getEntityId(), System.currentTimeMillis()); WATER_WEAKNESS.put(entity.getEntityId(), System.currentTimeMillis());
} }
boolean isWeakened(Entity entity) { boolean isWeakened(Entity entity) {
return waterWeakness.containsKey(entity.getEntityId()) && waterWeakness.get(entity.getEntityId()) + waterWeaknessDuration > System.currentTimeMillis(); return WATER_WEAKNESS.containsKey(entity.getEntityId()) && WATER_WEAKNESS.get(entity.getEntityId()) + WATER_WEAKNESS_DURATION > System.currentTimeMillis();
} }
void flush() { void flush() {
waterWeakness.entrySet().removeIf(integerLongEntry -> integerLongEntry.getValue() + waterWeaknessDuration < System.currentTimeMillis()); WATER_WEAKNESS.entrySet().removeIf(integerLongEntry -> integerLongEntry.getValue() + WATER_WEAKNESS_DURATION < System.currentTimeMillis());
} }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void a(EntityDamageByEntityEvent event) { public void a(EntityDamageByEntityEvent event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
if (isWeakened(entity)) { if (isWeakened(entity)) {
event.setDamage(event.getDamage() * (1 + waterWeaknessDamageIncrease)); event.setDamage(event.getDamage() * (1 + WATER_WEAKNESS_DAMAGE_INCREASE));
entity.getWorld().spawnParticle(Particle.WATER_SPLASH, event.getEntity().getLocation().add(0, entity.getHeight() / 2, 0), 16, .3, .3, .3, 0); entity.getWorld().spawnParticle(Particle.WATER_SPLASH, event.getEntity().getLocation().add(0, entity.getHeight() / 2, 0), 16, .3, .3, .3, 0);
} }
} }

View File

@ -48,7 +48,7 @@ import org.jetbrains.annotations.NotNull;
import java.text.DecimalFormat; import java.text.DecimalFormat;
public class ItemUse implements Listener { public class ItemUse implements Listener {
private static final DecimalFormat digit = new DecimalFormat("0.#"); private static final DecimalFormat DIGIT = new DecimalFormat("0.#");
@EventHandler @EventHandler
public void a(PlayerInteractEvent event) { public void a(PlayerInteractEvent event) {
@ -82,7 +82,7 @@ public class ItemUse implements Listener {
if (event.getAction().name().contains("RIGHT_CLICK")) { if (event.getAction().name().contains("RIGHT_CLICK")) {
if (!useItem.getPlayerData().canUseItem(useItem.getMMOItem().getId())) { if (!useItem.getPlayerData().canUseItem(useItem.getMMOItem().getId())) {
Message.ITEM_ON_COOLDOWN Message.ITEM_ON_COOLDOWN
.format(ChatColor.RED, "#left#", digit.format(useItem.getPlayerData().getItemCooldown(useItem.getMMOItem().getId()))) .format(ChatColor.RED, "#left#", DIGIT.format(useItem.getPlayerData().getItemCooldown(useItem.getMMOItem().getId())))
.send(player, "item-cooldown"); .send(player, "item-cooldown");
event.setCancelled(true); event.setCancelled(true);
return; return;