Adds per faction warps functionality from #72.
Default max warps per faction is 5. It can be changed in the config.yml.
You can now use {warps} in the info board to show how many warps a faction has when you walk into their territory.
Only faction mods+ can set faction warps.
This commit is contained in:
29
src/main/java/com/massivecraft/factions/cmd/CmdDelFWarp.java
Normal file
29
src/main/java/com/massivecraft/factions/cmd/CmdDelFWarp.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdDelFWarp extends FCommand {
|
||||
|
||||
public CmdDelFWarp() {
|
||||
super();
|
||||
this.aliases.add("delwarp");
|
||||
this.aliases.add("dw");
|
||||
this.aliases.add("deletewarp");
|
||||
this.requiredArgs.add("warp name");
|
||||
this.senderMustBeMember = true;
|
||||
this.senderMustBeModerator = true;
|
||||
this.senderMustBePlayer = true;
|
||||
this.permission = Permission.SETWARP.node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
String warp = argAsString(0);
|
||||
if (myFaction.isWarp(warp)) {
|
||||
myFaction.removeWarp(warp);
|
||||
fme.msg("<i>Deleted warp <a>%s", warp);
|
||||
} else {
|
||||
fme.msg("<i>Couldn't find warp <a>%s", warp);
|
||||
}
|
||||
}
|
||||
}
|
||||
39
src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java
Normal file
39
src/main/java/com/massivecraft/factions/cmd/CmdFWarp.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdFWarp extends FCommand {
|
||||
|
||||
public CmdFWarp() {
|
||||
super();
|
||||
this.aliases.add("warp");
|
||||
this.aliases.add("warps");
|
||||
this.optionalArgs.put("warpname", "warpname");
|
||||
|
||||
this.permission = Permission.WARP.node;
|
||||
this.senderMustBeMember = true;
|
||||
this.senderMustBeModerator = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
//TODO: check if in combat.
|
||||
if (args.size() == 0) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String s : myFaction.getWarps().keySet()) {
|
||||
sb.append(s + " ");
|
||||
}
|
||||
fme.msg("<i>Warps: <a>" + sb.toString().trim());
|
||||
} else if (args.size() > 1) {
|
||||
fme.msg("<i>/f warp <warpname>");
|
||||
} else {
|
||||
String warpName = argAsString(0);
|
||||
if (myFaction.isWarp(argAsString(0))) {
|
||||
fme.getPlayer().teleport(myFaction.getWarp(warpName).getLocation());
|
||||
fme.msg("<i>Warped to <a>%s", warpName);
|
||||
} else {
|
||||
fme.msg("<i>Couldn't find warp <a>%s", warpName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
39
src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java
Normal file
39
src/main/java/com/massivecraft/factions/cmd/CmdSetFWarp.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Relation;
|
||||
import com.massivecraft.factions.util.LazyLocation;
|
||||
|
||||
public class CmdSetFWarp extends FCommand {
|
||||
|
||||
public CmdSetFWarp() {
|
||||
super();
|
||||
this.aliases.add("setwarp");
|
||||
this.aliases.add("sw");
|
||||
this.requiredArgs.add("warp name");
|
||||
this.senderMustBeMember = true;
|
||||
this.senderMustBeModerator = true;
|
||||
this.senderMustBePlayer = true;
|
||||
this.permission = Permission.SETWARP.node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
if (!(fme.getRelationToLocation() == Relation.MEMBER)) {
|
||||
fme.msg("<i>You can only set warps in your faction territory.");
|
||||
return;
|
||||
}
|
||||
|
||||
int maxWarps = P.p.getConfig().getInt("max-warps", 5);
|
||||
if (maxWarps <= myFaction.getWarps().size()) {
|
||||
fme.msg("<i>Your Faction already has the max amount of warps set <a>(%d).", maxWarps);
|
||||
return;
|
||||
}
|
||||
|
||||
String warp = argAsString(0);
|
||||
LazyLocation loc = new LazyLocation(fme.getPlayer().getLocation());
|
||||
myFaction.setWarp(warp, loc);
|
||||
fme.msg("<i>Set warp <a>%s <i>to your location.", warp);
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,9 @@ public class FCmdRoot extends FCommand {
|
||||
public CmdAnnounce cmdAnnounce = new CmdAnnounce();
|
||||
public CmdSeeChunk cmdSeeChunk = new CmdSeeChunk();
|
||||
public CmdConvert cmdConvert = new CmdConvert();
|
||||
public CmdFWarp cmdFWarp = new CmdFWarp();
|
||||
public CmdSetFWarp cmdSetFWarp = new CmdSetFWarp();
|
||||
public CmdDelFWarp cmdDelFWarp = new CmdDelFWarp();
|
||||
|
||||
public FCmdRoot() {
|
||||
super();
|
||||
@@ -130,6 +133,9 @@ public class FCmdRoot extends FCommand {
|
||||
this.addSubCommand(this.cmdAnnounce);
|
||||
this.addSubCommand(this.cmdSeeChunk);
|
||||
this.addSubCommand(this.cmdConvert);
|
||||
this.addSubCommand(this.cmdFWarp);
|
||||
this.addSubCommand(this.cmdSetFWarp);
|
||||
this.addSubCommand(this.cmdDelFWarp);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user