-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better bleed effects, fixed some barrier logic, added riptide effect,…
… adding flying condition, adding libs disguises soundgroups
- Loading branch information
1 parent
d503904
commit 6f41323
Showing
29 changed files
with
442 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/java/land/face/strife/data/conditions/FlyingCondition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
src/main/java/land/face/strife/data/effects/Riptide.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
package land.face.strife.data.effects; | ||
|
||
import com.comphenix.protocol.PacketType; | ||
import com.comphenix.protocol.ProtocolLibrary; | ||
import com.comphenix.protocol.events.PacketContainer; | ||
import com.comphenix.protocol.wrappers.WrappedDataWatcher; | ||
import java.util.Iterator; | ||
import java.util.Map; | ||
import java.util.WeakHashMap; | ||
import land.face.strife.StrifePlugin; | ||
import land.face.strife.data.StrifeMob; | ||
import lombok.Setter; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.LivingEntity; | ||
import org.bukkit.scheduler.BukkitTask; | ||
|
||
public class Riptide extends Effect { | ||
|
||
public static Object RIPTIDE_POSE_ENUM = null; | ||
public static Object STANDING_POSE_ENUM = null; | ||
private static Map<LivingEntity, Integer> RIPTIDE_MAP = new WeakHashMap<>(); | ||
private static BukkitTask TASK = null; | ||
|
||
@Setter | ||
private int ticks; | ||
|
||
@Override | ||
public void apply(StrifeMob caster, StrifeMob target) { | ||
if (RIPTIDE_POSE_ENUM == null || STANDING_POSE_ENUM == null) { | ||
return; | ||
} | ||
RIPTIDE_MAP.put(target.getEntity(), ticks); | ||
try { | ||
PacketContainer fakeSpin = ProtocolLibrary.getProtocolManager() | ||
.createPacket(PacketType.Play.Server.ENTITY_METADATA); | ||
|
||
WrappedDataWatcher w = WrappedDataWatcher.getEntityWatcher(target.getEntity()); | ||
w.setObject(6, RIPTIDE_POSE_ENUM); | ||
w.setObject(7, (byte) 4); | ||
|
||
fakeSpin.getWatchableCollectionModifier().write(0, w.getWatchableObjects()); | ||
|
||
ProtocolLibrary.getProtocolManager().broadcastServerPacket(fakeSpin); | ||
} catch (Exception e) { | ||
sendCancelPacket(target.getEntity()); | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
private static void tickRiptide() { | ||
Iterator<LivingEntity> iterator = RIPTIDE_MAP.keySet().iterator(); | ||
while (iterator.hasNext()) { | ||
LivingEntity le = iterator.next(); | ||
if (!le.isValid()) { | ||
Bukkit.getLogger().info("CANCELED INVALID"); | ||
sendCancelPacket(le); | ||
continue; | ||
} | ||
if (le.getVelocity().getY() < 0.1 && le.isOnGround()) { | ||
Bukkit.getLogger().info("CANCELED GROUND"); | ||
continue; | ||
} | ||
if (RIPTIDE_MAP.get(le) < 1) { | ||
Bukkit.getLogger().info("CANCELED TIMEOUT"); | ||
sendCancelPacket(le); | ||
continue; | ||
} | ||
RIPTIDE_MAP.put(le, RIPTIDE_MAP.get(le) - 1); | ||
} | ||
} | ||
|
||
public static boolean isRiptideAnimationPlaying(LivingEntity target) { | ||
return RIPTIDE_MAP.containsKey(target); | ||
} | ||
|
||
public static void sendCancelPacket(LivingEntity target) { | ||
RIPTIDE_MAP.remove(target); | ||
try { | ||
PacketContainer restoreStanding = ProtocolLibrary.getProtocolManager() | ||
.createPacket(PacketType.Play.Server.ENTITY_METADATA); | ||
|
||
WrappedDataWatcher w = WrappedDataWatcher.getEntityWatcher(target); | ||
w.setObject(6, STANDING_POSE_ENUM); | ||
w.setObject(7, (byte) 0); | ||
|
||
restoreStanding.getWatchableCollectionModifier().write(0, w.getWatchableObjects()); | ||
|
||
ProtocolLibrary.getProtocolManager().broadcastServerPacket(restoreStanding); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public static void startTask(StrifePlugin plugin) { | ||
if (TASK != null) { | ||
TASK.cancel(); | ||
} | ||
if (TASK == null || TASK.isCancelled()) { | ||
TASK = Bukkit.getScheduler().runTaskTimer(plugin, Riptide::tickRiptide, 200L, 2L); | ||
} | ||
} | ||
|
||
public static void buildNMSEnum(StrifePlugin plugin) { | ||
try { | ||
RIPTIDE_POSE_ENUM = StrifePlugin.getNMSClass("EntityPose", plugin) | ||
.getField("SPIN_ATTACK").get(null); | ||
STANDING_POSE_ENUM = StrifePlugin.getNMSClass("EntityPose", plugin) | ||
.getField("STANDING").get(null); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.