Skip to content

Commit

Permalink
Merge pull request #29 from PixelOutlaw/develop
Browse files Browse the repository at this point in the history
Merging Develop
  • Loading branch information
UltraFaceguy authored Aug 6, 2021
2 parents daa449c + 6f41323 commit c8bb7b1
Show file tree
Hide file tree
Showing 31 changed files with 470 additions and 140 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</parent>

<artifactId>strife</artifactId>
<version>3.4.4</version>
<version>3.4.5</version>
<packaging>jar</packaging>

<name>strife</name>
Expand Down Expand Up @@ -109,7 +109,7 @@
<dependency>
<groupId>LibsDisguises</groupId>
<artifactId>LibsDisguises</artifactId>
<version>10.0.16-SNAPSHOT</version>
<version>10.0.26-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
55 changes: 55 additions & 0 deletions src/main/java/land/face/strife/StrifePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ The MIT License Copyright (c) 2015 Teal Cube Games
*/
package land.face.strife;

import static com.comphenix.protocol.PacketType.Play.Server.ENTITY_METADATA;

import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.reflect.StructureModifier;
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
import com.comphenix.xp.lookup.LevelingRate;
import com.tealcube.minecraft.bukkit.facecore.logging.PluginLogger;
import com.tealcube.minecraft.bukkit.facecore.plugin.FacePlugin;
Expand Down Expand Up @@ -51,6 +58,7 @@ The MIT License Copyright (c) 2015 Teal Cube Games
import land.face.strife.data.UniqueEntity;
import land.face.strife.data.ability.Ability;
import land.face.strife.data.champion.LifeSkillType;
import land.face.strife.data.effects.Riptide;
import land.face.strife.data.effects.ShootBlock;
import land.face.strife.data.effects.TriggerLoreAbility;
import land.face.strife.hooks.SnazzyPartiesHook;
Expand Down Expand Up @@ -153,8 +161,11 @@ The MIT License Copyright (c) 2015 Teal Cube Games
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitTask;

public class StrifePlugin extends FacePlugin {
Expand Down Expand Up @@ -537,6 +548,37 @@ public void enable() {

DamageUtil.refresh();

Riptide.buildNMSEnum(this);
Riptide.startTask(this);

ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this, ENTITY_METADATA) {
public void onPacketSending(PacketEvent event) {
try {
int entityId = event.getPacket().getIntegers().read(0);
if (entityId < 0) {
return;
}
Entity entity = event.getPacket()
.getEntityModifier(event.getPlayer().getWorld()).read(0);
if (entity instanceof LivingEntity && Riptide
.isRiptideAnimationPlaying((LivingEntity) entity)) {
StructureModifier<List<WrappedWatchableObject>> watcher = event.getPacket()
.getWatchableCollectionModifier();
for (WrappedWatchableObject watch : watcher.read(0)) {
if (watch.getIndex() == 6) {
watch.setValue(Riptide.RIPTIDE_POSE_ENUM);
}
if (watch.getIndex() == 7) {
watch.setValue((byte) 4);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
});

LogUtil.printInfo("Loaded " + uniqueEntityManager.getLoadedUniquesMap().size() + " mobs");
LogUtil.printInfo("Loaded " + effectManager.getLoadedEffects().size() + " effects");
LogUtil.printInfo("Loaded " + abilityManager.getLoadedAbilities().size() + " abilities");
Expand All @@ -552,6 +594,7 @@ public void disable() {
entityHider.close();
HandlerList.unregisterAll(this);
Bukkit.getScheduler().cancelTasks(this);
ProtocolLibrary.getProtocolManager().removePacketListeners(this);

strifeMobManager.despawnAllTempEntities();
bossBarManager.clearBars();
Expand Down Expand Up @@ -579,6 +622,18 @@ public void disable() {
LogUtil.printInfo("Successfully disabled Strife-v" + getDescription().getVersion());
}

public static Class<?> getNMSClass(String name, Plugin plugin) {
String version = plugin.getServer().getClass().getPackage().getName().split("\\.")[3];
try {
return Class.forName("net.minecraft.server." + version + "." + name);
}

catch (ClassNotFoundException e) {
e.printStackTrace();
return null;
}
}

private VersionedSmartYamlConfiguration defaultSettingsLoad(String name) {
return new VersionedSmartYamlConfiguration(new File(getDataFolder(), name),
getResource(name), VersionedConfiguration.VersionUpdateType.BACKUP_AND_UPDATE);
Expand Down
41 changes: 27 additions & 14 deletions src/main/java/land/face/strife/data/champion/Champion.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import land.face.strife.StrifePlugin;
import land.face.strife.data.CombatDetailsContainer;
import land.face.strife.managers.StatUpdateManager;
import land.face.strife.stats.StrifeStat;
import land.face.strife.stats.StrifeTrait;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;

public class Champion {
Expand Down Expand Up @@ -116,10 +118,10 @@ public int getPendingLevel(StrifeAttribute stat) {
}

public void buildAttributeHeatmap() {
float red = 0;
float yellow = 0;
float green = 0;
float blue = 0;
int red = 0;
int yellow = 0;
int green = 0;
int blue = 0;
for (StrifeAttribute attribute : getLevelMap().keySet()) {
switch (attribute.getKey()) {
case "str":
Expand All @@ -136,15 +138,27 @@ public void buildAttributeHeatmap() {
break;
}
}
float total = red + yellow + green + blue;
red = red / total;
yellow = yellow / total;
green = green / total;
blue = blue / total;
attributeHeatmap = IntStream.range(0, (int) (red * 8)).mapToObj(i -> "⬤").toString() +
IntStream.range(0, (int) (yellow * 8)).mapToObj(i -> "⬤") +
IntStream.range(0, (int) (green * 8)).mapToObj(i -> "⬤") +
IntStream.range(0, (int) (blue * 8)).mapToObj(i -> "⬤");
float total = Math.max(1, red + yellow + green + blue);
int segments = 40 - player.getName().length();

int redSegments = (int) Math.ceil((float) segments * (float) red / total);
total -= red;
segments -= redSegments;

int yellowSegments = (int) Math.floor((float) segments * (float) yellow / total);
total -= yellow;
segments -= yellowSegments;

int greenSegments = (int) Math.ceil((float) segments * (float) green / total);
segments -= greenSegments;

int blueSegments = segments;

attributeHeatmap =
ChatColor.RED + IntStream.range(0, redSegments).mapToObj(i -> "▌").collect(Collectors.joining()) +
ChatColor.YELLOW + IntStream.range(0, yellowSegments).mapToObj(i -> "▌").collect(Collectors.joining()) +
ChatColor.GREEN + IntStream.range(0, greenSegments).mapToObj(i -> "▌").collect(Collectors.joining()) +
ChatColor.BLUE + IntStream.range(0, blueSegments).mapToObj(i -> "▌").collect(Collectors.joining());
}

public String getAttributeHeatmap() {
Expand Down Expand Up @@ -181,7 +195,6 @@ public int getUnusedStatPoints() {

public void setUnusedStatPoints(int unusedStatPoints) {
saveData.setUnusedStatPoints(unusedStatPoints);
buildAttributeHeatmap();
}

public int getPendingUnusedStatPoints() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
public enum LifeSkillType {

CRAFTING("Crafting", "crafting", ChatColor.YELLOW),
ENCHANTING("Enchanting", "enchant", ChatColor.of(new Color(128, 93, 255))),
ENCHANTING("Enchanting", "enchant", ChatColor.of(new Color(113, 79, 236))),
FISHING("Fishing", "fishing", ChatColor.AQUA),
MINING("Mining", "mining", ChatColor.DARK_GREEN),
FARMING("Gathering", "farming", ChatColor.of(new Color(255, 192, 87))),
Expand All @@ -15,6 +15,7 @@ public enum LifeSkillType {
SNEAK("Sneak", "sneak", ChatColor.GRAY),
AGILITY("Agility", "agility", ChatColor.DARK_AQUA),
TRADING("Trading", "trading", ChatColor.DARK_GREEN),
FLYING("Flying", "flying", ChatColor.of(new Color(114, 187, 255))),
SWORDSMANSHIP("Swordsmanship", "sword", ChatColor.RED, true),
DAGGER_MASTERY("Dagger Mastery", "dagger", ChatColor.of(new Color(204, 246, 102)), true),
AXE_MASTERY("Axe Mastery", "axe", ChatColor.RED, true),
Expand Down Expand Up @@ -61,7 +62,7 @@ public ChatColor getColor() {
return color;
}

public boolean isComnbat() {
public boolean isCombat() {
return combat;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public enum ConditionType {
ENTITY_TYPE,
UNIQUE_ID,
FACTION_MEMBER,
FLYING,
VELOCITY,
GROUNDED,
BLEEDING,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package land.face.strife.data.conditions;

import land.face.strife.data.StrifeMob;

public class FlyingCondition extends Condition {

public boolean isMet(StrifeMob attacker, StrifeMob target) {
if (getCompareTarget() == CompareTarget.SELF) {
target = attacker;
}
return target.getEntity().isGliding();
}
}
2 changes: 1 addition & 1 deletion src/main/java/land/face/strife/data/effects/Damage.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void apply(StrifeMob caster, StrifeMob target) {
mods.setApplyOnHitEffects(applyOnHitEffects);
mods.setShowPopoffs(showPopoffs);
mods.setBypassBarrier(bypassBarrier);
mods.setScaleChancesWithAttack(true);
mods.setScaleChancesWithAttack(false);
if (canSneakAttack && caster.getEntity() instanceof Player && getPlugin().getStealthManager()
.canSneakAttack((Player) caster.getEntity())) {
mods.setSneakAttack(true);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/land/face/strife/data/effects/Effect.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public enum EffectType {
RESTORE_ENERGY,
INCREASE_RAGE,
PROJECTILE,
RIPTIDE,
EQUIPMENT_SWAP,
EVOKER_FANGS,
FALLING_BLOCK,
Expand Down
49 changes: 34 additions & 15 deletions src/main/java/land/face/strife/data/effects/Push.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package land.face.strife.data.effects;

import com.tealcube.minecraft.bukkit.shade.apache.commons.lang3.StringUtils;
import land.face.strife.data.StrifeMob;
import land.face.strife.util.LogUtil;
import org.bukkit.craftbukkit.libs.org.apache.commons.lang3.StringUtils;
import lombok.Setter;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.util.Vector;
Expand All @@ -13,6 +14,8 @@ public class Push extends Effect {
private double height;
private boolean cancelFall;
private boolean clamp;
@Setter
private boolean uncheckedHeight;
private PushType pushType;
private Vector tempVector;

Expand All @@ -32,19 +35,22 @@ public void apply(StrifeMob caster, StrifeMob target) {
direction = getEffectVelocity(caster.getEntity().getLocation().toVector(), target.getEntity());
break;
case CASTER_DIRECTION:
Vector casterDir = caster.getEntity().getLocation().getDirection();
if (casterDir.getX() == 0 && casterDir.getZ() == 0) {
direction = new Vector(power / 10, 0, 0);
} else {
direction = casterDir.setY(0).normalize().multiply(power / 10);
direction = caster.getEntity().getLocation().getDirection();
if (!uncheckedHeight) {
direction.setY(0.001);
}
direction.normalize().multiply(power / 10);
break;
case TEMP_DIRECTION:
LogUtil.printDebug(tempVector.getX() + " " + tempVector.getY() + " " + tempVector.getZ());
direction = getEffectVelocity(tempVector, target.getEntity());
break;
case WSE_DIRECTION:
direction = tempVector.clone().setY(0.001).normalize().multiply(power / 10);
direction = tempVector.clone();
if (!uncheckedHeight) {
direction.setY(0.001);
}
direction.normalize().multiply(power / 10);
break;
default:
return;
Expand All @@ -57,13 +63,23 @@ public void apply(StrifeMob caster, StrifeMob target) {
}
target.getEntity().setFallDistance(0);
}
if (clamp) {
newVelocity.setX(clampRay(oldVelocity.getX(), direction.getX()));
newVelocity.setY(clampRay(oldVelocity.getY(), height / 10));
newVelocity.setZ(clampRay(oldVelocity.getZ(), direction.getZ()));
if (uncheckedHeight) {
if (clamp) {
newVelocity.setX(clampRay(oldVelocity.getX(), direction.getX()));
newVelocity.setY(clampRay(oldVelocity.getY(), direction.getY()));
newVelocity.setZ(clampRay(oldVelocity.getZ(), direction.getZ()));
} else {
newVelocity.add(direction);
}
} else {
newVelocity.add(direction);
newVelocity.add(new Vector(0, height / 10, 0));
if (clamp) {
newVelocity.setX(clampRay(oldVelocity.getX(), direction.getX()));
newVelocity.setY(clampRay(oldVelocity.getY(), height / 10));
newVelocity.setZ(clampRay(oldVelocity.getZ(), direction.getZ()));
} else {
newVelocity.add(direction);
newVelocity.add(new Vector(0, height / 10, 0));
}
}
target.getEntity().setVelocity(newVelocity);
}
Expand Down Expand Up @@ -91,8 +107,11 @@ private Vector getEffectVelocity(Vector originLocation, Entity to) {
if (originLocation.equals(to.getLocation().toVector())) {
return new Vector(0, power / 10, 0);
}
return to.getLocation().toVector().subtract(originLocation).setY(0.001).normalize()
.multiply(power / 10);
Vector velocity = to.getLocation().toVector().subtract(originLocation);
if (!uncheckedHeight) {
velocity.setY(0.001);
}
return velocity.normalize().multiply(power / 10);
}

public void setPower(double power) {
Expand Down
Loading

0 comments on commit c8bb7b1

Please sign in to comment.