-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Modify knockback * Fix infected bugs * /maps [gamemode] * Other MISC changes
- Loading branch information
BennyDoesStuff
committed
Aug 23, 2019
1 parent
3c274be
commit 14868a2
Showing
13 changed files
with
245 additions
and
165 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
50 changes: 50 additions & 0 deletions
50
TGM/src/main/java/network/warzone/tgm/modules/KnockbackModule.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,50 @@ | ||
package network.warzone.tgm.modules; | ||
|
||
import network.warzone.tgm.match.MatchModule; | ||
import org.bukkit.entity.*; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.entity.EntityDamageByEntityEvent; | ||
import org.bukkit.event.entity.EntityDamageEvent; | ||
import org.bukkit.event.entity.ProjectileLaunchEvent; | ||
import org.bukkit.projectiles.ProjectileSource; | ||
import org.bukkit.util.Vector; | ||
|
||
public class KnockbackModule extends MatchModule implements Listener { | ||
|
||
@EventHandler | ||
public void onEntityDamage(EntityDamageByEntityEvent event) { | ||
if (event.getDamager() instanceof Arrow) { | ||
Entity e = event.getEntity(); | ||
Arrow arrow = (Arrow) event.getDamager(); | ||
event.setDamage(event.getDamage() / 2.5); | ||
addVelocity(e, arrow.getVelocity().normalize().multiply(0.45f)); | ||
} | ||
|
||
if (event.getCause() == EntityDamageEvent.DamageCause.ENTITY_ATTACK && event.getDamager() instanceof LivingEntity && event.getEntity() instanceof Player) { | ||
applyKnockback((LivingEntity) event.getDamager(), (Player) event.getEntity()); | ||
} | ||
} | ||
|
||
@EventHandler | ||
public void onArrowsShoot(ProjectileLaunchEvent e) { | ||
Projectile projectile = e.getEntity(); //Getting the projectile | ||
ProjectileSource shooter = projectile.getShooter(); //Getting the shooter | ||
if (shooter instanceof Player) { //If the shooter was a player | ||
Player player = (Player) shooter; | ||
//Here we get a unit vector of the direction the player is looking in and multiply it by the projectile's vector's magnitude | ||
//We then assign this to the projectile as its new velocity | ||
projectile.setVelocity(player.getLocation().getDirection().normalize().multiply(projectile.getVelocity().length())); | ||
} | ||
} | ||
|
||
private void applyKnockback(LivingEntity attacker, Player victim) { | ||
Vector kb = attacker.getLocation().getDirection().setY(0).normalize().multiply(0.65f); | ||
victim.setVelocity(kb); | ||
} | ||
|
||
private void addVelocity(Entity e, Vector v) { | ||
e.setVelocity(e.getVelocity().add(v)); | ||
} | ||
|
||
} |
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
36 changes: 0 additions & 36 deletions
36
TGM/src/main/java/network/warzone/tgm/modules/infection/InfectedTimeLimit.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.