Skip to content

Commit

Permalink
Merge pull request #86 from peacefulcraft-network/Class_Rework
Browse files Browse the repository at this point in the history
Class rework
  • Loading branch information
Parsonswy authored Jul 27, 2019
2 parents aa184dc + 4f6dfbc commit c0113b0
Show file tree
Hide file tree
Showing 39 changed files with 1,549 additions and 47 deletions.
4 changes: 4 additions & 0 deletions src/net/peacefulcraft/trenchpvp/TrenchPvP.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import net.peacefulcraft.trenchpvp.gamehandle.listeners.BlockIgnitionTimer;
import net.peacefulcraft.trenchpvp.gamehandle.listeners.ChangeClassSign;
import net.peacefulcraft.trenchpvp.gamehandle.listeners.ItemListener;
import net.peacefulcraft.trenchpvp.gamehandle.listeners.ItemSwitchListener;
import net.peacefulcraft.trenchpvp.gamehandle.listeners.JoinGameListen;
import net.peacefulcraft.trenchpvp.gamehandle.listeners.JoinGameSign;
import net.peacefulcraft.trenchpvp.gamehandle.listeners.LaunchPadUse;
Expand All @@ -31,6 +32,7 @@
import net.peacefulcraft.trenchpvp.gamehandle.listeners.PvPController;
import net.peacefulcraft.trenchpvp.gamehandle.listeners.QuitGameListen;
import net.peacefulcraft.trenchpvp.gamehandle.listeners.StartGameSign;
import net.peacefulcraft.trenchpvp.gamehandle.listeners.TNTIgnition;
import net.peacefulcraft.trenchpvp.gamehandle.tasks.Startgame;
import net.peacefulcraft.trenchpvp.gamehandle.tasks.SyncStats;
import net.peacefulcraft.trenchpvp.menu.listeners.KitMenu;
Expand Down Expand Up @@ -119,6 +121,8 @@ private void loadEventListners(){
getServer().getPluginManager().registerEvents(new PvPController(), this);
getServer().getPluginManager().registerEvents(new ItemListener(), this);
getServer().getPluginManager().registerEvents(new ArrowImpactListener(), this);
getServer().getPluginManager().registerEvents(new TNTIgnition(), this);
getServer().getPluginManager().registerEvents(new ItemSwitchListener(), this);

//new gameclasses.listeners
getServer().getPluginManager().registerEvents(new AbilityClickListener(), this);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package net.peacefulcraft.trenchpvp.gameclasses.abilities;

import java.util.ArrayList;
import java.util.List;

import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

import net.peacefulcraft.trenchpvp.TrenchPvP;
import net.peacefulcraft.trenchpvp.gameclasses.classConfigurations.TrenchKit;

public class BuildTimer extends TrenchAbility
{
private TrenchKit k;
private final int EFFECT_TIME = 400;

public BuildTimer(TrenchKit k)
{
super(k.getTrenchPlayer(), 20000, "Build Timer");

this.k=k;
}

@Override
public boolean abilitySignature(Event ev)
{
Player p = k.getTrenchPlayer().getPlayer();

if(!(p.getInventory().getItemInMainHand().getType() == Material.CLOCK)) { return false; }
if(!(p.getInventory().getItemInMainHand().getItemMeta().getDisplayName().equals("Build Timer"))) { return false; }

return true;
}

@Override
public void triggerAbility(Event ev)
{
Player p = k.getTrenchPlayer().getPlayer();

ArrayList<Player> lightning = new ArrayList<Player>();
List<Entity> list = p.getNearbyEntities(4, 4, 4);
for(Entity e : list) {
if(e instanceof Player) {
Player vic = (Player) e;
vic.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, EFFECT_TIME, 2));
vic.addPotionEffect(new PotionEffect(PotionEffectType.POISON, EFFECT_TIME, 2));
vic.addPotionEffect(new PotionEffect(PotionEffectType.GLOWING, EFFECT_TIME, 2));
lightning.add(vic);
}
}
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(TrenchPvP.getPluginInstance(), new Runnable() {
public void run() {
for(Player v : lightning) {
Location loc = v.getLocation();
loc.getWorld().strikeLightning(loc);
if(v.getHealth() != 0) {
v.setHealth(v.getHealth() + 5);
}
}
}
}, 100);


}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package net.peacefulcraft.trenchpvp.gameclasses.abilities;

import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.util.Vector;

import net.peacefulcraft.trenchpvp.gameclasses.classConfigurations.TrenchKit;

public class CatastrophicRapier extends TrenchAbility
{
private TrenchKit k;

public CatastrophicRapier(TrenchKit k) {
super(k.getTrenchPlayer(), 40, "Catastrophic Rapier");

this.k = k;
}

@Override
public boolean abilitySignature(Event ev)
{
Player p = k.getTrenchPlayer().getPlayer();

if(!(p.getInventory().getItemInMainHand().getType() == Material.DIAMOND_SWORD)) { return false; }
if(!(p.getInventory().getItemInMainHand().getItemMeta().getDisplayName().equals("Catastrophic Rapier"))) { return false; }

return true;
}

@Override
public void triggerAbility(Event ev)
{
Player p = k.getTrenchPlayer().getPlayer();

Vector v = new Vector(p.getVelocity().getX(), p.getVelocity().getY(), p.getVelocity().getZ());
Vector forward = p.getLocation().getDirection().multiply(2);
v.add(forward);

p.setVelocity(v);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package net.peacefulcraft.trenchpvp.gameclasses.abilities;

import java.util.Random;

import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.player.PlayerMoveEvent;

import net.peacefulcraft.trenchpvp.TrenchPvP;
import net.peacefulcraft.trenchpvp.gameclasses.classConfigurations.TrenchKit;
import net.peacefulcraft.trenchpvp.gamehandle.TeamManager;
import net.peacefulcraft.trenchpvp.gamehandle.player.TrenchPlayer;

public class CommunityManagerDumbFoot extends TrenchAbility
{
private TrenchKit k;

public CommunityManagerDumbFoot(TrenchKit k)
{
super(k.getTrenchPlayer(), 0, "Community Manager's Dumb Foot");

this.k=k;
}
@Override
public boolean abilitySignature(Event ev)
{
try {

PlayerMoveEvent e = (PlayerMoveEvent) ev;
TrenchPlayer t = TeamManager.findTrenchPlayer(e.getPlayer());

}catch(ClassCastException ex) {

TrenchPvP.logWarning("Error Matching" + this.getClass() + " event. Incompatible event loop " + ev.getClass());
return false;

}

return true;
}
@Override
public void triggerAbility(Event ev)
{
try {
PlayerMoveEvent e = (PlayerMoveEvent) ev;
Player p = e.getPlayer();

Random rand = new Random();
if(rand.nextInt(100) <= 1) {
Location loc = p.getLocation();
loc.getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 1.0f, false, false);
}

}catch(ClassCastException ex) {

TrenchPvP.logWarning("Error Matching" + this.getClass() + " event. Incompatible event loop " + ev.getClass());
return;
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package net.peacefulcraft.trenchpvp.gameclasses.abilities;

import java.util.List;

import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

import net.peacefulcraft.trenchpvp.gameclasses.classConfigurations.TrenchKit;
import net.peacefulcraft.trenchpvp.gamehandle.TeamManager;
import net.peacefulcraft.trenchpvp.gamehandle.player.TrenchPlayer;

public class EntityUprising extends TrenchAbility
{
private TrenchKit k;

private final int EFFECT_TIME = 200; //20 ticks per second

public EntityUprising(TrenchKit k)
{
super(k.getTrenchPlayer(), 20000, "Entity Uprising");

this.k = k;
}

@Override
public boolean abilitySignature(Event ev)
{
Player p = k.getTrenchPlayer().getPlayer();

if(!(p.getInventory().getItemInMainHand().getType() == Material.WHITE_STAINED_GLASS)) { return false; }
if(!(p.getInventory().getItemInMainHand().getItemMeta().getDisplayName().equals("Entity Uprising"))) { return false; }

return true;
}

@Override
public void triggerAbility(Event ev)
{
TrenchPlayer t = k.getTrenchPlayer();
Player p = t.getPlayer();

List<Entity> levList = p.getNearbyEntities(5, 5, 5);
for(Entity e : levList) {
if(e instanceof Player) {
Player vic = (Player) e;
if(TeamManager.findTrenchPlayer(vic).getPlayerTeam() != t.getPlayerTeam()) {
vic.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION, EFFECT_TIME, 1));
vic.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, EFFECT_TIME, 4));
}
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class GrenadeLauncher extends TrenchAbility{
private TrenchKit k;

public GrenadeLauncher(TrenchKit k) {
super(k.getTrenchPlayer(), 1000, "Grenade Launcer");
super(k.getTrenchPlayer(), 1000, "Grenade Launcher");

this.k = k;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.peacefulcraft.trenchpvp.gameclasses.abilities;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -50,9 +51,15 @@ public void triggerAbility(Event ev) {
Player p = e.getPlayer();

p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, EFFECT_TIME - 40, 3));
p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, EFFECT_TIME, 2));
p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, EFFECT_TIME, 2));
p.sendMessage(ChatColor.RED + "Ability is now on cooldown for 16 seconds.");

Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(TrenchPvP.getPluginInstance(), new Runnable() {
public void run() {
p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, EFFECT_TIME, 3));
}
}, EFFECT_TIME);

}catch(ClassCastException ex) {
TrenchPvP.logWarning("Error Triggering " + this.getClass() + " event. Incompatible event loop " + ev.getClass());
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package net.peacefulcraft.trenchpvp.gameclasses.abilities;

import java.util.List;

import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;

import net.peacefulcraft.trenchpvp.gameclasses.classConfigurations.TrenchKit;

public class LonelyMansMic extends TrenchAbility
{
private TrenchKit k;
public LonelyMansMic(TrenchKit k)
{
super(k.getTrenchPlayer(), 15000, "Lonely Mans Mic");

this.k=k;
}

@Override
public boolean abilitySignature(Event ev)
{
Player p = k.getTrenchPlayer().getPlayer();

if(!(p.getInventory().getItemInMainHand().getType() == Material.LEVER)) { return false; }
if(!(p.getInventory().getItemInMainHand().getItemMeta().getDisplayName().equals("Lonely Mans Mic"))) { return false; }

return true;
}

@Override
public void triggerAbility(Event ev)
{
Player p = k.getTrenchPlayer().getPlayer();
Location loc = p.getLocation();

List<Entity> list = p.getNearbyEntities(4, 4, 4);
for(Entity e : list) {
if(e instanceof Player) {
Player vic = (Player) e;
Location t = vic.getLocation().subtract(loc);
double distance = vic.getLocation().distance(loc);

t.getDirection().normalize().multiply(-1);
t.multiply(distance/1.2);
t.multiply(2); //Change

vic.setVelocity(t.toVector());
}
}
}

}
Loading

0 comments on commit c0113b0

Please sign in to comment.