Skip to content

Commit

Permalink
Misc Changes (#471)
Browse files Browse the repository at this point in the history
* Modify knockback

* Fix infected bugs

* /maps [gamemode]

* Other MISC changes
  • Loading branch information
BennyDoesStuff committed Aug 23, 2019
1 parent 3c274be commit 14868a2
Show file tree
Hide file tree
Showing 13 changed files with 245 additions and 165 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![Minecraft Version](https://img.shields.io/badge/supports%20MC%20versions-1.13%20--%201.14.4-brightgreen.svg)
[![Build Status](https://jenkins.bennydoesstuff.me/buildStatus/icon?job=TGM)](https://jenkins.bennydoesstuff.me/job/TGM)
[![Discord](https://img.shields.io/badge/chat-on%20discord-blue.svg)](https://discord.io/WarzoneMC)
[![Discord](https://img.shields.io/badge/chat-on%20discord-blue.svg)](https://warz.one/discord)

# Warzone
Team Oriented Minecraft PVP Suite
Expand Down Expand Up @@ -39,18 +39,19 @@ As an example, a map should be able to provide different spawn points as the mat
]
```


## Local Server Setup

1. Start with the latest stable [Paper (PaperSpigot)](https://papermc.io/ci/job/Paper/) build.
1. Start with the latest stable [Paper (PaperSpigot)](https://papermc.io/downloads) build.

2. Compile the latest version of TGM or download it from our [Jenkins](https://jenkins.bennydoesstuff.me/job/TGM/).

3. Create a `Maps` folder inside of the server and insert a supported TGM map. You can also just clone our `Maps` repository as a folder.
3. Create a `Maps` folder in the root folder and insert a supported TGM map. Make sure you also include a rotation.txt with the maps you would like to be present in the rotation.
- You can download our Maps folder as a reference on the Maps repo located [here](https://github.com/WarzoneMC/Maps).

4. (Optional) Install WorldEdit to enable the Teleport Tool.

5. Start the server. If you want stats to save, you need to setup the API [here](https://github.com/WarzoneMC/api).
5. Start the server. If you would like stats to be saved, you need to setup the API [here](https://github.com/WarzoneMC/api).

## Developer Tips

Expand Down
29 changes: 26 additions & 3 deletions TGM/src/main/java/network/warzone/tgm/command/CycleCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,42 @@

public class CycleCommands {

@Command(aliases = {"maps"}, desc = "View the maps that are on Warzone, although not necessarily in the rotation.", usage = "[page]")
@Command(aliases = {"maps"}, desc = "View the maps that are on Warzone, although not necessarily in the rotation.", usage = "[type]? [page]")
public static void maps(CommandContext cmd, CommandSender sender) throws CommandException {
int index;
int index = 1;
String typeString = "";

try {
index = cmd.argsLength() == 0 ? 1 : cmd.getInteger(0);
if (cmd.argsLength() == 1) {
if (cmd.getString(0).matches("[0-9]+")) {
index = cmd.getInteger(0);
} else {
typeString = cmd.getString(0);
}
}
else if (cmd.argsLength() == 2) {
typeString = cmd.getString(0);
index = cmd.getInteger(1);
}
} catch (NumberFormatException e) {
sender.sendMessage(ChatColor.RED + "Number expected.");
return;
}

GameType type = null;
for (GameType gameType : GameType.values()) {
if (gameType.name().toLowerCase().equals(typeString.toLowerCase())) {
type = gameType;
}
}

List<MapContainer> mapLibrary = TGM.get().getMatchManager().getMapLibrary().getMaps();

if (type != null) {
final GameType finalType = type;
mapLibrary = mapLibrary.stream().filter(map -> map.getMapInfo().getGametype().equals(finalType)).collect(Collectors.toList());
}

int pageSize = 9;

int pagesRemainder = mapLibrary.size() % pageSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,23 @@

import network.warzone.tgm.match.MatchManifest;
import network.warzone.tgm.match.MatchModule;
import network.warzone.tgm.modules.DeathMessageModule;
import network.warzone.tgm.modules.infection.InfectedTimeLimit;
import network.warzone.tgm.modules.*;
import network.warzone.tgm.modules.border.WorldBorderModule;
import network.warzone.tgm.modules.countdown.CycleCountdown;
import network.warzone.tgm.modules.countdown.StartCountdown;
import network.warzone.tgm.modules.filter.FilterManagerModule;
import network.warzone.tgm.modules.infection.InfectionModule;
import network.warzone.tgm.modules.killstreak.KillstreakModule;
import network.warzone.tgm.modules.kit.KitLoaderModule;
import network.warzone.tgm.modules.points.PointsModule;
import network.warzone.tgm.modules.portal.PortalLoaderModule;
import network.warzone.tgm.modules.region.RegionManagerModule;
import network.warzone.tgm.modules.reports.ReportsModule;
import network.warzone.tgm.modules.scoreboard.ScoreboardManagerModule;
import network.warzone.tgm.modules.tasked.TaskedModuleManager;
import network.warzone.tgm.modules.team.TeamManagerModule;
import network.warzone.tgm.modules.time.TimeModule;
import network.warzone.tgm.modules.visibility.VisibilityModule;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -16,14 +30,52 @@ public class InfectionManifest extends MatchManifest {

@Override
public List<MatchModule> allocateGameModules() {
List<MatchModule> matchModules = new ArrayList<>();
return new ArrayList<MatchModule>(){
{
add(new InfectionModule());
}
};
}

matchModules.add(new InfectionModule());
matchModules.add(new InfectedTimeLimit());
@Override
public List<MatchModule> allocateCoreModules() {
List<MatchModule> modules = new ArrayList<>();

allocateCoreModules().remove(new DeathMessageModule()); // Replaced by InfectionModule
modules.add(new TeamJoinNotificationsModule());
modules.add(new SpectatorModule());
modules.add(new SpawnPointHandlerModule());
modules.add(new SpawnPointLoaderModule());
modules.add(new VisibilityModule());
modules.add(new TimeModule());
modules.add(new TabListModule());
modules.add(new MatchProgressNotifications());
modules.add(new MatchResultModule());
modules.add(new TeamManagerModule());
modules.add(new ScoreboardManagerModule());
modules.add(new RegionManagerModule());
modules.add(new TaskedModuleManager());
modules.add(new StartCountdown());
modules.add(new CycleCountdown());
modules.add(new KitLoaderModule());
modules.add(new DeathModule());
modules.add(new FilterManagerModule());
modules.add(new ChatModule());
modules.add(new DisabledCommandsModule());
modules.add(new PointsModule());
modules.add(new LegacyDamageModule());
modules.add(new EntityDamageModule());
modules.add(new FireworkDamageModule());
modules.add(new GameRuleModule());
modules.add(new ItemRemoveModule());
modules.add(new RegenModule());
modules.add(new KillstreakModule());
modules.add(new ReportsModule());
modules.add(new StatsModule());
modules.add(new PortalLoaderModule());
modules.add(new WorldBorderModule());
modules.add(new KnockbackModule());

return matchModules;
return modules;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public List<MatchModule> allocateCoreModules() {
modules.add(new StatsModule());
modules.add(new PortalLoaderModule());
modules.add(new WorldBorderModule());
modules.add(new KnockbackModule());
return modules;
}
}
50 changes: 50 additions & 0 deletions TGM/src/main/java/network/warzone/tgm/modules/KnockbackModule.java
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));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

import network.warzone.tgm.match.MatchModule;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.attribute.Attribute;
import org.bukkit.enchantments.Enchantment;
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.util.Vector;

/**
* Reverts 1.9's damage values to those of 1.8
Expand Down
22 changes: 12 additions & 10 deletions TGM/src/main/java/network/warzone/tgm/modules/dtm/DTMModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,15 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;

@Getter
public class DTMModule extends MatchModule implements Listener {

@Getter private final List<Monument> monuments = new ArrayList<>();
private final HashMap<Monument, List<Integer>> monumentScoreboardLines = new HashMap<>();
private final HashMap<MatchTeam, Integer> teamScoreboardLines = new HashMap<>();
private final HashMap<String, Integer> teamScoreboardLines = new HashMap<>();

@Override
public void load(Match match) {
Expand Down Expand Up @@ -166,7 +163,7 @@ public void onScoreboardInit(ScoreboardInitEvent event) {
}
}
event.getSimpleScoreboard().add(getTeamScoreboardString(matchTeam), i);
teamScoreboardLines.put(matchTeam, i++);
teamScoreboardLines.put(matchTeam.getId(), i++);

if (teams.indexOf(matchTeam) < teams.size() - 1) {
event.getSimpleScoreboard().add(StringUtils.repeat(" ", spaceCount++), i++);
Expand All @@ -176,9 +173,14 @@ public void onScoreboardInit(ScoreboardInitEvent event) {

@EventHandler
public void onTeamUpdate(TeamUpdateEvent event) {
for (MatchTeam matchTeam : teamScoreboardLines.keySet()) {
TeamManagerModule teamManager = TGM.get().getModule(TeamManagerModule.class);

Set<String> teamIds = teamScoreboardLines.keySet();
Set<MatchTeam> matchTeams = teamIds.stream().map(teamManager::getTeamById).collect(Collectors.toSet());

for (MatchTeam matchTeam : matchTeams) {
if (event.getMatchTeam() == matchTeam) {
int i = teamScoreboardLines.get(matchTeam);
int i = teamScoreboardLines.get(matchTeam.getId());

for (SimpleScoreboard simpleScoreboard : TGM.get().getModule(ScoreboardManagerModule.class).getScoreboards().values()) {
simpleScoreboard.remove(i);
Expand Down Expand Up @@ -222,7 +224,7 @@ private MatchTeam getHighestHealthTeam() {

if (highest != null) {
final MatchTeam team = highest;
int amount = teams.entrySet().stream().filter(entry -> teams.get(team) == entry.getValue()).collect(Collectors.toList()).size();
long amount = teams.entrySet().stream().filter(entry -> teams.get(team).equals( entry.getValue())).count();
if (amount > 1) return null;
else return team;
}
Expand All @@ -249,7 +251,7 @@ private String getScoreboardString(Monument monument) {
}
}

public List<Monument> getAliveMonuments(MatchTeam matchTeam) {
private List<Monument> getAliveMonuments(MatchTeam matchTeam) {
List<Monument> alive = new ArrayList<>();
for (Monument monument : monuments) {
if (monument.isAlive() && monument.getOwners().contains(matchTeam)) {
Expand Down

This file was deleted.

Loading

0 comments on commit 14868a2

Please sign in to comment.