mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-02-03 11:31:21 +01:00
!Format fixes
This commit is contained in:
parent
f3a40b926e
commit
ae175089df
@ -40,22 +40,20 @@ public class ArrowParticles extends BukkitRunnable {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO Allow Note to be colored and allow BLOCK_DUST/ITEM_DUST to pick a block/item.
|
||||
if (color != null) {
|
||||
if (particle == Particle.REDSTONE) {
|
||||
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) {
|
||||
// 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++) {
|
||||
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 }
|
||||
// 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);
|
||||
}
|
||||
// TODO Allow Note to be colored and allow BLOCK_DUST/ITEM_DUST to pick a block/item.
|
||||
if (color != null) {
|
||||
if (particle == Particle.REDSTONE) {
|
||||
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) {
|
||||
// 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++) {
|
||||
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 }
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,8 +30,8 @@ public class ItemTier {
|
||||
private final double chance;
|
||||
private final NumericStatFormula capacity;
|
||||
|
||||
private static final Random random = new Random();
|
||||
private static final boolean glow = Bukkit.getPluginManager().getPlugin("GlowAPI") != null;
|
||||
private static final Random RANDOM = new Random();
|
||||
private static final boolean GLOW = Bukkit.getPluginManager().getPlugin("GlowAPI") != null;
|
||||
|
||||
public ItemTier(ConfigurationSection config) {
|
||||
id = config.getName().toUpperCase().replace("-", "_");
|
||||
@ -41,7 +41,7 @@ public class ItemTier {
|
||||
|
||||
try {
|
||||
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) {
|
||||
throw new IllegalArgumentException("Could not load tier color: " + exception.getMessage());
|
||||
}
|
||||
@ -138,7 +138,7 @@ public class ItemTier {
|
||||
}
|
||||
|
||||
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 };
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class SoulboundInfo {
|
||||
/**
|
||||
* 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
|
||||
@ -53,7 +53,7 @@ public class SoulboundInfo {
|
||||
}
|
||||
|
||||
public void setup() {
|
||||
info.put(player.getUniqueId(), this);
|
||||
INFO.put(player.getUniqueId(), this);
|
||||
}
|
||||
|
||||
public void giveItems() {
|
||||
@ -67,9 +67,9 @@ public class SoulboundInfo {
|
||||
}
|
||||
|
||||
public static void read(Player player) {
|
||||
if (info.containsKey(player.getUniqueId())) {
|
||||
info.get(player.getUniqueId()).giveItems();
|
||||
info.remove(player.getUniqueId());
|
||||
if (INFO.containsKey(player.getUniqueId())) {
|
||||
INFO.get(player.getUniqueId()).giveItems();
|
||||
INFO.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,6 +78,6 @@ public class SoulboundInfo {
|
||||
* and yet have items cached in server RAM
|
||||
*/
|
||||
public static Collection<SoulboundInfo> getAbandonnedInfo() {
|
||||
return info.values();
|
||||
return INFO.values();
|
||||
}
|
||||
}
|
||||
|
@ -28,8 +28,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class UpgradeTemplate {
|
||||
@NotNull private final String id;
|
||||
@NotNull private final Map<ItemStat, UpgradeInfo> perStatUpgradeInfos = new HashMap<>();
|
||||
@NotNull
|
||||
private final String id;
|
||||
@NotNull
|
||||
private final Map<ItemStat, UpgradeInfo> perStatUpgradeInfos = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Loads an Upgrade Template directly from the YML file. Neat!
|
||||
|
@ -58,7 +58,7 @@ public class GemStone extends UseItem {
|
||||
|
||||
// check for success rate
|
||||
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);
|
||||
Message.GEM_STONE_BROKE
|
||||
.format(ChatColor.RED, "#gem#", MMOUtils.getDisplayName(getItem()), "#item#", MMOUtils.getDisplayName(target.getItem()))
|
||||
|
@ -72,7 +72,7 @@ public class ItemSkin extends UseItem {
|
||||
// check for success rate
|
||||
double successRate = getNBTItem().getStat(ItemStats.SUCCESS_RATE.getId());
|
||||
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);
|
||||
Message.SKIN_BROKE.format(ChatColor.RED, "#item#", MMOUtils.getDisplayName(target.getItem()))
|
||||
.send(player);
|
||||
|
@ -28,7 +28,7 @@ public class UseItem {
|
||||
protected final PlayerData playerData;
|
||||
protected final VolatileMMOItem mmoitem;
|
||||
|
||||
protected static final Random random = new Random();
|
||||
protected static final Random RANDOM = new Random();
|
||||
|
||||
public UseItem(Player player, NBTItem nbtItem) {
|
||||
this(PlayerData.get(player), nbtItem);
|
||||
|
@ -54,8 +54,8 @@ public class Musket extends UntargetedWeapon {
|
||||
double a = Math.toRadians(getPlayer().getEyeLocation().getYaw() + 160);
|
||||
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.setYaw((float) (loc.getYaw() + (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));
|
||||
Vector vec = loc.getDirection();
|
||||
|
||||
MMORayTraceResult trace = MythicLib.plugin.getVersion().getWrapper().rayTrace(stats.getPlayer(), vec, range,
|
||||
|
@ -14,8 +14,8 @@ import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
public class NumericStatFormula implements RandomStatData {
|
||||
private final double base, scale, spread, maxSpread;
|
||||
|
||||
private static final Random random = new Random();
|
||||
private static final DecimalFormat digit = new DecimalFormat("0.####");
|
||||
private static final Random RANDOM = new Random();
|
||||
private static final DecimalFormat DIGIT = new DecimalFormat("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)
|
||||
*/
|
||||
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
|
||||
@ -151,13 +151,13 @@ public class NumericStatFormula implements RandomStatData {
|
||||
public String toString() {
|
||||
|
||||
if (scale == 0 && spread == 0)
|
||||
return digit.format(base);
|
||||
return DIGIT.format(base);
|
||||
|
||||
if (scale == 0)
|
||||
return "[" + digit.format(base * (1 - maxSpread)) + " -> " + digit.format(base * (1 + maxSpread)) + "] (" + digit.format(spread * 100)
|
||||
+ "% Spread) (" + digit.format(base) + " Avg)";
|
||||
return "[" + DIGIT.format(base * (1 - maxSpread)) + " -> " + DIGIT.format(base * (1 + maxSpread)) + "] (" + DIGIT.format(spread * 100)
|
||||
+ "% 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 : "") + "}";
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ import java.util.Random;
|
||||
public class RandomAmount {
|
||||
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) {
|
||||
this.min = min;
|
||||
@ -33,6 +33,6 @@ public class RandomAmount {
|
||||
}
|
||||
|
||||
public int getRandomAmount() {
|
||||
return max > 0 ? min + random.nextInt(max - min + 1) : min;
|
||||
return max > 0 ? min + RANDOM.nextInt(max - min + 1) : min;
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import java.util.logging.Level;
|
||||
|
||||
public class CustomBlockListener implements Listener {
|
||||
|
||||
private static final Random random = new Random();
|
||||
private static final Random RANDOM = new Random();
|
||||
|
||||
public CustomBlockListener() {
|
||||
if (MMOItems.plugin.getLanguage().replaceMushroomDrops)
|
||||
@ -53,7 +53,7 @@ public class CustomBlockListener implements Listener {
|
||||
event.setExpToDrop(event.getPlayer().getGameMode() == GameMode.CREATIVE ? 0
|
||||
: CustomBlockListener.getPickaxePower(event.getPlayer()) >= block.getRequiredPower()
|
||||
? 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);
|
||||
}
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
|
@ -11,28 +11,28 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
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 double waterWeaknessDamageIncrease = 0.3;
|
||||
private static final long WATER_WEAKNESS_DURATION = 1000 * 6;
|
||||
private static final double WATER_WEAKNESS_DAMAGE_INCREASE = 0.3;
|
||||
|
||||
public static void weaken(Entity entity) {
|
||||
waterWeakness.put(entity.getEntityId(), System.currentTimeMillis());
|
||||
WATER_WEAKNESS.put(entity.getEntityId(), System.currentTimeMillis());
|
||||
}
|
||||
|
||||
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() {
|
||||
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)
|
||||
public void a(EntityDamageByEntityEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class ItemUse implements Listener {
|
||||
private static final DecimalFormat digit = new DecimalFormat("0.#");
|
||||
private static final DecimalFormat DIGIT = new DecimalFormat("0.#");
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerInteractEvent event) {
|
||||
@ -82,7 +82,7 @@ public class ItemUse implements Listener {
|
||||
if (event.getAction().name().contains("RIGHT_CLICK")) {
|
||||
if (!useItem.getPlayerData().canUseItem(useItem.getMMOItem().getId())) {
|
||||
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");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user