Skip to content

Commit

Permalink
0.2.3: properly compare old/new areas, cleanup for 0.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian Weiss committed Feb 14, 2019
1 parent 898b96a commit 741edfc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
12 changes: 5 additions & 7 deletions plugin/me/insanj/pride/PridePlayerListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public void onPlayerQuit(PlayerQuitEvent event) { }
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
//Location from = event.getFrom();
//plugin.getLogger().info(String.format("From %.2f,%.2f,%.2f to %.2f,%.2f,%.2f", from.getX(), from.getY(), from.getZ(), to.getX(), to.getY(), to.getZ()));

Location to = event.getTo();
detectPride(event.getPlayer().getName(), to, event.getPlayer().getWorld());
}
Expand All @@ -49,7 +47,7 @@ public void detectPride(String playerName, Location playerLocation, World world)
//plugin.getLogger("Unable to get prideAreas from pride.txt file");
prideAreas = new HashMap();
PrideConfigurator.writePrideAreas(filename, prideAreas);
plugin.getLogger().info("Write new pride.txt file because we couldn't find one already");
plugin.getLogger().info("Wrote new pride.txt file because we couldn't find one already");
}

double threshold = 50; // how close you have to be to an area to activate it
Expand All @@ -61,7 +59,7 @@ public void detectPride(String playerName, Location playerLocation, World world)
double xDiff = Math.abs(areaLocation.getX() - playerLocation.getX());
double zDiff = Math.abs(areaLocation.getZ() - playerLocation.getZ());
double totalDiff = xDiff + zDiff;
plugin.getLogger().info("Checking if player " + playerName + " is inside area " + (String)key + ". diff = " + Double.toString(totalDiff));
// plugin.getLogger().info("Checking if player " + playerName + " is inside area " + (String)key + ". diff = " + Double.toString(totalDiff));

if (totalDiff <= threshold) {
String areaName = (String)key;
Expand All @@ -88,16 +86,16 @@ public void detectPride(String playerName, Location playerLocation, World world)
} else if (areaMessage.contains("and")) {
areaMessage = areaName + " ," + areaMessage;
} else {
areaMessage = areaMessage + " and " + areaName;
areaMessage = areaMessage + " & " + areaName;
}
}

if (areaMessage == null) {
// wat ?
} else {
Bukkit.broadcastMessage("🦁" + ChatColor.GREEN + playerName + ChatColor.WHITE + " has activated " + ChatColor.BLUE + areaMessage + ChatColor.WHITE + "!");
Bukkit.broadcastMessage("" + ChatColor.GREEN + playerName + ChatColor.WHITE + " entered " + ChatColor.BLUE + areaMessage + ChatColor.WHITE + "!");
}

playerAreaHistory.put(playerName, newlyActivatedAreas); // update history
playerAreaHistory.put(playerName, activatedAreas); // update history
}
}
7 changes: 3 additions & 4 deletions plugin/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: pride
main: me.insanj.pride.Pride
version: 0.1.0
version: 0.2.3
description: keep track of your playmates in minecraft
commands:
pride:
description: Add a player to your pride.
description: Add your current area to Pride
usage: |
/pride add <username>
/pride remove <username>
/pride add <name>

0 comments on commit 741edfc

Please sign in to comment.