Skip to content

Commit f079222

Browse files
Merge pull request #361 from VolmitSoftware/Development
Development
2 parents 2ebe0c9 + 9c79f12 commit f079222

24 files changed

+382
-302
lines changed

build.gradle

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,14 @@ plugins {
2323
id "de.undercouch.download" version "5.0.1"
2424
}
2525

26-
version '1.4.21-1.19.3'
26+
version '1.4.23-1.19.3'
2727
def nmsVersion = "1.19.3" //[NMS]
2828
def apiVersion = '1.19'
2929
def specialSourceVersion = '1.11.0' //[NMS]
3030
def spigotJarVersion = '1.19.3-R0.1-SNAPSHOT' //[NMS]
3131
def name = getRootProject().getName() // Defined in settings.gradle
3232
def main = 'com.volmit.adapt.Adapt'
33+
def manifoldVersion = '2022.1.21'
3334

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

125-
126126
dependencies {
127127
// Provided or Classpath
128128
compileOnly 'org.projectlombok:lombok:1.18.24'
@@ -133,9 +133,9 @@ dependencies {
133133
// Cancer
134134
implementation 'art.arcane:Amulet:22.7.18'
135135
implementation 'art.arcane:Fukkit:22.7.5'
136-
annotationProcessor 'systems.manifold:manifold-ext:2022.1.21'
137-
testAnnotationProcessor 'systems.manifold:manifold-ext:2022.1.21'
138-
implementation 'systems.manifold:manifold-rt:2022.1.21'
136+
annotationProcessor 'systems.manifold:manifold-ext:' + manifoldVersion
137+
testAnnotationProcessor 'systems.manifold:manifold-ext:' + manifoldVersion
138+
implementation 'systems.manifold:manifold-rt:' + manifoldVersion
139139
implementation "io.papermc:paperlib:1.0.7"
140140

141141
//Random Api's
@@ -150,15 +150,15 @@ dependencies {
150150

151151
// Shaded
152152
implementation 'io.papermc:paperlib:1.0.5'
153-
implementation "net.kyori:adventure-text-minimessage:4.11.0"
153+
implementation 'net.kyori:adventure-text-minimessage:4.12.0'
154154
implementation 'net.kyori:adventure-platform-bukkit:4.1.2'
155-
implementation 'net.kyori:adventure-api:4.11.0'
155+
implementation 'net.kyori:adventure-api:4.12.0'
156156
implementation 'xyz.xenondevs:particle:1.8.1'
157157

158158
// Dynamically Loaded
159159
implementation 'com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2'
160160
implementation 'org.apache.commons:commons-lang3:3.12.0'
161-
implementation 'com.google.code.gson:gson:2.9.0'
161+
implementation 'com.google.code.gson:gson:2.10'
162162
}
163163

164164
if (JavaVersion.current().toString() != "17") {

src/main/java/com/volmit/adapt/Adapt.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ public static void autoUpdateCheck() {
9999
if (instance.getDescription().getVersion().contains("development")) {
100100
info("Development build detected. Skipping update check.");
101101
return;
102-
}
103-
else if (!version.equals(instance.getDescription().getVersion())) {
102+
} else if (!version.equals(instance.getDescription().getVersion())) {
104103
info("Please update your Adapt plugin to the latest version! (Current: " + instance.getDescription().getVersion() + " Latest: " + version + ")");
105104
} else {
106105
info("You are running the latest version of Adapt!");

src/main/java/com/volmit/adapt/api/Component.java

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -265,31 +265,21 @@ default void vfxZuck(Location from, Location to) {
265265
}
266266
}
267267

268-
default boolean safeGiveItem(Player player, Entity droppedItemEntity, ItemStack is) {
269-
EntityPickupItemEvent e = new EntityPickupItemEvent(player, (Item) droppedItemEntity, 0);
268+
default void safeGiveItem(Player player, Entity itemEntity, ItemStack is) {
269+
EntityPickupItemEvent e = new EntityPickupItemEvent(player, (Item) itemEntity, 0);
270270
Bukkit.getPluginManager().callEvent(e);
271271
if (!e.isCancelled()) {
272-
droppedItemEntity.remove();
272+
itemEntity.remove();
273273
if (!player.getInventory().addItem(is).isEmpty()) {
274274
player.getWorld().dropItem(player.getLocation(), is);
275275
}
276-
return true;
277-
} else {
278-
return false;
279276
}
280277
}
281278

282-
default boolean safeGiveItem(Player player, Item droppedItemEntity, ItemStack is) {
283-
EntityPickupItemEvent e = new EntityPickupItemEvent(player, droppedItemEntity, 0);
284-
Bukkit.getPluginManager().callEvent(e);
285-
if (!e.isCancelled()) {
286-
droppedItemEntity.remove();
287-
if (!player.getInventory().addItem(is).isEmpty()) {
288-
player.getWorld().dropItem(player.getLocation(), is);
289-
}
290-
return true;
291-
} else {
292-
return false;
279+
280+
default void safeGiveItem(Player player, ItemStack item) {
281+
if (!player.getInventory().addItem(item).isEmpty()) {
282+
player.getWorld().dropItem(player.getLocation(), item);
293283
}
294284
}
295285

src/main/java/com/volmit/adapt/api/recipe/AdaptRecipe.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class Furnace implements AdaptRecipe {
115115
private String key;
116116
private ItemStack result;
117117
private Material ingredient;
118-
// private float experience = 1;
118+
// private float experience = 1;
119119
// private int cookTime = 20;
120120
private float experience;
121121
private int cookTime;

src/main/java/com/volmit/adapt/api/value/MaterialValue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public static double getValue(Material m) {
139139

140140
private static double getValue(Material m, Set<MaterialRecipe> ignore) {
141141
if (get().value.containsKey(m)) {
142-
if (m.getHardness() == 0) {
142+
if (m.isBlock() && m.getHardness() == 0) {
143143
return 0;
144144
}
145145
return get().value.get(m);

src/main/java/com/volmit/adapt/api/world/AdaptPlayer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,13 @@ public double getSpeed() {
241241

242242
public boolean hasAdaptation(String id) {
243243
String skillLine = id.split("-")[0];
244+
Adapt.verbose("Checking for adaptation " + id + " in skill line " + skillLine);
244245
if (skillLine == null)
245246
return false;
246247
PlayerSkillLine line = getData().getSkillLine(skillLine);
248+
Adapt.verbose("Found skill line " + line);
247249
if (line.getAdaptation(id) == null || line.getAdaptation(id).getLevel() == 0) {
250+
Adapt.verbose("Adaptation " + id + " not found or level 0");
248251
return false;
249252
}
250253
return line.getAdaptation(id).getLevel() > 0;

src/main/java/com/volmit/adapt/api/world/PlayerSkillLine.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ public void giveXP(Notifier p, double xp) {
6767
last = M.ms();
6868
if (AdaptConfig.get().isActionbarNotifyXp()) {
6969
p.notifyXP(line, xp);
70+
} else {
71+
// bossbar thing here
7072
}
7173
}
7274
}

src/main/java/com/volmit/adapt/content/adaptation/architect/ArchitectFoundation.java

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,18 @@
2222
import com.volmit.adapt.api.adaptation.SimpleAdaptation;
2323
import com.volmit.adapt.util.*;
2424
import lombok.NoArgsConstructor;
25+
import net.minecraft.world.level.Explosion;
2526
import org.bukkit.*;
2627
import org.bukkit.block.Block;
2728
import org.bukkit.block.data.BlockData;
2829
import org.bukkit.entity.Player;
2930
import org.bukkit.event.EventHandler;
3031
import org.bukkit.event.EventPriority;
3132
import org.bukkit.event.block.BlockBreakEvent;
33+
import org.bukkit.event.block.BlockExplodeEvent;
3234
import org.bukkit.event.block.BlockPistonExtendEvent;
3335
import org.bukkit.event.block.BlockPistonRetractEvent;
36+
import org.bukkit.event.entity.EntityExplodeEvent;
3437
import org.bukkit.event.player.PlayerMoveEvent;
3538
import org.bukkit.event.player.PlayerToggleSneakEvent;
3639

@@ -114,6 +117,7 @@ public void on(PlayerMoveEvent e) {
114117
blockPower.put(p, power);
115118
}
116119

120+
//prevent piston from moving blocks // Dupe fix
117121
@EventHandler(priority = EventPriority.HIGHEST)
118122
public void on(BlockPistonExtendEvent e) {
119123
if (e.isCancelled()) {
@@ -127,6 +131,7 @@ public void on(BlockPistonExtendEvent e) {
127131
});
128132
}
129133

134+
//prevent piston from pulling blocks // Dupe fix
130135
@EventHandler(priority = EventPriority.HIGHEST)
131136
public void on(BlockPistonRetractEvent e) {
132137
if (e.isCancelled()) {
@@ -140,6 +145,35 @@ public void on(BlockPistonRetractEvent e) {
140145
});
141146
}
142147

148+
//prevent TNT from destroying blocks // Dupe fix
149+
@EventHandler(priority = EventPriority.HIGHEST)
150+
public void on(BlockExplodeEvent e) {
151+
if (e.isCancelled()) {
152+
return;
153+
}
154+
if (activeBlocks.contains(e.getBlock())) {
155+
Adapt.verbose("Cancelled Block Explosion on Adaptation Foundation Block");
156+
e.setCancelled(true);
157+
}
158+
}
159+
160+
//prevent block from being destroyed // Dupe fix
161+
@EventHandler(priority = EventPriority.HIGHEST)
162+
public void on(BlockBreakEvent e) {
163+
if (activeBlocks.contains(e.getBlock())) {
164+
e.setCancelled(true);
165+
}
166+
}
167+
168+
//prevent Entities from destroying blocks // Dupe fix
169+
@EventHandler(priority = EventPriority.HIGHEST)
170+
public void on(EntityExplodeEvent e) {
171+
if (e.isCancelled()) {
172+
return;
173+
}
174+
e.blockList().removeIf(activeBlocks::contains);
175+
}
176+
143177
@EventHandler(priority = EventPriority.MONITOR)
144178
public void on(PlayerToggleSneakEvent e) {
145179
if (e.isCancelled()) {
@@ -238,12 +272,7 @@ private boolean hasCooldown(Player i) {
238272
return cooldowns.containsKey(i);
239273
}
240274

241-
@EventHandler(priority = EventPriority.HIGHEST)
242-
public void on(BlockBreakEvent e) {
243-
if (activeBlocks.contains(e.getBlock())) {
244-
e.setCancelled(true);
245-
}
246-
}
275+
247276

248277
@Override
249278
public boolean isEnabled() {

src/main/java/com/volmit/adapt/content/adaptation/architect/ArchitectPlacement.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ public void on(BlockPlaceEvent e) {
110110
if (hand.getAmount() > 0) {
111111
runPlayerViewport(getBlockFace(p), p.getTargetBlock(null, 5), p.getInventory().getItemInMainHand().getType(), p);
112112
}
113+
e.setCancelled(true);
113114
} else {
114115
Adapt.messagePlayer(p, C.RED + Localizer.dLocalize("architect", "placement", "lore1") + " " + C.GREEN + totalMap.get(p).size() + C.RED + " " + Localizer.dLocalize("architect", "placement", "lore2"));
115116
}

src/main/java/com/volmit/adapt/content/adaptation/axe/AxeWoodVeinminer.java

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import com.volmit.adapt.util.J;
2626
import com.volmit.adapt.util.Localizer;
2727
import lombok.NoArgsConstructor;
28-
import org.bukkit.Location;
2928
import org.bukkit.Material;
3029
import org.bukkit.Particle;
3130
import org.bukkit.Sound;
@@ -37,8 +36,8 @@
3736
import org.bukkit.inventory.ItemStack;
3837

3938
import java.util.Collection;
40-
import java.util.HashMap;
41-
import java.util.Map;
39+
import java.util.HashSet;
40+
import java.util.Set;
4241

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

9190
Block block = e.getBlock();
92-
Map<Location, Block> blockMap = new HashMap<>();
93-
blockMap.put(block.getLocation(), block);
91+
Set<Block> blockMap = new HashSet<>();
9492
int blockCount = 0;
9593
for (int i = 0; i < getRadius(getLevel(p)); i++) {
9694
for (int x = -i; x <= i; x++) {
@@ -107,46 +105,31 @@ public void on(BlockBreakEvent e) {
107105
Adapt.verbose("Block: " + b.getLocation() + " is too far away from " + block.getLocation() + " (" + getRadius(getLevel(p)) + ")");
108106
continue;
109107
}
110-
blockMap.put(b.getLocation(), b);
108+
blockMap.add(b);
111109
}
112110
}
113111
}
114112
}
115113
}
116114

117115
J.s(() -> {
118-
for (Location l : blockMap.keySet()) {
119-
Block b = e.getBlock().getWorld().getBlockAt(l);
120-
xp(p, 2);
121-
if (getPlayer(p).getData().getSkillLines() != null
122-
&& getPlayer(p).getData().getSkillLines().get("axes").getAdaptations() != null
123-
&& getPlayer(p).getData().getSkillLines().get("axes").getAdaptations().get("axe-drop-to-inventory") != null
124-
&& getPlayer(p).getData().getSkillLines().get("axes").getAdaptations().get("axe-drop-to-inventory").getLevel() > 0) {
125-
Collection<ItemStack> items = e.getBlock().getDrops();
126-
if (!isLog(new ItemStack(b.getType()))) {
127-
for (ItemStack i : items) {
128-
p.playSound(p.getLocation(), Sound.BLOCK_CALCITE_HIT, 0.01f, 0.01f);
129-
xp(p, 2);
130-
HashMap<Integer, ItemStack> extra = p.getInventory().addItem(i);
131-
if (!extra.isEmpty()) {
132-
p.getWorld().dropItem(p.getLocation(), extra.get(0));
133-
}
134-
}
135-
} else {
136-
if (!p.getInventory().addItem(new ItemStack(b.getType())).isEmpty()) {
137-
p.getWorld().dropItemNaturally(p.getLocation(), new ItemStack(b.getType()));
138-
}
116+
for (Block blocks : blockMap) {
117+
if (getPlayer(p).getData().getSkillLines().get("axes").getAdaptations().get("axe-drop-to-inventory").getLevel() > 0) {
118+
Collection<ItemStack> items = blocks.getDrops();
119+
for (ItemStack item : items) {
120+
safeGiveItem(p, item);
121+
Adapt.verbose("Giving item: " + item);
139122
}
140-
p.breakBlock(l.getBlock());
123+
blocks.setType(Material.AIR);
141124
} else {
142-
b.breakNaturally(p.getItemInUse());
143-
e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.BLOCK_FUNGUS_BREAK, 0.01f, 0.25f);
125+
blocks.breakNaturally(p.getItemInUse());
126+
blocks.getWorld().playSound(e.getBlock().getLocation(), Sound.BLOCK_FUNGUS_BREAK, 0.01f, 0.25f);
144127
if (getConfig().showParticles) {
145-
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);
128+
blocks.getWorld().spawnParticle(Particle.ASH, blocks.getLocation().add(0.5, 0.5, 0.5), 25, 0.5, 0.5, 0.5, 0.1);
146129
}
147130
}
148131
if (getConfig().showParticles) {
149-
vfxSingleCubeOutlineR(b, Particle.ENCHANTMENT_TABLE);
132+
vfxSingleCubeOutlineR(blocks, Particle.ENCHANTMENT_TABLE);
150133
}
151134
}
152135
});

0 commit comments

Comments
 (0)