Mouth of Sauron ability created
parent
183f5a8f8d
commit
99c8d1222a
@ -0,0 +1,32 @@
|
|||||||
|
package com.zivilon.cinder_loe.character;
|
||||||
|
|
||||||
|
import lotr.common.entity.npc.LOTREntityNPC;
|
||||||
|
import lotr.common.entity.npc.LOTRHireableBase;
|
||||||
|
import lotr.common.entity.npc.LOTRUnitTradeEntry;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class MouthOfSauronEntityHandler extends LOTRUnitTradeEntry {
|
||||||
|
|
||||||
|
private final LOTREntityNPC npc;
|
||||||
|
|
||||||
|
public MouthOfSauronEntityHandler(LOTREntityNPC npc, float alignmentRequired) {
|
||||||
|
super(npc.getClass(), 0 /*costless*/, alignmentRequired);
|
||||||
|
this.npc = npc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LOTREntityNPC getOrCreateHiredNPC(World world) {
|
||||||
|
// Return the very same NPC, no new spawn.
|
||||||
|
return npc;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasRequiredCostAndAlignment(EntityPlayer player, LOTRHireableBase trader) {
|
||||||
|
// If they're already hired, disallow re-hiring
|
||||||
|
if (npc.hiredNPCInfo != null && npc.hiredNPCInfo.isActive) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return super.hasRequiredCostAndAlignment(player, trader);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,47 @@
|
|||||||
|
package com.zivilon.cinder_loe.command;
|
||||||
|
|
||||||
|
import net.minecraft.command.CommandBase;
|
||||||
|
import net.minecraft.command.ICommandSender;
|
||||||
|
import net.minecraft.command.WrongUsageException;
|
||||||
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.util.ChatComponentText;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static com.zivilon.cinder_loe.character.CharacterEventListener.hiringEnabled;
|
||||||
|
|
||||||
|
public class CommandMouthOfSauron extends CommandBase {
|
||||||
|
@Override
|
||||||
|
public String getCommandName() {
|
||||||
|
return "MouthofSauron";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCommandUsage(ICommandSender sender) {
|
||||||
|
return "/MouthofSauron <on|off>";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processCommand(ICommandSender sender, String[] args) {
|
||||||
|
if (!(sender instanceof EntityPlayerMP)) {
|
||||||
|
sender.addChatMessage(new ChatComponentText("Only players may use this command."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (args.length != 1 ||
|
||||||
|
(!args[0].equalsIgnoreCase("on") && !args[0].equalsIgnoreCase("off"))) {
|
||||||
|
throw new WrongUsageException(getCommandUsage(sender));
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityPlayerMP player = (EntityPlayerMP) sender;
|
||||||
|
UUID id = player.getUniqueID();
|
||||||
|
boolean enable = args[0].equalsIgnoreCase("on");
|
||||||
|
|
||||||
|
if (enable) {
|
||||||
|
hiringEnabled.add(id);
|
||||||
|
player.addChatMessage(new ChatComponentText("MouthOfSauron auto-hire ENABLED."));
|
||||||
|
} else {
|
||||||
|
hiringEnabled.remove(id);
|
||||||
|
player.addChatMessage(new ChatComponentText("MouthOfSauron auto-hire DISABLED."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue