Skip to content

Commit

Permalink
TimePeriod, Sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
Sefiraat committed Nov 10, 2021
1 parent 4216f07 commit d9c9304
Show file tree
Hide file tree
Showing 43 changed files with 427 additions and 327 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<sonar.organization>sefiraat</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>

<sonar.issue.ignore.multicriteria>e1,e2</sonar.issue.ignore.multicriteria>
<sonar.issue.ignore.multicriteria>e1,e2,e3</sonar.issue.ignore.multicriteria>
<sonar.issue.ignore.multicriteria.e1.ruleKey>java:S6212</sonar.issue.ignore.multicriteria.e1.ruleKey>
<sonar.issue.ignore.multicriteria.e1.resourceKey>**</sonar.issue.ignore.multicriteria.e1.resourceKey>

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ protected void execute(CommandSender sender, String[] args) {
@Override
@ParametersAreNonnullByDefault
protected void complete(CommandSender commandSender, String[] strings, List<String> list) {

// Not required
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ protected void execute(CommandSender sender, String[] args) {
@Override
@ParametersAreNonnullByDefault
protected void complete(CommandSender commandSender, String[] strings, List<String> list) {

// Not required
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ public void onArmorStandManipulate(PlayerArmorStandManipulateEvent e) {

@EventHandler
public void onArmorDispense(BlockDispenseArmorEvent e) {
if (e.getTargetEntity() instanceof ArmorStand) {
if (ArmourStandUtils.isDisplayStand((ArmorStand) e.getTargetEntity())) e.setCancelled(true);
if (e.getTargetEntity() instanceof ArmorStand
&& ArmourStandUtils.isDisplayStand((ArmorStand) e.getTargetEntity())
) {
e.setCancelled(true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private void liquefactionBasin(Player player, SlimefunItem blockItem, Block clic
for (Map.Entry<StoryType, Integer> entry : cacheMap.entrySet()) {
final Integer integer = entry.getValue();
final StoryType storyType = entry.getKey();
final ItemStack itemStack = Materials.DUMMY_CRYSTAL_MAP.get(storyType).getItem().clone();
final ItemStack itemStack = Materials.getDummyCrystalMap().get(storyType).getItem().clone();
final double xOffset = (space * xPos) - evenOffset;

final Vector pointVector = new Vector(xOffset, 0, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void onInteract(PlayerInteractEvent e) {
);
stack.setItemMeta(itemMeta);
staveInstance.buildLore();
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(
player.sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(
ThemeType.SUCCESS.getColor() + "Casting spell: " + castInformation.getSpellType().getId()
));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.event.player.PlayerEggThrowEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.weather.LightningStrikeEvent;
import org.bukkit.inventory.ItemStack;
Expand Down Expand Up @@ -109,13 +108,6 @@ public void onFallingBlockLands(EntityChangeBlockEvent event) {
}
}

@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onEggThrow(PlayerEggThrowEvent event) {
if (CrystamaeHistoria.getProjectileMap().containsKey(event.getEgg().getUniqueId())) {
event.setHatching(false);
}
}

private boolean entityHitAllowed(CastInformation castInformation, Entity hitEntity) {
final Player player = Bukkit.getPlayer(castInformation.getCaster());
return hitEntity instanceof LivingEntity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.TimeCompression;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.TimeDilation;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Tracer;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.TunnelBore;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.Vacuum;
import io.github.sefiraat.crystamaehistoria.magic.spells.tier1.WitherWeather;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.liquefactionbasin.LiquefactionBasinCache;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ private void castBlood(CastInformation castInformation, Location location, doubl
getDamage(castInformation)
);
ParticleUtils.displayParticleEffect(livingEntity, 2, 10, dustOptions);
if (iteration <= 5) {
if (livingEntity.getHealth() <= 0) {
GeneralUtils.pushEntity(castInformation.getCaster(), castInformation.getCastLocation(), entity, 5);
ParticleUtils.displayParticleEffect(livingEntity, 4, 20, dustOptions);
entity.remove();
castBlood(castInformation, livingEntity.getLocation(), 2, iteration + 1);
}
if (iteration <= 5 && livingEntity.getHealth() <= 0) {
GeneralUtils.pushEntity(castInformation.getCaster(), castInformation.getCastLocation(), entity, 5);
ParticleUtils.displayParticleEffect(livingEntity, 4, 20, dustOptions);
entity.remove();
castBlood(castInformation, livingEntity.getLocation(), 2, iteration + 1);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public void projectileHit(CastInformation castInformation) {
final Location location = castInformation.getProjectileLocation();
final double range = getProjectileAoe(castInformation);
final int density = 50;

for (double height = 0; height <= Math.PI; height += Math.PI / density) {
for (int i = 0; i < range; i++) {
final double r = i * Math.sin(height);
Expand All @@ -63,45 +64,48 @@ public void projectileHit(CastInformation castInformation) {
final Location pointLocation = location.clone().add(x, y, z);
final Block block = pointLocation.getBlock();
final Material material = block.getType();
final Collection<Entity> entities = pointLocation.getWorld().getNearbyEntities(
pointLocation,
0.5,
0.5,
0.5
);

if (Tag.WOOL.isTagged(material)) {
convertBlock(caster, block, Tag.WOOL);
processBlock(caster, block, Tag.WOOL);
} else if (SlimefunTag.TERRACOTTA.isTagged(material)) {
convertBlock(caster, block, SlimefunTag.TERRACOTTA);
processBlock(caster, block, SlimefunTag.TERRACOTTA);
} else if (CrystaTag.GLAZED_TERRACOTTA.isTagged(material)) {
convertBlock(caster, block, CrystaTag.GLAZED_TERRACOTTA);
processBlock(caster, block, CrystaTag.GLAZED_TERRACOTTA);
} else if (SlimefunTag.CONCRETE_POWDERS.isTagged(material)) {
convertBlock(caster, block, SlimefunTag.CONCRETE_POWDERS);
processBlock(caster, block, SlimefunTag.CONCRETE_POWDERS);
} else if (CrystaTag.CONCRETE_BLOCKS.isTagged(material)) {
convertBlock(caster, block, CrystaTag.CONCRETE_BLOCKS);
processBlock(caster, block, CrystaTag.CONCRETE_BLOCKS);
} else if (Tag.CARPETS.isTagged(material)) {
convertBlock(caster, block, Tag.CARPETS);
processBlock(caster, block, Tag.CARPETS);
}
}
}
}
processEntities(location, caster);
}

for (Entity entity : entities) {
if (entity instanceof Colorable
&& GeneralUtils.hasPermission(caster, pointLocation, Interaction.INTERACT_ENTITY)
) {
final int randomValue = ThreadLocalRandom.current().nextInt(
0,
(int) Arrays.stream(DyeColor.values()).count()
);
((Colorable) entity).setColor(DyeColor.values()[randomValue]);
}
}
private void processEntities(Location location, UUID caster) {
final Collection<Entity> entities = location.getWorld().getNearbyEntities(
location,
0.5,
0.5,
0.5
);

}
for (Entity entity : entities) {
if (entity instanceof Colorable
&& GeneralUtils.hasPermission(caster, entity.getLocation(), Interaction.INTERACT_ENTITY)
) {
final int randomValue = ThreadLocalRandom.current().nextInt(
0,
(int) Arrays.stream(DyeColor.values()).count()
);
((Colorable) entity).setColor(DyeColor.values()[randomValue]);
}
}
}

private void convertBlock(UUID caster, Block block, Tag<Material> tag) {
private void processBlock(UUID caster, Block block, Tag<Material> tag) {
if (GeneralUtils.hasPermission(caster, block, Interaction.PLACE_BLOCK)) {
final List<Material> list = tag.getValues().stream().toList();
final int randomValue = ThreadLocalRandom.current().nextInt(0, list.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ public void projectileHit(CastInformation castInformation) {
for (int y = -range; y < range; y++) {
for (int x = -range; x < range; x++) {
for (int z = -range; z < range; z++) {
if (Math.sqrt((double) (x * x) + (y * y) + (z * z)) <= range) {
final Block block = location.getWorld().getBlockAt(
x + location.getBlockX(),
y + location.getBlockY(),
z + location.getBlockZ());
if (!blocks.contains(block)
&& GeneralUtils.hasPermission(caster, block, Interaction.BREAK_BLOCK)
) {
blocks.add(block);
}
if (Math.sqrt((double) (x * x) + (y * y) + (z * z)) > range) {
continue;
}

final Block block = location.getWorld().getBlockAt(
x + location.getBlockX(),
y + location.getBlockY(),
z + location.getBlockZ());
if (!blocks.contains(block) && GeneralUtils.hasPermission(caster, block, Interaction.BREAK_BLOCK)) {
blocks.add(block);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public EasterEgg() {
@ParametersAreNonnullByDefault
public void cast(CastInformation castInformation) {
Location location = castInformation.getCastLocation().add(0, 1, 0);
for (String string : ThemeType.EGG_NAMES) {
for (String string : ThemeType.getEggNames()) {
final List<Material> list = CrystaTag.SPAWN_EGGS.getValues().stream().toList();
final int randomValue = ThreadLocalRandom.current().nextInt(0, list.size());
DisplayItem displayItem = new DisplayItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public void cast(CastInformation castInformation) {
&& GeneralUtils.hasPermission(castInformation.getCaster(), entity.getLocation(), Interaction.INTERACT_ENTITY)
&& entity.getUniqueId() != castInformation.getCaster()
) {
// Todo mobs dont spin?
Location newLocation = entity.getLocation().clone();
newLocation.setYaw(entity.getLocation().getYaw() + 10F);
entity.teleport(newLocation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public void cast(CastInformation castInformation) {

// Bonemealing
for (int i = 0; i < castInformation.getStaveLevel() * 3; i++) {
final int x = (int) ThreadLocalRandom.current().nextDouble(-range, range);
final int z = (int) ThreadLocalRandom.current().nextDouble(-range, range);
final int x = ThreadLocalRandom.current().nextInt((int) -range, (int) range);
final int z = ThreadLocalRandom.current().nextInt((int) -range, (int) range);
final Block potentialBlock = location.add(x, 0, z).getBlock();
if (Tag.CROPS.isTagged(potentialBlock.getType())) {
potentialBlock.applyBoneMeal(BlockFace.UP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,19 @@
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

public class PlutosDecent extends Spell {

protected static final List<Material> MATERIALS = new ArrayList<>();

static {
MATERIALS.add(Material.BLACKSTONE_SLAB);
MATERIALS.add(Material.BLACKSTONE_STAIRS);
MATERIALS.add(Material.BLACKSTONE_WALL);
MATERIALS.add(Material.CRACKED_POLISHED_BLACKSTONE_BRICKS);
}

public PlutosDecent() {
SpellCoreBuilder spellCoreBuilder = new SpellCoreBuilder(25, false, 60, false, 75, true)
.makeDamagingSpell(5, true, 1, false)
Expand Down Expand Up @@ -65,7 +75,7 @@ private void spawnBlocks(CastInformation castInformation, List<Block> blocks) {
MagicFallingBlock magicFallingBlock = SpellUtils.summonMagicFallingBlock(
castInformation,
block.getLocation().add(0, 40, 0),
Material.BLACKSTONE_STAIRS,
MATERIALS.get(ThreadLocalRandom.current().nextInt(MATERIALS.size())),
5
);
magicFallingBlock.setVelocity(block.getLocation(), 2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@

public class Ravage extends Spell {

// TODO Riding ravagers removed until Paper patches

public Ravage() {
SpellCoreBuilder spellCoreBuilder = new SpellCoreBuilder(5, true, 0, false, 50, true)
.makeInstantSpell(this::cast)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ public void tick(CastInformation castInformation) {

final Block block = castInformation.getTargetedBlockOnCast().getRelative(xOffset, 0, zOffset);
final Block blockBelow = block.getRelative(BlockFace.DOWN);
if (GeneralUtils.tryBreakBlock(castInformation.getCaster(), block)) {
if (GeneralUtils.tryBreakBlock(castInformation.getCaster(), blockBelow)
&& castInformation.getCurrentTick() % 5 == 0
) {
blockBelow.setType(Material.TORCH);
}
if (GeneralUtils.tryBreakBlock(castInformation.getCaster(), block)
&& GeneralUtils.tryBreakBlock(castInformation.getCaster(), blockBelow)
&& castInformation.getCurrentTick() % 5 == 0
) {
blockBelow.setType(Material.TORCH);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

public class Tracer extends Spell {

public static final Map<String, Color> COLOR_MAP = new LinkedHashMap<>();
protected static final Map<String, Color> COLOR_MAP = new LinkedHashMap<>();

static {
COLOR_MAP.put("player", Color.fromRGB(255, 255, 255));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ null, new ItemStack(Material.FLOWER_POT), null,
ThemeType.GADGET,
"Greenhouse Glass",
"Crops under this glass will grow faster.",
"Works during the day in light worlds only.",
"",
ThemeType.CLICK_INFO.getColor() + "Rate: " + ThemeType.PASSIVE.getColor() + "5"
),
Expand Down Expand Up @@ -614,6 +615,7 @@ amalgamateDustEpic, new ItemStack(Material.GLASS), amalgamateDustEpic,
ThemeType.GADGET,
"Focused Greenhouse Glass",
"Crops under this glass will grow faster.",
"Works during the day in light worlds only.",
"",
ThemeType.CLICK_INFO.getColor() + "Rate: " + ThemeType.PASSIVE.getColor() + "10"
),
Expand Down
Loading

0 comments on commit d9c9304

Please sign in to comment.