/*
 * Copyright 2015 Demigods RPG
 * Copyright 2015 Alexander Chauncey
 * Copyright 2015 Alex Bennett
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.demigodsrpg.game.command;

import com.demigodsrpg.game.DGGame;
import com.demigodsrpg.game.command.type.BaseCommand;
import com.demigodsrpg.game.command.type.CommandResult;
import com.demigodsrpg.game.gui.ShrineGUI;
import com.demigodsrpg.game.model.PlayerModel;
import com.demigodsrpg.game.model.ShrineModel;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;

public class ShrineCommand extends BaseCommand {
    @Override
    public CommandResult onCommand(CommandSender sender, Command command, String[] args) {
        if (sender instanceof ConsoleCommandSender) {
            return CommandResult.PLAYER_ONLY;
        }
        Player player = (Player) sender;

        if (args.length < 1) {
            try {
                Inventory inventory = new ShrineGUI(player).getInventory();
                if (inventory == null) {
                    player.sendMessage(ChatColor.YELLOW + "You don't have any shrines yet!");
                    return CommandResult.QUIET_ERROR;
                }
                player.openInventory(inventory);
            } catch (Exception oops) {
                oops.printStackTrace();
                return CommandResult.ERROR;
            }

            return CommandResult.SUCCESS;
        } else if ("invite".equalsIgnoreCase(args[0]) || "uninvite".equalsIgnoreCase(args[0])) {
            if (args.length < 3) {
                return CommandResult.INVALID_SYNTAX;
            }

            String inviteeName = args[1];
            String shrineName = args[2];

            PlayerModel invitee = DGGame.PLAYER_R.fromName(inviteeName);
            ShrineModel shrine = DGGame.SHRINE_R.fromId(shrineName);

            boolean invite = "invite".equalsIgnoreCase(args[0]);

            if (invitee == null) {
                player.sendMessage(ChatColor.RED + "That player has not joined this server yet.");
                return CommandResult.QUIET_ERROR;
            }
            if (!invite && !invitee.getShrineWarps().contains(shrineName)) {
                player.sendMessage(ChatColor.RED + "That player has never been invited to that shrine.");
            }
            if (shrine == null || player.getUniqueId().toString().equals(shrine.getOwnerMojangId())) {
                player.sendMessage(ChatColor.RED + "That shrine is not yours.");
                return CommandResult.QUIET_ERROR;
            }

            if (invite) {
                invitee.addShrineWarp(shrine);
                player.sendMessage(ChatColor.YELLOW + "Invite sent to " + invitee.getLastKnownName() + ".");
            } else {
                invitee.removeShrineWarp(shrine);
                player.sendMessage(ChatColor.YELLOW + "Uninvited " + invitee.getLastKnownName() + ".");
            }
            OfflinePlayer inviteePlayer = invitee.getOfflinePlayer();
            if (inviteePlayer.isOnline()) {
                inviteePlayer.getPlayer().sendMessage(invite ? ChatColor.YELLOW + player.getName() + " has invited you to a shrine." :
                        ChatColor.YELLOW + player.getName() + " has uninvited you from a shrine.");
            }

            return CommandResult.SUCCESS;
        }

        return CommandResult.INVALID_SYNTAX;
    }
}

@@ -2522,24 +2522,95 @@
 rineName);%0A%0A
+            PlayerModel inviter = DGGame.PLAYER_R.fromPlayer(player);%0A%0A
             
@@ -3036,32 +3036,321 @@
 that shrine.%22);%0A
+                return CommandResult.QUIET_ERROR;%0A            %7D else if (invite && !invitee.getFaction().equals(inviter.getFaction())) %7B%0A                player.sendMessage(ChatColor.RED + %22That player is not in the same faction as you.%22);%0A                return CommandResult.QUIET_ERROR;%0A
             %7D%0A  

Add faction check.