Skip to content

Commit

Permalink
Max ammo now replenishes grenades #60
Browse files Browse the repository at this point in the history
Fixed an issue with removing signs #73
Fixed leaderbaords being in wrong order
Fixed Mystery Box giving the player a duplicate gun #65
Fixed other players being able to collect other players Mystery box guns #64
Last Hell hound now drops a max ammo #63
Hell Hound kills no longer count towards the players zombie kill count
Fixed a bug when the M1911 is not a valid gun
Guns can now shoot through barriers
Changed the PlaceholderAPI Indetifier
Misc Changes
  • Loading branch information
TheTurkeyDev committed Feb 23, 2021
1 parent 2f53819 commit 5be0052
Show file tree
Hide file tree
Showing 23 changed files with 216 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void clearAllSetup()
activeActions.clear();
}

public static final String CONSOLE_PREFIX = "[CoM: Zombies] ";
public static final String CONSOLE_PREFIX = "[COM_Zombies] ";
public static final String PREFIX = ChatColor.RED + "[ " + ChatColor.GOLD + ChatColor.ITALIC + "CoM: Zombies" + ChatColor.RED + " ]" + ChatColor.GRAY + " ";

public static INMSUtil nmsUtil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public boolean onCommand(Player player, String[] args)
if(gm.players.get(i).getName().equalsIgnoreCase(player.getName()))
{
gm.removePlayer(player);
CommandUtil.sendMessageToPlayer(player, ChatColor.GOLD + "You have left the game leaving " + gm.players.size() + " people in the game!");
CommandUtil.sendMessageToPlayer(player, ChatColor.GOLD + "You have left the game!");
return true;
}
}
Expand Down
42 changes: 27 additions & 15 deletions Core/src/main/java/com/theprogrammingturkey/comz/game/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.theprogrammingturkey.comz.game.actions.BaseAction;
import com.theprogrammingturkey.comz.game.features.Door;
import com.theprogrammingturkey.comz.game.features.DownedPlayer;
import com.theprogrammingturkey.comz.game.features.PowerUp;
import com.theprogrammingturkey.comz.game.features.RandomBox;
import com.theprogrammingturkey.comz.game.managers.*;
import com.theprogrammingturkey.comz.game.weapons.BaseGun;
Expand All @@ -37,15 +38,7 @@
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Mob;
import org.bukkit.entity.Painting;
import org.bukkit.entity.Player;
import org.bukkit.entity.Zombie;
import org.bukkit.entity.*;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffectType;
Expand Down Expand Up @@ -1153,7 +1146,7 @@ public boolean isFireSale()

public void damageMob(Mob mob, Player player, float damageAmount)
{
double zombHealth = mob.getHealth() - damageAmount;
double mobHealth = mob.getHealth() - damageAmount;
mob.playEffect(EntityEffect.HURT);

if(isInstaKill())
Expand All @@ -1172,11 +1165,18 @@ public void damageMob(Mob mob, Player player, float damageAmount)

PointManager.notifyPlayer(player);
spawnManager.removeEntity(mob);
zombieKilled(player);

if(mob instanceof Zombie)
zombieKilled(player);

if(spawnManager.getEntities().size() <= 0)
{
if(mob instanceof Wolf)
powerUpManager.dropPowerUp(mob, PowerUp.MAX_AMMO);
nextWave();
}
}
else if(zombHealth < 1)
else if(mobHealth < 1)
{
if(mob instanceof Zombie)
player.getWorld().playSound(mob.getLocation(), Sound.ENTITY_ZOMBIE_DEATH, 1f, 1f);
Expand All @@ -1192,13 +1192,20 @@ else if(zombHealth < 1)

PointManager.notifyPlayer(player);
spawnManager.removeEntity(mob);
zombieKilled(player);

if(mob instanceof Zombie)
zombieKilled(player);

if(spawnManager.getEntities().size() <= 0)
{
if(mob instanceof Wolf)
powerUpManager.dropPowerUp(mob, PowerUp.MAX_AMMO);
nextWave();
}
}
else
{
mob.setHealth(zombHealth);
mob.setHealth(mobHealth);
if(mob instanceof Zombie)
player.getWorld().playSound(mob.getLocation(), Sound.ENTITY_ZOMBIE_HURT, 1f, 1f);
else
Expand All @@ -1213,7 +1220,7 @@ else if(zombHealth < 1)

if(debugMode)
{
mob.setCustomName(String.valueOf(zombHealth));
mob.setCustomName(String.valueOf(mobHealth));
mob.setCustomNameVisible(true);
}
else
Expand Down Expand Up @@ -1289,6 +1296,11 @@ public int getDogRoundEveryX()
return dogRoundEveryX;
}

public String getStartingGun()
{
return startingGun;
}

public void zombieKilled(Player player)
{
Leaderboard.getPlayerStatFromPlayer(player).incKills();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void setPlayerDown(boolean isDowned)
guns[0] = manager.removeGun(1);
guns[1] = manager.removeGun(2);
manager.removeGun(3);
manager.addGun(new GunInstance(WeaponManager.getGun("M1911"), player, 1));
manager.addGun(new GunInstance(WeaponManager.getGun(game.getStartingGun()), player, 1));
player.setGameMode(GameMode.CREATIVE);
player.setAllowFlight(false);
scheduleTask();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public class RandomBox
private String boxId;
private int boxCost;

private Player openedBy;

private boolean running;
private boolean gunSelected;
private boolean isTeddyBear;
Expand Down Expand Up @@ -82,11 +84,13 @@ public void Start(final Player player, int PointsNeeded)
}
}

openedBy = player;

if(chestLocation != null)
COMZombies.nmsUtil.playChestAction(chestLocation, true);

running = true;
weapon = WeaponManager.getRandomWeapon(false);
weapon = WeaponManager.getRandomWeapon(false, boxGame.getPlayersGun(player));
Location itemLoc;

if(chestLocation != null)
Expand Down Expand Up @@ -118,7 +122,7 @@ public void run()
{
if(time > 0)
{
weapon = WeaponManager.getRandomWeapon(false);
weapon = WeaponManager.getRandomWeapon(false, boxGame.getPlayersGun(player));
item.setItemStack(new ItemStack(weapon.getMaterial()));
namePlate.setCustomName(weapon.getName());
player.getWorld().playSound(boxLoc, Sound.BLOCK_NOTE_BLOCK_HARP, 1f, 1f);
Expand Down Expand Up @@ -176,9 +180,9 @@ public boolean canActivate()
return !this.running;
}

public boolean canPickWeapon()
public boolean canPickWeapon(Player player)
{
return this.gunSelected;
return player.equals(openedBy) && this.gunSelected;
}

public void pickUpWeapon(Player player)
Expand All @@ -203,7 +207,7 @@ public void reset()
Bukkit.getScheduler().cancelTask(id);
running = false;

if( !boxGame.boxManager.isMultiBox() && !boxGame.isFireSale() && boxGame.boxManager.getCurrentbox() != this)
if(!boxGame.boxManager.isMultiBox() && !boxGame.isFireSale() && boxGame.boxManager.getCurrentbox() != this)
this.removeBox();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.theprogrammingturkey.comz.COMZombies;
import com.theprogrammingturkey.comz.config.ConfigManager;
import com.theprogrammingturkey.comz.config.CustomConfig;
import com.theprogrammingturkey.comz.game.Game;
import com.theprogrammingturkey.comz.game.GameManager;
import com.theprogrammingturkey.comz.game.features.RandomBox;
import com.theprogrammingturkey.comz.util.BlockUtils;
import com.theprogrammingturkey.comz.util.Util;
import com.theprogrammingturkey.comz.config.COMZConfig;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.block.BlockFace;
Expand Down Expand Up @@ -115,7 +113,6 @@ public void removeBox(Player player, RandomBox box)

public void addBox(RandomBox box)
{
CustomConfig conf = ConfigManager.getConfig(COMZConfig.ARENAS);
if(game.getMode() == Game.ArenaStatus.DISABLED || game.getMode() == Game.ArenaStatus.WAITING)
{
boolean same = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
package com.theprogrammingturkey.comz.game.managers;

import com.theprogrammingturkey.comz.game.features.PerkType;
import com.theprogrammingturkey.comz.game.weapons.BasicGun;
import com.theprogrammingturkey.comz.game.weapons.GunInstance;
import com.theprogrammingturkey.comz.game.Game;
import com.theprogrammingturkey.comz.game.GameManager;
import com.theprogrammingturkey.comz.game.features.PerkType;
import com.theprogrammingturkey.comz.game.weapons.BaseGun;
import com.theprogrammingturkey.comz.game.weapons.GunInstance;
import com.theprogrammingturkey.comz.game.weapons.Weapon;
import org.bukkit.ChatColor;
import com.theprogrammingturkey.comz.game.weapons.WeaponInstance;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

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

public class PlayerWeaponManager
{
private List<GunInstance> guns = new ArrayList<>();
private List<WeaponInstance> weapons = new ArrayList<>();
private Player player;

public PlayerWeaponManager(Player player)
Expand Down Expand Up @@ -111,25 +111,15 @@ else if(!game.perkManager.hasPerk(player, PerkType.MULE_KICK) && tempSlot == 3)
public void addWeapon(Weapon weapon)
{
int slot = this.getCorrectSlot(weapon);
if(slot >= 1 && slot <= 3 && weapon instanceof BasicGun)
if(slot >= 1 && slot <= 3 && weapon instanceof BaseGun)
{
removeGun(getGun(slot));
addGun(new GunInstance((BasicGun) weapon, player, slot));
addGun(new GunInstance((BaseGun) weapon, player, slot));
}
else if(slot == 8)
{
int amount = 4;
ItemStack current = player.getInventory().getItem(slot);
if(current != null && current.getType().equals(weapon.getMaterial()))
amount += current.getAmount();

ItemStack newStack = new ItemStack(weapon.getMaterial(), amount);
ItemMeta data = newStack.getItemMeta();
if(data != null)
data.setDisplayName(ChatColor.DARK_GREEN + "" + weapon.getName());
newStack.setItemMeta(data);

player.getInventory().setItem(slot, newStack);
weapons.remove(getWeapon(slot));
addWeapon(new WeaponInstance(weapon, player, slot));
}

player.updateInventory();
Expand All @@ -148,6 +138,19 @@ public void addGun(GunInstance gun)
player.updateInventory();
}

/**
* Adds a weapon to the array list of weapons
*
* @param weapon : Weapon to add
*/
public void addWeapon(WeaponInstance weapon)
{
if(weapon == null)
return;
weapons.add(weapon);
player.updateInventory();
}

/**
* Used to check if the item the player is holding is a gun
*
Expand Down Expand Up @@ -175,6 +178,14 @@ public GunInstance getGun(int slot)
return null;
}

public WeaponInstance getWeapon(int slot)
{
for(WeaponInstance weapon : weapons)
if(weapon.getSlot() == slot)
return weapon;
return null;
}

/**
* Used to remove a gun from the guns list if contained.
*
Expand All @@ -193,11 +204,19 @@ public GunInstance removeGun(int slot)
return null;
}

public boolean hasGun(BasicGun gun)
public boolean hasGun(BaseGun gun)
{
for(GunInstance g : guns)
if(g.getType().equals(gun))
return true;
return false;
}

public void maxAmmo()
{
for(WeaponInstance weapon : weapons)
weapon.maxAmmo();
for(GunInstance gun : guns)
gun.maxAmmo();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,12 @@ public void powerUpDrop(Entity mob, Entity entPlayer)
if(game.boxManager.isMultiBox())
availableRewards.remove(PowerUp.FIRE_SALE);

int randomPerk = COMZombies.rand.nextInt(availableRewards.size());

PowerUp powerUp = availableRewards.get(randomPerk);
dropItem(mob, new ItemStack(powerUp.getMaterial(), 1));
this.dropPowerUp(mob, availableRewards.get(COMZombies.rand.nextInt(availableRewards.size())));
}
}

public void dropPowerUp(Entity mob, PowerUp powerUp)
{
dropItem(mob, new ItemStack(powerUp.getMaterial(), 1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ public void addSign(Sign sign)
save();
}

public void removeSign(Sign sign)
{
gameSigns.remove(sign);
save();
}

public boolean isSign(Sign sign)
{
return gameSigns.contains(sign);
Expand Down

0 comments on commit 5be0052

Please sign in to comment.