Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ProgrammerDan authored Jun 8, 2017
2 parents 0aabf00 + dcb82ce commit 882412d
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 50 deletions.
33 changes: 10 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
JukeAlert
=========
# JukeAlert

Additional updates requested for Devoted:
A plugin for Minecraft 1.10 that turns Noteblocks and Jukeboxes into snitches that record player entries and actions.

Snitch network command and control block. Essentially a change to jukealert requiring a stationary block that will relay snitch entries. Until that is set up on the snitch group jukeboxes will only record actions by /jainfo, breaking snitches will reveal parts of the 'relay's' location, allowing you to find an enemy's relay (and destroy it) after breaking a couple snitches.
## Usage

Breaking that down:
- Reinforce a **Noteblock** with a [Citadel](https://github.com/DevotedMC/Citadel) reinforcement to create an entry snitch. The snitch will send a notification to everyone on the Citadel group its reinforced to when other players enter its field - an 11 block cube centered on the snitch.

1: New block (let's use a Sea Lantern for development) that is required to be on a group with a snitch before sending snitch 'entry' alerts:
- Reinforce a **Jukebox** with a [Citadel](https://github.com/DevotedMC/Citadel) reinforcement to create a snitch. The snitch will send a notification to everyone on the Citadel group its reinforced to when other players enter its field - an 11 block cube centered on the snitch. It will also record player actions that occur within the field, e.g. block placement and destruction. Type `/jainfo` to check what players did in the snitched area while you were gone.

public void playerJoinEvent(PlayerJoinEvent event)

public void handlePlayerExit(PlayerEvent event)

private void handleSnitchEntry(Player player)
Wiki: https://github.com/Civcraft/JukeAlert/wiki

2: If a snitch is broken and a relay is reinforced on that group, it will display the following in the player who broke the snitch's chat:
Getting started with Devoted: https://www.reddit.com/r/Devoted/wiki/help

"Relayed snitch broken. Relay located at [world XXX XXX XXX]"

With 5 of the X's randomly revealed. So for instance:

"Relayed snitch broken. Relay located at [world X3X 21 1X2]"

This allows players to track down Relays, if they break enough snitches.

---

Additionally, a change to allow players with invisibility potions to not trip entry alerts. /jainfo alerts are fine, but no chat alerts.
## Contributing
- Style guide: https://github.com/DevotedMC/style-guide
- Build server: https://build.civcraft.co/job/JukeAlert-master/
30 changes: 21 additions & 9 deletions src/main/java/com/untamedears/JukeAlert/chat/SendSnitchInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import java.util.TreeMap;
import java.util.logging.Level;

import com.google.common.base.Strings;

import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
Expand All @@ -27,32 +29,42 @@ public class SendSnitchInfo implements Runnable {

private String snitchName;

private boolean isJukebox;

private boolean shouldCensor;

private boolean isGroup;

public SendSnitchInfo(List<SnitchAction> info, Player player, int offset, String snitchName, boolean shouldCensor,
boolean isGroup) {
public SendSnitchInfo(List<SnitchAction> info, Player player, int offset, String snitchName, boolean isJukebox,
boolean shouldCensor, boolean isGroup) {

this.info = info;
this.player = player;
this.offset = offset;
this.snitchName = snitchName;
this.isJukebox = isJukebox;
this.shouldCensor = shouldCensor;
this.isGroup = isGroup;
}

public void run() {

if (!isJukebox) {
if (this.snitchName == null || this.snitchName.trim().isEmpty()) {
player.sendMessage(ChatColor.AQUA + " * Unnamed entry snitch");
} else {
player.sendMessage(ChatColor.AQUA + " * Entry snitch " + this.snitchName);
}
return;
}
if (info != null && !info.isEmpty()) {
String output = "";

if (this.snitchName != null) {
output += ChatColor.WHITE + " Snitch Log for " + this.snitchName + " "
+ ChatColor.DARK_GRAY
+ "-----------------------------------".substring(this.snitchName.length()) + "\n";
if (this.snitchName != null && !this.snitchName.trim().isEmpty()) {
output += ChatColor.WHITE + " Log for snitch " + this.snitchName + " "
+ ChatColor.DARK_GRAY + Strings.repeat("-", this.snitchName.length()) + "\n";
} else {
output += ChatColor.WHITE + " Snitch Log "
output += ChatColor.WHITE + " Log for unnamed snitch "
+ ChatColor.DARK_GRAY + "----------------------------------------" + "\n";
}

Expand Down Expand Up @@ -103,10 +115,10 @@ public void run() {
output += "\n";
output += ChatColor.DARK_GRAY + " * Page " + offset + " ------------------------------------------";
player.sendMessage(output);
} else if (this.snitchName != null) {
} else if (this.snitchName != null && !this.snitchName.trim().isEmpty()) {
player.sendMessage(ChatColor.AQUA + " * Page " + offset + " is empty for snitch " + this.snitchName);
} else {
player.sendMessage(ChatColor.AQUA + " * Page " + offset + " is empty");
player.sendMessage(ChatColor.AQUA + " * Page " + offset + " is empty for unnamed snitch");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.List;

import com.google.common.base.Strings;

import org.bukkit.ChatColor;
import org.bukkit.entity.Player;

Expand Down Expand Up @@ -42,9 +44,7 @@ public void run() {
topLine += "for " + worldName + " ";
}

topLine = ChatColor.WHITE + topLine
+ ChatColor.DARK_GRAY
+ "--------------------------------------------------------".substring(topLine.length()) + "\n";
topLine = ChatColor.WHITE + topLine + ChatColor.DARK_GRAY + Strings.repeat("-", topLine.length()) + "\n";

String columnNames = ChatColor.GRAY
+ String.format(" %s %s %s", ChatFiller.fillString("Location", locationColWidth),
Expand All @@ -58,8 +58,7 @@ public void run() {
}

String bottomLine = ChatColor.DARK_GRAY + " * Page " + offset + " ";
bottomLine = bottomLine
+ "-------------------------------------------------------".substring(bottomLine.length());
bottomLine = bottomLine + Strings.repeat("-", bottomLine.length());
output.addExtra(bottomLine);
player.spigot().sendMessage(output);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private void sendLog(CommandSender sender, Snitch snitch, int offset, boolean sh

Player player = (Player) sender;
GetSnitchInfoPlayerTask task = new GetSnitchInfoPlayerTask(JukeAlert.getInstance(), snitch.getId(),
snitch.getName(), offset, player, shouldCensor, filterAction, filterPlayer);
snitch.getName(), snitch.shouldLog(), offset, player, shouldCensor, filterAction, filterPlayer);
Bukkit.getScheduler().runTaskAsynchronously(JukeAlert.getInstance(), task);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.vehicle.VehicleDestroyEvent;
import org.bukkit.event.vehicle.VehicleMoveEvent;
import org.bukkit.material.Lever;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitScheduler;
Expand Down Expand Up @@ -271,11 +272,11 @@ public void reinforceSnitchBlock(ReinforcementCreationEvent event) {

String message;
if (isJukebox) {
message = (ChatColor.AQUA + "You've created a snitch block registered to the group " + snitchGroupName
+ ". To name your snitch, type /janame.");
message = (ChatColor.AQUA + "You've created a snitch registered to the group " + snitchGroupName
+ ". To name it, type /janame.");
} else {
message = (ChatColor.AQUA + "You've created an entry snitch registered to the group " + snitchGroupName
+ ". To name your entry snitch, type /janame.");
+ ". To name it, type /janame.");
}
TextComponent lineText = new TextComponent(message);
lineText.setHoverEvent(
Expand Down Expand Up @@ -452,6 +453,15 @@ public void enterSnitchProximity(PlayerMoveEvent event) {
}
}

@EventHandler(priority = EventPriority.HIGH)
public void onVehicleMovement(VehicleMoveEvent event) {
Entity e = event.getVehicle().getPassenger();
// TODO: apparently there's no way to get the second passenger? wtf, bukkit
if (e instanceof Player) {
enterSnitchProximity(new PlayerMoveEvent((Player) e, event.getFrom(), event.getTo()));
}
}

// Because teleporting doesn't trigger a movement event :/
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerTeleport(PlayerTeleportEvent event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,11 @@ public void removeSnitch(Snitch snitch) {

snitches.get(snitch.getLoc().getWorld()).remove(snitch);
snitchesById.remove(snitch.getId());
Set<Snitch> groupSet = snitchesByGroup.get(snitch.getGroup().getName());
if (groupSet != null) {
groupSet.remove(snitch);
if (snitch.getGroup() != null) {
Set<Snitch> groupSet = snitchesByGroup.get(snitch.getGroup().getName());
if (groupSet != null) {
groupSet.remove(snitch);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class GetSnitchInfoPlayerTask implements Runnable {

private String snitchName;

private boolean isJukebox;

private String group;

private LoggedAction filterAction;
Expand All @@ -40,11 +42,12 @@ public class GetSnitchInfoPlayerTask implements Runnable {

private final JukeAlert plugin;

public GetSnitchInfoPlayerTask(JukeAlert plugin, int snitchId, String snitchName, int offset, Player player,
boolean shouldCensor) {
public GetSnitchInfoPlayerTask(JukeAlert plugin, int snitchId, String snitchName, boolean isJukebox, int offset,
Player player, boolean shouldCensor) {

this.snitchId = snitchId;
this.snitchName = snitchName;
this.isJukebox = isJukebox;
this.offset = offset;
this.player = player;
this.plugin = plugin;
Expand All @@ -54,11 +57,12 @@ public GetSnitchInfoPlayerTask(JukeAlert plugin, int snitchId, String snitchName
this.filterPlayer = "";
}

public GetSnitchInfoPlayerTask(JukeAlert plugin, int snitchId, String snitchName, int offset, Player player,
boolean shouldCensor, LoggedAction filterAction, String filterPlayer) {
public GetSnitchInfoPlayerTask(JukeAlert plugin, int snitchId, String snitchName, boolean isJukebox, int offset,
Player player, boolean shouldCensor, LoggedAction filterAction, String filterPlayer) {

this.snitchId = snitchId;
this.snitchName = snitchName;
this.isJukebox = isJukebox;
this.offset = offset;
this.player = player;
this.plugin = plugin;
Expand All @@ -76,6 +80,7 @@ public GetSnitchInfoPlayerTask(JukeAlert plugin, String group, int offset, Playe
this.plugin = plugin;
this.snitchId = -1;
this.snitchName = null;
this.isJukebox = true;
this.shouldCensor = false;
this.filterAction = null;
this.filterPlayer = "";
Expand All @@ -87,10 +92,11 @@ public void run() {
SendSnitchInfo sendSnitchInfo;
if (group == null) {
sendSnitchInfo = new SendSnitchInfo(plugin.getJaLogger().getSnitchInfo(snitchId, (offset - 1) * 10,
this.filterAction, this.filterPlayer), this.player, offset, this.snitchName, shouldCensor, false);
this.filterAction, this.filterPlayer), this.player, offset, this.snitchName, this.isJukebox,
shouldCensor, false);
} else {
sendSnitchInfo = new SendSnitchInfo(plugin.getJaLogger().getSnitchGroupInfo(group, (offset - 1) * 10),
this.player, offset, null, false, true);
this.player, offset, null, this.isJukebox, false, true);
}
sendSnitchInfo.run();
}
Expand Down

0 comments on commit 882412d

Please sign in to comment.