Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ plugins {
id "de.undercouch.download" version "5.0.1"
}

version '1.4.21-1.19.3'
version '1.4.23-1.19.3'
def nmsVersion = "1.19.3" //[NMS]
def apiVersion = '1.19'
def specialSourceVersion = '1.11.0' //[NMS]
def spigotJarVersion = '1.19.3-R0.1-SNAPSHOT' //[NMS]
def name = getRootProject().getName() // Defined in settings.gradle
def main = 'com.volmit.adapt.Adapt'
def manifoldVersion = '2022.1.21'

// ADD YOURSELF AS A NEW LINE IF YOU WANT YOUR OWN BUILD TASK GENERATED
// ======================== WINDOWS =============================
Expand Down Expand Up @@ -122,7 +123,6 @@ configurations.all {
resolutionStrategy.cacheDynamicVersionsFor 60, 'minutes'
}


dependencies {
// Provided or Classpath
compileOnly 'org.projectlombok:lombok:1.18.24'
Expand All @@ -133,9 +133,9 @@ dependencies {
// Cancer
implementation 'art.arcane:Amulet:22.7.18'
implementation 'art.arcane:Fukkit:22.7.5'
annotationProcessor 'systems.manifold:manifold-ext:2022.1.21'
testAnnotationProcessor 'systems.manifold:manifold-ext:2022.1.21'
implementation 'systems.manifold:manifold-rt:2022.1.21'
annotationProcessor 'systems.manifold:manifold-ext:' + manifoldVersion
testAnnotationProcessor 'systems.manifold:manifold-ext:' + manifoldVersion
implementation 'systems.manifold:manifold-rt:' + manifoldVersion
implementation "io.papermc:paperlib:1.0.7"

//Random Api's
Expand All @@ -150,15 +150,15 @@ dependencies {

// Shaded
implementation 'io.papermc:paperlib:1.0.5'
implementation "net.kyori:adventure-text-minimessage:4.11.0"
implementation 'net.kyori:adventure-text-minimessage:4.12.0'
implementation 'net.kyori:adventure-platform-bukkit:4.1.2'
implementation 'net.kyori:adventure-api:4.11.0'
implementation 'net.kyori:adventure-api:4.12.0'
implementation 'xyz.xenondevs:particle:1.8.1'

// Dynamically Loaded
implementation 'com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'com.google.code.gson:gson:2.10'
}

if (JavaVersion.current().toString() != "17") {
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/com/volmit/adapt/Adapt.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ public static void autoUpdateCheck() {
if (instance.getDescription().getVersion().contains("development")) {
info("Development build detected. Skipping update check.");
return;
}
else if (!version.equals(instance.getDescription().getVersion())) {
} else if (!version.equals(instance.getDescription().getVersion())) {
info("Please update your Adapt plugin to the latest version! (Current: " + instance.getDescription().getVersion() + " Latest: " + version + ")");
} else {
info("You are running the latest version of Adapt!");
Expand Down
24 changes: 7 additions & 17 deletions src/main/java/com/volmit/adapt/api/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,31 +265,21 @@ default void vfxZuck(Location from, Location to) {
}
}

default boolean safeGiveItem(Player player, Entity droppedItemEntity, ItemStack is) {
EntityPickupItemEvent e = new EntityPickupItemEvent(player, (Item) droppedItemEntity, 0);
default void safeGiveItem(Player player, Entity itemEntity, ItemStack is) {
EntityPickupItemEvent e = new EntityPickupItemEvent(player, (Item) itemEntity, 0);
Bukkit.getPluginManager().callEvent(e);
if (!e.isCancelled()) {
droppedItemEntity.remove();
itemEntity.remove();
if (!player.getInventory().addItem(is).isEmpty()) {
player.getWorld().dropItem(player.getLocation(), is);
}
return true;
} else {
return false;
}
}

default boolean safeGiveItem(Player player, Item droppedItemEntity, ItemStack is) {
EntityPickupItemEvent e = new EntityPickupItemEvent(player, droppedItemEntity, 0);
Bukkit.getPluginManager().callEvent(e);
if (!e.isCancelled()) {
droppedItemEntity.remove();
if (!player.getInventory().addItem(is).isEmpty()) {
player.getWorld().dropItem(player.getLocation(), is);
}
return true;
} else {
return false;

default void safeGiveItem(Player player, ItemStack item) {
if (!player.getInventory().addItem(item).isEmpty()) {
player.getWorld().dropItem(player.getLocation(), item);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/volmit/adapt/api/recipe/AdaptRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class Furnace implements AdaptRecipe {
private String key;
private ItemStack result;
private Material ingredient;
// private float experience = 1;
// private float experience = 1;
// private int cookTime = 20;
private float experience;
private int cookTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public static double getValue(Material m) {

private static double getValue(Material m, Set<MaterialRecipe> ignore) {
if (get().value.containsKey(m)) {
if (m.getHardness() == 0) {
if (m.isBlock() && m.getHardness() == 0) {
return 0;
}
return get().value.get(m);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/volmit/adapt/api/world/AdaptPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,13 @@ public double getSpeed() {

public boolean hasAdaptation(String id) {
String skillLine = id.split("-")[0];
Adapt.verbose("Checking for adaptation " + id + " in skill line " + skillLine);
if (skillLine == null)
return false;
PlayerSkillLine line = getData().getSkillLine(skillLine);
Adapt.verbose("Found skill line " + line);
if (line.getAdaptation(id) == null || line.getAdaptation(id).getLevel() == 0) {
Adapt.verbose("Adaptation " + id + " not found or level 0");
return false;
}
return line.getAdaptation(id).getLevel() > 0;
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/volmit/adapt/api/world/PlayerSkillLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ public void giveXP(Notifier p, double xp) {
last = M.ms();
if (AdaptConfig.get().isActionbarNotifyXp()) {
p.notifyXP(line, xp);
} else {
// bossbar thing here
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@
import com.volmit.adapt.api.adaptation.SimpleAdaptation;
import com.volmit.adapt.util.*;
import lombok.NoArgsConstructor;
import net.minecraft.world.level.Explosion;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockExplodeEvent;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;

Expand Down Expand Up @@ -114,6 +117,7 @@ public void on(PlayerMoveEvent e) {
blockPower.put(p, power);
}

//prevent piston from moving blocks // Dupe fix
@EventHandler(priority = EventPriority.HIGHEST)
public void on(BlockPistonExtendEvent e) {
if (e.isCancelled()) {
Expand All @@ -127,6 +131,7 @@ public void on(BlockPistonExtendEvent e) {
});
}

//prevent piston from pulling blocks // Dupe fix
@EventHandler(priority = EventPriority.HIGHEST)
public void on(BlockPistonRetractEvent e) {
if (e.isCancelled()) {
Expand All @@ -140,6 +145,35 @@ public void on(BlockPistonRetractEvent e) {
});
}

//prevent TNT from destroying blocks // Dupe fix
@EventHandler(priority = EventPriority.HIGHEST)
public void on(BlockExplodeEvent e) {
if (e.isCancelled()) {
return;
}
if (activeBlocks.contains(e.getBlock())) {
Adapt.verbose("Cancelled Block Explosion on Adaptation Foundation Block");
e.setCancelled(true);
}
}

//prevent block from being destroyed // Dupe fix
@EventHandler(priority = EventPriority.HIGHEST)
public void on(BlockBreakEvent e) {
if (activeBlocks.contains(e.getBlock())) {
e.setCancelled(true);
}
}

//prevent Entities from destroying blocks // Dupe fix
@EventHandler(priority = EventPriority.HIGHEST)
public void on(EntityExplodeEvent e) {
if (e.isCancelled()) {
return;
}
e.blockList().removeIf(activeBlocks::contains);
}

@EventHandler(priority = EventPriority.MONITOR)
public void on(PlayerToggleSneakEvent e) {
if (e.isCancelled()) {
Expand Down Expand Up @@ -238,12 +272,7 @@ private boolean hasCooldown(Player i) {
return cooldowns.containsKey(i);
}

@EventHandler(priority = EventPriority.HIGHEST)
public void on(BlockBreakEvent e) {
if (activeBlocks.contains(e.getBlock())) {
e.setCancelled(true);
}
}


@Override
public boolean isEnabled() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public void on(BlockPlaceEvent e) {
if (hand.getAmount() > 0) {
runPlayerViewport(getBlockFace(p), p.getTargetBlock(null, 5), p.getInventory().getItemInMainHand().getType(), p);
}
e.setCancelled(true);
} else {
Adapt.messagePlayer(p, C.RED + Localizer.dLocalize("architect", "placement", "lore1") + " " + C.GREEN + totalMap.get(p).size() + C.RED + " " + Localizer.dLocalize("architect", "placement", "lore2"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.volmit.adapt.util.J;
import com.volmit.adapt.util.Localizer;
import lombok.NoArgsConstructor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Sound;
Expand All @@ -37,8 +36,8 @@
import org.bukkit.inventory.ItemStack;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.HashSet;
import java.util.Set;

public class AxeWoodVeinminer extends SimpleAdaptation<AxeWoodVeinminer.Config> {
public AxeWoodVeinminer() {
Expand Down Expand Up @@ -89,8 +88,7 @@ public void on(BlockBreakEvent e) {
if (isLog(new ItemStack(e.getBlock().getType()))) {

Block block = e.getBlock();
Map<Location, Block> blockMap = new HashMap<>();
blockMap.put(block.getLocation(), block);
Set<Block> blockMap = new HashSet<>();
int blockCount = 0;
for (int i = 0; i < getRadius(getLevel(p)); i++) {
for (int x = -i; x <= i; x++) {
Expand All @@ -107,46 +105,31 @@ public void on(BlockBreakEvent e) {
Adapt.verbose("Block: " + b.getLocation() + " is too far away from " + block.getLocation() + " (" + getRadius(getLevel(p)) + ")");
continue;
}
blockMap.put(b.getLocation(), b);
blockMap.add(b);
}
}
}
}
}

J.s(() -> {
for (Location l : blockMap.keySet()) {
Block b = e.getBlock().getWorld().getBlockAt(l);
xp(p, 2);
if (getPlayer(p).getData().getSkillLines() != null
&& getPlayer(p).getData().getSkillLines().get("axes").getAdaptations() != null
&& getPlayer(p).getData().getSkillLines().get("axes").getAdaptations().get("axe-drop-to-inventory") != null
&& getPlayer(p).getData().getSkillLines().get("axes").getAdaptations().get("axe-drop-to-inventory").getLevel() > 0) {
Collection<ItemStack> items = e.getBlock().getDrops();
if (!isLog(new ItemStack(b.getType()))) {
for (ItemStack i : items) {
p.playSound(p.getLocation(), Sound.BLOCK_CALCITE_HIT, 0.01f, 0.01f);
xp(p, 2);
HashMap<Integer, ItemStack> extra = p.getInventory().addItem(i);
if (!extra.isEmpty()) {
p.getWorld().dropItem(p.getLocation(), extra.get(0));
}
}
} else {
if (!p.getInventory().addItem(new ItemStack(b.getType())).isEmpty()) {
p.getWorld().dropItemNaturally(p.getLocation(), new ItemStack(b.getType()));
}
for (Block blocks : blockMap) {
if (getPlayer(p).getData().getSkillLines().get("axes").getAdaptations().get("axe-drop-to-inventory").getLevel() > 0) {
Collection<ItemStack> items = blocks.getDrops();
for (ItemStack item : items) {
safeGiveItem(p, item);
Adapt.verbose("Giving item: " + item);
}
p.breakBlock(l.getBlock());
blocks.setType(Material.AIR);
} else {
b.breakNaturally(p.getItemInUse());
e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.BLOCK_FUNGUS_BREAK, 0.01f, 0.25f);
blocks.breakNaturally(p.getItemInUse());
blocks.getWorld().playSound(e.getBlock().getLocation(), Sound.BLOCK_FUNGUS_BREAK, 0.01f, 0.25f);
if (getConfig().showParticles) {
e.getBlock().getWorld().spawnParticle(Particle.ASH, e.getBlock().getLocation().add(0.5, 0.5, 0.5), 25, 0.5, 0.5, 0.5, 0.1);
blocks.getWorld().spawnParticle(Particle.ASH, blocks.getLocation().add(0.5, 0.5, 0.5), 25, 0.5, 0.5, 0.5, 0.1);
}
}
if (getConfig().showParticles) {
vfxSingleCubeOutlineR(b, Particle.ENCHANTMENT_TABLE);
vfxSingleCubeOutlineR(blocks, Particle.ENCHANTMENT_TABLE);
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void onTick() {
if (activeStands.get(b.getBlock()) == 0) {
activeStands.remove(b.getBlock());
}
if(activeStands.containsKey(b.getBlock())) {
if (activeStands.containsKey(b.getBlock())) {
activeStands.put(b.getBlock(), activeStands.get(b.getBlock()) - 1);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void on(EntityDamageEvent e) {
} else {
if (getConfig().consumable != null && Material.getMaterial(getConfig().consumable) != null) {
Material mat = Material.getMaterial(getConfig().consumable);
if (mat != null &&p.getInventory().contains(mat)) {
if (mat != null && p.getInventory().contains(mat)) {
p.getInventory().removeItem(new ItemStack(mat, 1));
addPotionStacks(p, PotionEffectType.LUCK, getLevel(p), 50, false);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void on(EntityDamageEvent e) {
} else {
if (getConfig().consumable != null && Material.getMaterial(getConfig().consumable) != null) {
Material mat = Material.getMaterial(getConfig().consumable);
if (mat != null &&p.getInventory().contains(mat)) {
if (mat != null && p.getInventory().contains(mat)) {
p.getInventory().removeItem(new ItemStack(mat, 1));
addPotionStacks(p, PotionEffectType.REGENERATION, getLevel(p), 5 + getLevel(p), false);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void on(EntityDamageEvent e) {
} else {
if (getConfig().consumable != null && Material.getMaterial(getConfig().consumable) != null) {
Material mat = Material.getMaterial(getConfig().consumable);
if (mat != null &&p.getInventory().contains(mat)) {
if (mat != null && p.getInventory().contains(mat)) {
p.getInventory().removeItem(new ItemStack(mat, 1));
addPotionStacks(p, PotionEffectType.DAMAGE_RESISTANCE, getLevel(p), 50, false);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void on(EntityDamageEvent e) {
} else {
if (getConfig().consumable != null && Material.getMaterial(getConfig().consumable) != null) {
Material mat = Material.getMaterial(getConfig().consumable);
if (mat != null &&p.getInventory().contains(mat)) {
if (mat != null && p.getInventory().contains(mat)) {
p.getInventory().removeItem(new ItemStack(mat, 1));
addPotionStacks(p, PotionEffectType.SPEED, getLevel(p), 50, false);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void on(EntityDamageEvent e) {
} else {
if (getConfig().consumable != null && Material.getMaterial(getConfig().consumable) != null) {
Material mat = Material.getMaterial(getConfig().consumable);
if (mat != null &&p.getInventory().contains(mat)) {
if (mat != null && p.getInventory().contains(mat)) {
p.getInventory().removeItem(new ItemStack(mat, 1));
addPotionStacks(p, PotionEffectType.INCREASE_DAMAGE, getLevel(p), 50, false);
} else {
Expand Down
Loading