Skip to content

Commit

Permalink
Merge pull request #460 from VolmitSoftware/Development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
NextdoorPsycho committed Aug 12, 2023
2 parents fd10b5c + 3c40a09 commit 65c01a2
Show file tree
Hide file tree
Showing 14 changed files with 222 additions and 259 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ plugins {
id "de.undercouch.download" version "5.0.1"
}

version '1.12.3-1.20.1'
version '1.13.0-1.20.1'
def nmsVersion = "1.20.1" //[NMS]
def apiVersion = '1.20'
def specialSourceVersion = '1.11.0' //[NMS]
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/volmit/adapt/AdaptConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
@Getter
public class AdaptConfig {
private static AdaptConfig config = null;
private boolean hotReload = false;
public boolean debug = false;
public boolean autoUpdateCheck = true;
public boolean autoUpdateLanguage = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ public void registerConfiguration(Class<T> type) {
@Override
public void onTick() {
try {
if (!AdaptConfig.get().isHotReload()) {
return;
}
if (fw.checkModified() && file.exists()) {
config = null;
getConfig();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/volmit/adapt/api/skill/SimpleSkill.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void registerAdvancement(AdaptAdvancement a) {
}

public boolean checkValidEntity(EntityType e) {
if (!e.isAlive()) {
if (!e.isAlive() || e.equals(EntityType.PARROT)) {
return false;
}
return !ItemListings.getInvalidDamageableEntities().contains(e);
Expand Down
148 changes: 70 additions & 78 deletions src/main/java/com/volmit/adapt/api/world/PlayerSkillLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,77 @@ private static double diff(long a, long b) {
return Math.abs(a - b / (double) (a == 0 ? 1 : a));
}

public void update(AdaptPlayer p, String line, PlayerData data) {
grantSkillsAndAdaptations(p, line);
checkMaxLevel(p, line);
updateFreshness();
updateMultiplier(data);
updateEarnedXP(p, line);
updateLevel(p, line, data);
}

private void grantSkillsAndAdaptations(AdaptPlayer p, String line) {
if (!p.getData().isGranted("skill_" + line) && AdaptConfig.get().isAdvancements()) {
p.getAdvancementHandler().grant("skill_" + line);
}

for (String i : getAdaptations().keySet()) {
if (!p.getData().isGranted("adaptation_" + i) && AdaptConfig.get().isAdvancements()) {
p.getAdvancementHandler().grant("adaptation_" + i);
}
}
}

private void checkMaxLevel(AdaptPlayer p, String line) {
if (!p.isBusy() && getXp() > XP.getXpForLevel(AdaptConfig.get().experienceMaxLevel)) {
p.getData().addWisdom();
Adapt.warn("A Player has reached the maximum level of " + AdaptConfig.get().experienceMaxLevel + " and has been granted 1 wisdom, Dropping Level to " + lastLevel);
setXp(XP.getXpForLevel(AdaptConfig.get().experienceMaxLevel - 1));
}
}

private void updateFreshness() {
double max = 1D + (getLevel() * 0.004);

freshness += (0.1 * freshness) + 0.00124;
if (freshness > max) freshness = max;
if (freshness < 0.01) freshness = 0.01;
if (freshness < rfreshness) rfreshness -= ((rfreshness - freshness) * 0.003);
if (freshness > rfreshness) rfreshness += (freshness - rfreshness) * 0.265;
}

private void updateMultiplier(PlayerData data) {
double m = rfreshness;
for (XPMultiplier i : multipliers.copy()) {
if (i.isExpired()) multipliers.remove(i);
else m += i.getMultiplier();
}

m = Math.max(0.01, Math.min(m, 1000));
multiplier = m * data.getMultiplier();
}

private void updateEarnedXP(AdaptPlayer p, String line) {
double earned = xp - lastXP;
if (earned > p.getServer().getSkillRegistry().getSkill(line).getMinXp()) lastXP = xp;
}

private void updateLevel(AdaptPlayer p, String line, PlayerData data) {
if (lastLevel < getLevel()) {
long kb = getKnowledge();
for (int i = lastLevel; i < getLevel(); i++) {
giveKnowledge((i / 13) + 1);
p.getData().giveMasterXp((i * AdaptConfig.get().getPlayerXpPerSkillLevelUpLevelMultiplier()) + AdaptConfig.get().getPlayerXpPerSkillLevelUpBase());
}

if (AdaptConfig.get().isActionbarNotifyLevel()) notifyLevel(p, getLevel(), getKnowledge());
lastLevel = getLevel();
}
}

public void giveXP(Notifier p, double xp) {
freshness -= xp * 0.001;
// freshness -= xp * 0.005; // Increased from 0.001
freshness -= Math.pow(xp, 2) * 0.0001; // Exponential decrease, attempt
xp = multiplier * xp;
this.xp += xp;

Expand Down Expand Up @@ -117,83 +186,6 @@ public Skill getRawSkill(AdaptPlayer p) {
return p.getServer().getSkillRegistry().getSkill(line);
}

public void update(AdaptPlayer p, String line, PlayerData data) {
if (!p.getData().isGranted("skill_" + line) && AdaptConfig.get().isAdvancements()) {
p.getAdvancementHandler().grant("skill_" + line);
}

for (String i : getAdaptations().k()) {
if (!p.getData().isGranted("adaptation_" + i) && AdaptConfig.get().isAdvancements()) {
p.getAdvancementHandler().grant("adaptation_" + i);
}
}

//check if they are exceeding the max level, and just set it to the last level XP and level
if (!p.isBusy() && getXp() > XP.getXpForLevel(AdaptConfig.get().experienceMaxLevel)) {
p.getData().addWisdom();
Adapt.warn("A Player has reached the maximum level of " + AdaptConfig.get().experienceMaxLevel + " and has been granted 1 wisdom, Dropping Level to " + lastLevel);
setXp(XP.getXpForLevel(AdaptConfig.get().experienceMaxLevel -1));
}

double max = 1D + (getLevel() * 0.004);

freshness += (0.1 * freshness) + 0.00124;
if (freshness > max) {
freshness = max;
}

if (freshness < 0.01) {
freshness = 0.01;
}

if (freshness < rfreshness) {
rfreshness -= ((rfreshness - freshness) * 0.003);
}

if (freshness > rfreshness) {
rfreshness += (freshness - rfreshness) * 0.265;
}

double m = rfreshness;

for (XPMultiplier i : multipliers.copy()) {
if (i.isExpired()) {
multipliers.remove(i);
continue;
}

m += i.getMultiplier();
}

if (m <= 0) {
m = 0.01;
}

if (m > 1000) {
m = 1000;
}

multiplier = m * data.getMultiplier();

double earned = xp - lastXP;

if (earned > p.getServer().getSkillRegistry().getSkill(line).getMinXp()) {
lastXP = xp;
}

if (lastLevel < getLevel()) {
long kb = getKnowledge();
for (int i = lastLevel; i < getLevel(); i++) {
giveKnowledge((i / 13) + 1);
p.getData().giveMasterXp((i * AdaptConfig.get().getPlayerXpPerSkillLevelUpLevelMultiplier()) + AdaptConfig.get().getPlayerXpPerSkillLevelUpBase());
}
if (AdaptConfig.get().isActionbarNotifyLevel()) {
notifyLevel(p, getLevel(), getKnowledge());
}
lastLevel = getLevel();
}
}

private void notifyLevel(AdaptPlayer p, double lvl, long kn) {
// Skill s = p.getServer().getSkillRegistry().getSkill(getLine());
if (lvl % 10 == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package com.volmit.adapt.content.adaptation.axe;

import com.volmit.adapt.Adapt;
import com.volmit.adapt.api.adaptation.SimpleAdaptation;
import com.volmit.adapt.util.C;
import com.volmit.adapt.util.Element;
Expand All @@ -36,9 +35,7 @@
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.*;

public class AxeLeafVeinminer extends SimpleAdaptation<AxeLeafVeinminer.Config> {
public AxeLeafVeinminer() {
Expand Down Expand Up @@ -88,22 +85,19 @@ public void on(BlockBreakEvent e) {
if (isLeaves(new ItemStack(e.getBlock().getType()))) {
Block block = e.getBlock();
Map<Location, Block> blockMap = new HashMap<>();
blockMap.put(block.getLocation(), block);

for (int i = 0; i < getRadius(getLevel(p)); i++) {
for (int x = -i; x <= i; x++) {
for (int y = -i; y <= i; y++) {
for (int z = -i; z <= i; z++) {
Block b = block.getRelative(x, y, z);
if (b.getType() == block.getType()) {
if (block.getLocation().distance(b.getLocation()) > getRadius(getLevel(p))) {
continue;
}
if (!canBlockBreak(p, b.getLocation())) {
Adapt.verbose("Player " + p.getName() + " doesn't have permission.");
continue;
}
blockMap.put(b.getLocation(), b);
Deque<Block> stack = new LinkedList<>();
stack.push(block);
int radius = getRadius(getLevel(p));
while (!stack.isEmpty() && blockMap.size() < radius) {
Block currentBlock = stack.pop();
if (blockMap.containsKey(currentBlock.getLocation())) continue;
blockMap.put(currentBlock.getLocation(), currentBlock);
for (int x = -1; x <= 1; x++) {
for (int y = -1; y <= 1; y++) {
for (int z = -1; z <= 1; z++) {
Block b = currentBlock.getRelative(x, y, z);
if (b.getType() == block.getType() && currentBlock.getLocation().distance(b.getLocation()) <= radius && canBlockBreak(p, b.getLocation())) {
stack.push(b);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,17 @@ public void on(InventoryClickEvent e) {


private boolean validateArmor(ItemStack item) {
if (item.getItemMeta() != null && item.getItemMeta().getLore() != null && item.getItemMeta().getLore().get(0) != null) {
return (item.getItemMeta().getLore().get(0).contains("MultiArmor"));
} else {
return false;
if (item.getItemMeta() != null && item.getItemMeta().getLore() != null) {
for (String lore : item.getItemMeta().getLore()) {
if (lore != null && lore.contains("MultiArmor")) {
return true;
}
}
}
return false;
}


private double getSlots(double level) {
return getConfig().startingSlots + level;
}
Expand Down

0 comments on commit 65c01a2

Please sign in to comment.