Skip to content

Commit

Permalink
Merge pull request #112 from FN-FAL113/Dev/bug-fixes
Browse files Browse the repository at this point in the history
bug fixes and telepathy suggestion added
  • Loading branch information
FN-FAL113 authored Dec 8, 2023
2 parents ed93eaa + c9930b4 commit 6e9e2d6
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 69 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/blob-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,9 @@ jobs:
- name: Build with Maven
run: mvn package

- name: Set Filename Env Variables
run: |
echo "PROJECT_NAME=$(mvn help:evaluate -Dexpression=project.name -q -DforceStdout)" >> "$GITHUB_ENV"
echo "PROJECT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> "$GITHUB_ENV"
- name: Upload to Blob Builds
uses: WalshyDev/blob-builds/gh-action@main
with:
project: FNAmplifications
apiToken: ${{ secrets.BLOB_BUILDS_API_TOKEN }}
file: ./target/${{ env.PROJECT_NAME}} v${{ env.PROJECT_VERSION }}.jar
releaseNotes: ${{ github.event.head_commit.message }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
*.ipr
*.iws

# vs code
*.vscode

# IntelliJ
out/

Expand Down
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ Addon supports 1.16.x, 1.17.x, 1.18.x, 1.19.x, and 1.20.x minecraft versions
- **and more coming anytime soon!**

## :arrow_down: Download from build page with auto updates
### [Download Official Jar](https://thebusybiscuit.github.io/builds/FN-FAL113/FN-FAL-s-Amplifications/main)
[![Build Status](https://thebusybiscuit.github.io/builds/FN-FAL113/FN-FAL-s-Amplifications/main/badge.svg)](https://thebusybiscuit.github.io/builds/FN-FAL113/FN-FAL-s-Amplifications/main)
### [Download Official Jar](https://blob.build/project/FNAmplifications)

## ⏯️ Tutorial by Boomer_1 covering this addon
More has changed since this video was released meaning more items and content since the past few months!
Expand All @@ -49,7 +48,7 @@ Each major category has its own configurable settings.

You can change them if you think they need balancing or for several reasons

### :running: Head to my addon channel at SF Addon Community Server for feedbacks
### :running: Head over to SF Addon Community Server for feedbacks
<p>
<a href="https://discord.gg/slimefun">
<img src="https://discordapp.com/api/guilds/565557184348422174/widget.png?style=banner3" alt="Discord Invite"/>
Expand All @@ -59,7 +58,14 @@ You can change them if you think they need balancing or for several reasons
</a>
</p>

## 💖 Support the Project/Dev
I develop stuff for free with dedication and hard work. Sharing this project with fellow minecraft gamers/server owners or giving it a star is a huge sign of appreciation!</br>
a donation button (currently using parent's paypal due to my pending account requirements).<br/>
<a href="https://www.paypal.com/paypalme/ameliaOrbeta" target=_blank>
<img src="https://raw.githubusercontent.com/stefan-niedermann/paypal-donate-button/master/paypal-donate-button.png" alt="Donate with PayPal" width="40%" />
</a>

## :label: Credits
Waleks for SMG based generators<br>
Big credits to minecraft-heads for the head textures used by this addon:<br>
https://minecraft-heads.com/
Waleks for SMG based generators<br>
Minecraft-Heads for the head textures used by the addon:<br>
[Visit MC Heads Site](https://minecraft-heads.com/)
21 changes: 18 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@

<groupId>ne.fnfal113</groupId>
<artifactId>FNAmplifications</artifactId>
<version>Unoffical-4.1.2</version>
<version>Unoffical-4.1.3</version>
<packaging>jar</packaging>

<name>FNAmplifications</name>

<description>Adds different kind of items in-game! Take part on exploring FN's offerings!</description>
<description>Adds different kind of items in-game from machines, utilities to pvp related items! Take part on exploring FN's offering!</description>

<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<url>https://github.com/FN-FAL113</url>

<build>
Expand Down Expand Up @@ -48,7 +50,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<version>3.5.1</version>
<executions>
<execution>
<phase>package</phase>
Expand All @@ -61,11 +63,17 @@
</execution>
</executions>
<configuration>
<!-- shaded packages -->
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>ne.fnfal113.fnamplifications.bstats</shadedPattern>
</relocation>

<relocation>
<pattern>io.github.bakedlibs.dough.updater</pattern>
<shadedPattern>ne.fnfal113.fnamplifications.dough.updater</shadedPattern>
</relocation>
</relocations>
</configuration>
</plugin>
Expand Down Expand Up @@ -104,6 +112,13 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.github.baked-libs.dough</groupId>
<artifactId>dough-updater</artifactId>
<version>4b28bd408e</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import javax.annotation.Nonnull;

import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
import io.github.thebusybiscuit.slimefun4.libraries.dough.updater.GitHubBuildsUpdater;
import io.github.bakedlibs.dough.updater.BlobBuildUpdater;
import ne.fnfal113.fnamplifications.config.ConfigManager;
import ne.fnfal113.fnamplifications.gears.commands.GearCommands;
import ne.fnfal113.fnamplifications.gears.runnables.ArmorEquipRunnable;
Expand Down Expand Up @@ -50,8 +50,8 @@ public void onEnable() {
registerCommands();
getServer().getScheduler().runTaskTimerAsynchronously(this, new ArmorEquipRunnable(), 0L, getConfig().getInt("armor-update-period") * 20L);

if (getConfig().getBoolean("auto-update", true) && getDescription().getVersion().startsWith("DEV - ")) {
new GitHubBuildsUpdater(this, getFile(), "FN-FAL113/FN-FAL-s-Amplifications/main").start();
if (getConfig().getBoolean("auto-update", true) && getDescription().getVersion().startsWith("Dev - ")) {
new BlobBuildUpdater(this, getFile(), "FNAmplifications").start();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ public TelepathyGem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType reci

@Override
public void onDrag(Player player, SlimefunItem slimefunGemItem, ItemStack gemItem, ItemStack itemStackToSocket){
if (WeaponArmorEnum.PICKAXE.isTagged(itemStackToSocket.getType()) || WeaponArmorEnum.AXES.isTagged(itemStackToSocket.getType())) {
if (WeaponArmorEnum.PICKAXE.isTagged(itemStackToSocket.getType()) || WeaponArmorEnum.HOES.isTagged(itemStackToSocket.getType())
|| WeaponArmorEnum.SHOVELS.isTagged(itemStackToSocket.getType()) || WeaponArmorEnum.AXES.isTagged(itemStackToSocket.getType())
) {
bindGem(slimefunGemItem, itemStackToSocket, player);
} else {
player.sendMessage(Utils.colorTranslator("&eInvalid item to socket! Gem works on pickaxes and axes only"));
player.sendMessage(Utils.colorTranslator("&eInvalid item to socket! Gem works on pickaxes, hoes, shovels and axes only"));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,19 @@ public class Gem {

@Getter
private final SlimefunItem slimefunGemItem;
@Getter
private final String SlimefunGemItemName;

@Getter
private final ItemStack itemStackToSocket;

@Getter
private final String SlimefunGemItemID;

@Getter
private final Player player;

@Getter
private final NamespacedKey SlimefunGemItemIDKey;

@Getter
private final NamespacedKey socketAmountKey;

Expand All @@ -42,7 +45,6 @@ public Gem(SlimefunItem slimefunGemItem, ItemStack itemStackToSocket, Player pla
this.slimefunGemItem = slimefunGemItem;
this.itemStackToSocket = itemStackToSocket;
this.player = player;
this.SlimefunGemItemName = slimefunGemItem.getItemName();
this.SlimefunGemItemID = slimefunGemItem.getId();
this.SlimefunGemItemIDKey = Keys.createKey(slimefunGemItem.getId().toLowerCase());
this.socketAmountKey = Keys.createKey(itemStackToSocket.getType().toString().toLowerCase() + "_socket_amount");
Expand All @@ -55,10 +57,17 @@ public void startSocket(){

if(itemGemAmount < 5) { // gem amount must be below 5
if(!isSameGem(getItemStackToSocket())){ // check if the gem being added already exist
getPlayer().setItemOnCursor(new ItemStack(Material.AIR));
ItemStack cursorGemItem = getPlayer().getItemOnCursor();

if(cursorGemItem.getAmount() > 1) { // prevent consuming stacked gem
cursorGemItem.setAmount(cursorGemItem.getAmount() - 1);
} else {
getPlayer().setItemOnCursor(new ItemStack(Material.AIR));
}

socketGemToItemStack(meta, pdc, itemGemAmount);
} else {
getPlayer().sendMessage(Utils.colorTranslator("&6Your item has " + getSlimefunGemItemName() + " &6socketed already!"));
getPlayer().sendMessage(Utils.colorTranslator("&6Your item has " + getSlimefunGemItem().getItemName() + " &6socketed already!"));
getPlayer().playSound(getPlayer().getLocation(), Sound.ENTITY_BAT_TAKEOFF, 1.0F, 1.0F);
}

Expand All @@ -70,7 +79,7 @@ public void startSocket(){
}

public void socketGemToItemStack(ItemMeta meta, PersistentDataContainer pdc, int itemGemAmount){
String gemSlimefunItemname = getSlimefunGemItemName();
String gemSlimefunItemname = getSlimefunGemItem().getItemName();
List<String> lore = meta.hasLore() ? lore = meta.getLore() : new ArrayList<>();

if (itemGemAmount == 0) { // add the lore when adding a gem for the first time
Expand Down Expand Up @@ -114,18 +123,18 @@ public int checkGemAmount(PersistentDataContainer pdc, ItemStack itemStack){

/**
*
* @param itemStack the item to check whether it has already the gem
* @return if it has the same existing gem
* @param itemStackToSocket the itemstack to check
* @return a boolean if it has same existing gem
*/
public boolean isSameGem(ItemStack itemStack){
ItemMeta meta = itemStack.getItemMeta();
PersistentDataContainer container = meta.getPersistentDataContainer();
public boolean isSameGem(ItemStack itemStackToSocket){
ItemMeta meta = itemStackToSocket.getItemMeta();
PersistentDataContainer itemPdc = meta.getPersistentDataContainer();

if(container.isEmpty()) {
if(itemPdc.isEmpty()) {
return false;
}

return container.has(getSlimefunGemItemIDKey(), PersistentDataType.STRING);
return itemPdc.has(getSlimefunGemItemIDKey(), PersistentDataType.STRING);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,29 @@ public class UpgradedGem extends Gem {
@Getter
private final NamespacedKey key;

public UpgradedGem(SlimefunItem slimefunGemItem, ItemStack itemStackToSocket, Player p){
public UpgradedGem(SlimefunItem slimefunGemItem, ItemStack itemStackToSocket, Player p) {
super(slimefunGemItem, itemStackToSocket, p);

this.key = Keys.createKey(slimefunGemItem.getId().toLowerCase() + "_gem_tier");
}

public void upgradeExistingGem(ItemStack slimefunGemItem, int gemTier){
public void upgradeExistingGem(ItemStack slimefunGemItem, int gemTier) {
ItemMeta meta = getItemStackToSocket().getItemMeta();

PersistentDataContainer container = meta.getPersistentDataContainer();
int itemGemTier = container.getOrDefault(getKey(), PersistentDataType.INTEGER, 4);
int currentGemTier = container.getOrDefault(getKey(), PersistentDataType.INTEGER, 4);

List<String> lore = meta.getLore();

if(isSameGem(getItemStackToSocket())){
// gem pdc value must be equal to the succeeding item pdc value for tier order upgrades
// pdc value is reversed, tier 1 = 4, tier 2 = 3, tier 3 = 2, tier 4 = 1
// pdc value is then divided to the chance of the gem based from the config value or instance value
if(itemGemTier - 1 == gemTier){ // item gem tier II = 3 - 1 == 2, gem to bind tier 3 = 2.
if(isSameGem(getItemStackToSocket())) {
// current gem pdc value must be equal to the gem upgrade pdc value for tier order upgrades
// pdc tier value is reversed: tier 1 = 4, tier 2 = 3, tier 3 = 2, tier 4 = 1
// pdc tier value is then divided to the chance of the gem based from the config or instance value
if(currentGemTier - 1 == gemTier) { // ex. current gem tier II = 3 - 1 == 2 then the gem to bind tier 3 = 2.
getPlayer().setItemOnCursor(new ItemStack(Material.AIR));
if (lore != null) { // update item gem lore
for (int i = 0; i < lore.size(); i++) {
if(lore.get(i).contains(Utils.colorTranslator(getSlimefunGemItemName().substring(0, getSlimefunGemItemName().lastIndexOf(" ") + 2)))){
if(lore.get(i).contains(Utils.colorTranslator(getSlimefunGemItem().getItemName().substring(0, getSlimefunGemItem().getItemName().lastIndexOf(" ") + 2)))){
lore.set(i, ChatColor.RED + "◬ " + slimefunGemItem.getItemMeta().getDisplayName());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ public void onEntityDeath(PlayerDeathEvent event){

@EventHandler
public void onDragDrop(InventoryClickEvent event) {
if (!(event.getWhoClicked() instanceof Player)) {
if(!(event.getWhoClicked() instanceof Player)) {
return;
}

if (event.getAction() != InventoryAction.SWAP_WITH_CURSOR) {
if(event.getAction() != InventoryAction.SWAP_WITH_CURSOR) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;

import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.utils.WorldUtils;
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
import ne.fnfal113.fnamplifications.staffs.abstracts.AbstractStaff;
import ne.fnfal113.fnamplifications.utils.Keys;
Expand Down Expand Up @@ -49,7 +48,7 @@ public void onClick(PlayerInteractEvent event){
return;
}

for(int y = WorldUtils.getMinHeight(chunk.getWorld()); y <= chunk.getWorld().getMaxHeight() - 1; y++) {
for(int y = chunk.getWorld().getMinHeight(); y <= chunk.getWorld().getMaxHeight() - 1; y++) {
for(int x = 0; x <= 15; x++) {
for(int z = 0; z <= 15; z++) {
Block itemStack = chunk.getBlock(x, y, z);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void onClick(Player player, ItemStack itemInMainHand){
itemInMainHand.setAmount(itemInMainHand.getAmount() - 1);
}

public Consumer<ThrowableItemTask> torchConsumer(){
public Consumer<ThrowableItemTask> torchConsumer() {
return throwableItemTask -> {
Player owner = throwableItemTask.getPlayer();
ArmorStand armorStand = throwableItemTask.getArmorStand();
Expand All @@ -81,12 +81,14 @@ public Consumer<ThrowableItemTask> torchConsumer(){
RayTraceResult result = armorStand.rayTraceBlocks(0.80);
List<Entity> entityList = armorStand.getNearbyEntities(0.3, 0.3, 0.3);

if(result != null && Objects.requireNonNull(result.getHitBlock()).getType() != Material.GRASS && !Tag.FLOWERS.isTagged(result.getHitBlock().getType())){
if(result != null && Objects.requireNonNull(result.getHitBlock()).getType() != Material.GRASS
&& !Tag.FLOWERS.isTagged(result.getHitBlock().getType())
) {
Block blockHit = result.getHitBlock();

if(blockHit == null || blockTypePredicate.test(blockHit) || IGNORED_SOLID_BLOCKS.contains(blockHit.getType())
|| blockNameContains(blockHit, "gate") || blockNameContains(blockHit, "leaves")){
throwableItemTask.dropItemTask(armorStand, torch.clone());
throwableItemTask.dropTorch();

return;
}
Expand All @@ -98,7 +100,7 @@ public Consumer<ThrowableItemTask> torchConsumer(){
Predicate<Block> blockPredicate = block -> block.getType() == Material.AIR || block.getType() == Material.CAVE_AIR;

if(blockHit.getType() == Material.TORCH || blockHit.getType() == Material.WALL_TORCH){
throwableItemTask.dropItemTask(armorStand, torch.clone());
throwableItemTask.dropTorch();

return;
}
Expand All @@ -112,12 +114,14 @@ public Consumer<ThrowableItemTask> torchConsumer(){
} else if(blockPredicate.test(blockHit.getRelative(BlockFace.UP))){
placeTorch(blockHit.getRelative(BlockFace.UP), BlockFace.UP);
} else {
throwableItemTask.dropItemTask(armorStand, torch.clone());
throwableItemTask.dropTorch();;

return;
}

throwableItemTask.removeItemTask(armorStand);

throwableItemTask.stopTask();

return;
}
}
Expand All @@ -127,16 +131,17 @@ public Consumer<ThrowableItemTask> torchConsumer(){
if (entityList.get(i) instanceof Damageable && entityList.get(i).getUniqueId() != owner.getUniqueId()) {
entityList.get(i).setFireTicks(80);

throwableItemTask.removeItemTask(armorStand);
throwableItemTask.stopTask();

return;
}
}

throwableItemTask.dropItemTask(armorStand, torch.clone());
throwableItemTask.dropTorch();;
}

if(armorStand.getLocation().distanceSquared(owner.getLocation()) > 6400){ // drop the torch if it reaches 80 blocks away
throwableItemTask.dropItemTask(armorStand, torch.clone());
throwableItemTask.dropTorch();;
}
};
}
Expand Down
Loading

0 comments on commit 6e9e2d6

Please sign in to comment.