Skip to content

Commit

Permalink
Merge pull request #41 from jcdesimp/develop
Browse files Browse the repository at this point in the history
Landlord Beta release for Minecraft 1.9
  • Loading branch information
Battelman2 committed Mar 31, 2016
2 parents fa278d7 + 5e3a5cf commit 1f8d525
Show file tree
Hide file tree
Showing 46 changed files with 3,401 additions and 2,027 deletions.
19 changes: 18 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,21 @@

# Maven
log/
target/
target/
### Java template
*.class

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*



out
56 changes: 33 additions & 23 deletions src/com/jcdesimp/landlord/LandAlerter.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.jcdesimp.landlord.persistantData.OwnedLand;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand All @@ -19,77 +20,88 @@
*/
public class LandAlerter implements Listener {

HashMap<String,String> landIn = new HashMap<String, String>();
HashMap<String, String> landIn = new HashMap<String, String>();


private Landlord plugin;


public LandAlerter(Landlord plugin) {
this.plugin = plugin;
}

public void landAlertPlayer(Player player, Location loc) {

FileConfiguration messages = plugin.getMessageConfig();

String leaveOwn = messages.getString("info.alerts.leaveOwnLand");
String leaveOther = messages.getString("info.alerts.leaveOtherLand");
String enterOwn = messages.getString("info.alerts.enterOwnLand");
String enterOther = messages.getString("info.alerts.enterOtherLand");

OwnedLand land = OwnedLand.getApplicableLand(loc);


//Leaving Land
if(landIn.containsKey(player.getName())){
if(land==null){
if (landIn.containsKey(player.getName())) {
if (land == null) {
String prevName = landIn.get(player.getName());
if(prevName.equals(player.getName())){
player.sendMessage(ChatColor.YELLOW+"** Now leaving your land.");
if (prevName.equals(player.getName())) {
player.sendMessage(ChatColor.YELLOW + "** " + leaveOwn);
} else {
player.sendMessage(ChatColor.YELLOW+"** Now leaving "+ prevName +"'s land.");
player.sendMessage(ChatColor.YELLOW + "** " + (leaveOther.replace("#{owner}", prevName)));
}

} else {
String prevName = landIn.get(player.getName());
if(!prevName.equals(land.getOwnerUsername())){
if(prevName.equals(player.getName())){
player.sendMessage(ChatColor.YELLOW+"** Now leaving your land.");
if (!prevName.equals(land.getOwnerUsername())) {
if (prevName.equals(player.getName())) {
player.sendMessage(ChatColor.YELLOW + "** " + leaveOwn);
} else {
player.sendMessage(ChatColor.YELLOW+"** Now leaving "+ prevName +"'s land.");
player.sendMessage(ChatColor.YELLOW + "** " + (leaveOther.replace("#{owner}", prevName)));
}
}
}
}



//Entering Land
if(land==null){
if (land == null) {
landIn.remove(player.getName());
return;
}

if(landIn.containsKey(player.getName())) {
if (landIn.containsKey(player.getName())) {
String prevName = landIn.get(player.getName());
if (!prevName.equals(land.getOwnerUsername())) {
landIn.put(player.getName(), land.getOwnerUsername());

if (land.getOwnerUsername().equals(player.getName())) {
player.sendMessage(ChatColor.GREEN + "** Now entering your land.");
player.sendMessage(ChatColor.GREEN + "** " + enterOwn);
} else {
String ownerName = land.getOwnerUsername();
player.sendMessage(ChatColor.YELLOW + "** Now entering " + ownerName + "'s land.");
player.sendMessage(ChatColor.YELLOW + "** " + enterOther.replace("#{owner}", ownerName));

}
}
} else {
landIn.put(player.getName(), land.getOwnerUsername());
if (land.getOwnerUsername().equals(player.getName())) {
player.sendMessage(ChatColor.GREEN + "** Now entering your land.");
player.sendMessage(ChatColor.GREEN + "** " + enterOwn);
} else {
String ownerName = land.getOwnerUsername();
player.sendMessage(ChatColor.YELLOW + "** Now entering " + ownerName + "'s land.");
player.sendMessage(ChatColor.YELLOW + "** " + enterOther.replace("#{owner}", ownerName));

}
}
}



@EventHandler(priority = EventPriority.HIGH)
public void alertPlayerMove(PlayerMoveEvent event) {
Player player = event.getPlayer();




if (player.getVehicle() != null) {
return;
}
Expand All @@ -101,8 +113,6 @@ public void alertPlayerMove(PlayerMoveEvent event) {
landAlertPlayer(player, event.getTo());




}

}
Expand All @@ -113,7 +123,7 @@ public void teleportAlert(PlayerTeleportEvent event) {
}

@EventHandler(priority = EventPriority.HIGH)
public void playerLeave(PlayerQuitEvent event){
public void playerLeave(PlayerQuitEvent event) {
landIn.remove(event.getPlayer().getName());
}

Expand Down
Loading

0 comments on commit 1f8d525

Please sign in to comment.