Now it compiles. Time to fix runtime errors...
This commit is contained in:
parent
4e964ba194
commit
1c062c9c79
@ -1,3 +1,7 @@
|
||||
name: Factions
|
||||
version: 1.0 beta8
|
||||
version: 1.1
|
||||
main: com.bukkit.mcteam.factions.Factions
|
||||
commands:
|
||||
f:
|
||||
description: All of the Factions commands
|
||||
usage: See documentation.
|
@ -51,111 +51,13 @@ public class Conf {
|
||||
|
||||
public static List<Material> territoryProtectedMaterials = new ArrayList<Material>();
|
||||
|
||||
// Command names / aliases
|
||||
public static List<String> aliasBase = new ArrayList<String>();
|
||||
public static List<String> aliasHelp = new ArrayList<String>();
|
||||
|
||||
public static List<String> aliasList = new ArrayList<String>();
|
||||
public static List<String> aliasShow = new ArrayList<String>();
|
||||
|
||||
public static List<String> aliasMap = new ArrayList<String>();
|
||||
|
||||
public static List<String> aliasJoin = new ArrayList<String>();
|
||||
public static List<String> aliasLeave = new ArrayList<String>();
|
||||
|
||||
public static List<String> aliasCreate = new ArrayList<String>();
|
||||
public static List<String> aliasTag = new ArrayList<String>();
|
||||
public static List<String> aliasDescription = new ArrayList<String>();
|
||||
public static List<String> aliasChat = new ArrayList<String>();
|
||||
|
||||
public static List<String> aliasTitle = new ArrayList<String>();
|
||||
public static List<String> aliasInvite = new ArrayList<String>();
|
||||
public static List<String> aliasDeinvite = new ArrayList<String>();
|
||||
public static List<String> aliasOpen = new ArrayList<String>();
|
||||
|
||||
public static List<String> aliasKick = new ArrayList<String>();
|
||||
public static List<String> aliasModerator = new ArrayList<String>();
|
||||
public static List<String> aliasAdmin = new ArrayList<String>();
|
||||
|
||||
public static List<String> aliasClaim = new ArrayList<String>();
|
||||
public static List<String> aliasUnclaim = new ArrayList<String>();
|
||||
|
||||
public static List<String> aliasRelationAlly = new ArrayList<String>();
|
||||
public static List<String> aliasRelationNeutral = new ArrayList<String>();
|
||||
public static List<String> aliasRelationEnemy = new ArrayList<String>();
|
||||
|
||||
public static List<String> aliasVersion = new ArrayList<String>();
|
||||
|
||||
// Value aliases
|
||||
public static List<String> aliasTrue = new ArrayList<String>();
|
||||
public static boolean allowNoSlashCommand = true;
|
||||
|
||||
static {
|
||||
territoryProtectedMaterials.add(Material.WOODEN_DOOR);
|
||||
territoryProtectedMaterials.add(Material.DISPENSER);
|
||||
territoryProtectedMaterials.add(Material.CHEST);
|
||||
territoryProtectedMaterials.add(Material.FURNACE);
|
||||
|
||||
aliasBase.add("/f");
|
||||
aliasBase.add("f");
|
||||
|
||||
aliasHelp.add("help");
|
||||
aliasHelp.add("h");
|
||||
aliasHelp.add("?");
|
||||
|
||||
aliasList.add("list");
|
||||
aliasList.add("ls");
|
||||
|
||||
aliasShow.add("show");
|
||||
aliasShow.add("who");
|
||||
|
||||
aliasMap.add("map");
|
||||
|
||||
aliasJoin.add("join");
|
||||
|
||||
aliasLeave.add("leave");
|
||||
|
||||
aliasCreate.add("create");
|
||||
aliasCreate.add("new");
|
||||
aliasTag.add("tag");
|
||||
aliasDescription.add("desc");
|
||||
|
||||
aliasChat.add("chat");
|
||||
aliasChat.add("c");
|
||||
|
||||
aliasTitle.add("title");
|
||||
|
||||
aliasInvite.add("invite");
|
||||
aliasInvite.add("inv");
|
||||
|
||||
aliasDeinvite.add("deinvite");
|
||||
aliasDeinvite.add("deinv");
|
||||
|
||||
aliasOpen.add("open");
|
||||
aliasOpen.add("close");
|
||||
|
||||
aliasKick.add("kick");
|
||||
|
||||
aliasModerator.add("mod");
|
||||
|
||||
aliasAdmin.add("admin");
|
||||
|
||||
aliasClaim.add("claim");
|
||||
|
||||
aliasUnclaim.add("unclaim");
|
||||
aliasUnclaim.add("declaim");
|
||||
|
||||
aliasRelationAlly.add("ally");
|
||||
aliasRelationNeutral.add("neutral");
|
||||
aliasRelationEnemy.add("enemy");
|
||||
|
||||
aliasVersion.add("version");
|
||||
|
||||
aliasTrue.add("true");
|
||||
aliasTrue.add("yes");
|
||||
aliasTrue.add("y");
|
||||
aliasTrue.add("ok");
|
||||
aliasTrue.add("on");
|
||||
aliasTrue.add("+");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
@ -53,6 +53,44 @@ public class Faction {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public boolean getOpen() {
|
||||
return open;
|
||||
}
|
||||
|
||||
public void setOpen(boolean isOpen) {
|
||||
open = isOpen;
|
||||
save();
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return this.getTag("");
|
||||
}
|
||||
public String getTag(String prefix) {
|
||||
return prefix+this.tag;
|
||||
}
|
||||
public String getTag(Faction otherFaction) {
|
||||
return this.getTag(otherFaction.getRelationColor(this).toString());
|
||||
}
|
||||
public String getTag(FPlayer otherFollower) {
|
||||
return this.getTag(otherFollower.getRelationColor(this).toString());
|
||||
}
|
||||
public void setTag(String str) {
|
||||
if (Conf.factionTagForceUpperCase) {
|
||||
str = str.toUpperCase();
|
||||
}
|
||||
this.tag = str;
|
||||
save();
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String value) {
|
||||
this.description = value;
|
||||
save();
|
||||
}
|
||||
|
||||
// -------------------------------
|
||||
// Invites
|
||||
// -------------------------------
|
||||
@ -106,49 +144,6 @@ public class Faction {
|
||||
return getRelation(follower.getFaction());
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -------------------------------
|
||||
// Information
|
||||
// -------------------------------
|
||||
public String getTag() {
|
||||
return this.getTag("");
|
||||
}
|
||||
public String getTag(String prefix) {
|
||||
return prefix+this.tag;
|
||||
}
|
||||
public String getTag(Faction otherFaction) {
|
||||
return this.getTag(otherFaction.getRelationColor(this).toString());
|
||||
}
|
||||
public String getTag(FPlayer otherFollower) {
|
||||
return this.getTag(otherFollower.getRelationColor(this).toString());
|
||||
}
|
||||
public void setTag(String str) {
|
||||
if (Conf.factionTagForceUpperCase) {
|
||||
str = str.toUpperCase();
|
||||
}
|
||||
this.tag = str;
|
||||
this.save();
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String value) {
|
||||
this.description = value;
|
||||
this.save();
|
||||
}
|
||||
|
||||
public boolean getOpen() {
|
||||
return open;
|
||||
}
|
||||
|
||||
public void setOpen(boolean isOpen) {
|
||||
open = isOpen;
|
||||
this.save();
|
||||
}
|
||||
|
||||
//----------------------------------------------//
|
||||
// Power
|
||||
//----------------------------------------------//
|
||||
@ -336,11 +331,10 @@ public class Faction {
|
||||
if ( ! file.exists()) {
|
||||
Factions.log("No factions to load from disk. Creating new file.");
|
||||
save();
|
||||
return true;
|
||||
}
|
||||
|
||||
try {
|
||||
Type type = new TypeToken<Map<String, Faction>>(){}.getType();
|
||||
Type type = new TypeToken<Map<Integer, Faction>>(){}.getType();
|
||||
instances = Factions.gson.fromJson(DiscUtil.read(file), type);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -4,6 +4,7 @@ import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -17,6 +18,29 @@ import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.bukkit.mcteam.factions.commands.FBaseCommand;
|
||||
import com.bukkit.mcteam.factions.commands.FCommandAdmin;
|
||||
import com.bukkit.mcteam.factions.commands.FCommandChat;
|
||||
import com.bukkit.mcteam.factions.commands.FCommandClaim;
|
||||
import com.bukkit.mcteam.factions.commands.FCommandCreate;
|
||||
import com.bukkit.mcteam.factions.commands.FCommandDeinvite;
|
||||
import com.bukkit.mcteam.factions.commands.FCommandDescription;
|
||||
import com.bukkit.mcteam.factions.commands.FCommandHelp;
|
||||
import com.bukkit.mcteam.factions.commands.FCommandInvite;
|
||||
import com.bukkit.mcteam.factions.commands.FCommandJoin;
|
||||
import com.bukkit.mcteam.factions.commands.FCommandKick;
|
||||
import com.bukkit.mcteam.factions.commands.FCommandLeave;
|
||||
import com.bukkit.mcteam.factions.commands.FCommandList;
|
||||
import com.bukkit.mcteam.factions.commands.FCommandMap;
|
||||
import com.bukkit.mcteam.factions.commands.FCommandMod;
|
||||
import com.bukkit.mcteam.factions.commands.FCommandOpen;
|
||||
import com.bukkit.mcteam.factions.commands.FCommandRelationAlly;
|
||||
import com.bukkit.mcteam.factions.commands.FCommandRelationEnemy;
|
||||
import com.bukkit.mcteam.factions.commands.FCommandRelationNeutral;
|
||||
import com.bukkit.mcteam.factions.commands.FCommandShow;
|
||||
import com.bukkit.mcteam.factions.commands.FCommandTag;
|
||||
import com.bukkit.mcteam.factions.commands.FCommandTitle;
|
||||
import com.bukkit.mcteam.factions.commands.FCommandUnclaim;
|
||||
import com.bukkit.mcteam.factions.commands.FCommandVersion;
|
||||
import com.bukkit.mcteam.factions.listeners.FactionsBlockListener;
|
||||
import com.bukkit.mcteam.factions.listeners.FactionsEntityListener;
|
||||
import com.bukkit.mcteam.factions.listeners.FactionsPlayerListener;
|
||||
@ -49,30 +73,49 @@ public class Factions extends JavaPlugin {
|
||||
// Commands
|
||||
public List<FBaseCommand> commands = new ArrayList<FBaseCommand>();
|
||||
|
||||
private String baseCommand;
|
||||
|
||||
public Factions() {
|
||||
Factions.instance = this;
|
||||
|
||||
// Add the commands
|
||||
commands.add(new FCommandHelp());
|
||||
commands.add(new FCommandAdmin());
|
||||
commands.add(new FCommandChat());
|
||||
commands.add(new FCommandClaim());
|
||||
commands.add(new FCommandCreate());
|
||||
commands.add(new FCommandDeinvite());
|
||||
commands.add(new FCommandDescription());
|
||||
commands.add(new FCommandInvite());
|
||||
commands.add(new FCommandJoin());
|
||||
commands.add(new FCommandKick());
|
||||
commands.add(new FCommandLeave());
|
||||
commands.add(new FCommandList());
|
||||
commands.add(new FCommandMap());
|
||||
commands.add(new FCommandMod());
|
||||
commands.add(new FCommandOpen());
|
||||
commands.add(new FCommandRelationAlly());
|
||||
commands.add(new FCommandRelationEnemy());
|
||||
commands.add(new FCommandRelationNeutral());
|
||||
commands.add(new FCommandShow());
|
||||
commands.add(new FCommandTag());
|
||||
commands.add(new FCommandTitle());
|
||||
commands.add(new FCommandUnclaim());
|
||||
commands.add(new FCommandVersion());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Add the commands
|
||||
/*commands.add(new VCommandBlood());
|
||||
commands.add(new VCommandInfect());
|
||||
commands.add(new VCommandLoad());
|
||||
commands.add(new VCommandSave());
|
||||
commands.add(new VCommandTime());
|
||||
commands.add(new VCommandTurn());
|
||||
commands.add(new VCommandCure());
|
||||
commands.add(new VCommandList());
|
||||
commands.add(new VCommandVersion());*/
|
||||
|
||||
setupPermissions();
|
||||
setupHelp();
|
||||
|
||||
log("=== INIT START ===");
|
||||
long timeInitStart = System.currentTimeMillis();
|
||||
|
||||
setupHelp();
|
||||
setupPermissions();
|
||||
|
||||
// Ensure basefolder exists!
|
||||
this.getDataFolder().mkdirs();
|
||||
|
||||
FPlayer.load();
|
||||
Faction.load();
|
||||
Board.load();
|
||||
@ -97,8 +140,10 @@ public class Factions extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
FPlayer.save();
|
||||
Faction.save();
|
||||
Board.save();
|
||||
log("Disabled");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
@ -130,9 +175,7 @@ public class Factions extends JavaPlugin {
|
||||
if (test != null) {
|
||||
helpPlugin = ((Help) test);
|
||||
Factions.log("Found and will use plugin "+helpPlugin.getDescription().getFullName());
|
||||
|
||||
// TODO not hardcoded:
|
||||
helpPlugin.registerCommand("f help *[page]", "Factions plugin help.", helpPlugin, true);
|
||||
helpPlugin.registerCommand(this.getBaseCommand()+" help *[page]", "Factions plugin help.", helpPlugin, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,6 +184,17 @@ public class Factions extends JavaPlugin {
|
||||
// Commands
|
||||
// -------------------------------------------- //
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public String getBaseCommand() {
|
||||
if (this.baseCommand != null) {
|
||||
return this.baseCommand;
|
||||
}
|
||||
|
||||
Map<String, Object> Commands = (Map<String, Object>)this.getDescription().getCommands();
|
||||
this.baseCommand = Commands.keySet().iterator().next();
|
||||
return this.baseCommand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
List<String> parameters = new ArrayList<String>(Arrays.asList(args));
|
||||
@ -164,8 +218,7 @@ public class Factions extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(Conf.colorSystem+"Unknown faction command \""+commandName+"\". Try /help faction"); // TODO test help messages exists....
|
||||
//TODO should we use internal help system instead?
|
||||
sender.sendMessage(Conf.colorSystem+"Unknown faction command \""+commandName+"\". Try "+Conf.colorCommand+"/f help");
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
@ -14,6 +14,8 @@ import com.bukkit.mcteam.factions.struct.Role;
|
||||
import com.bukkit.mcteam.factions.util.TextUtil;
|
||||
|
||||
public class FBaseCommand {
|
||||
public List<String> aliases;
|
||||
|
||||
public List<String> requiredParameters;
|
||||
public List<String> optionalParameters;
|
||||
|
||||
@ -42,17 +44,7 @@ public class FBaseCommand {
|
||||
helpDescription = "no description";
|
||||
}
|
||||
|
||||
public ArrayList<String> getAliases() {
|
||||
String name = this.getClass().getName().toLowerCase();
|
||||
if (name.lastIndexOf('.') > 0) {
|
||||
name = name.substring(name.lastIndexOf('.')+1);
|
||||
}
|
||||
|
||||
name = name.substring(8);
|
||||
|
||||
ArrayList<String> aliases = new ArrayList<String>();
|
||||
aliases.add(name);
|
||||
|
||||
public List<String> getAliases() {
|
||||
return aliases;
|
||||
}
|
||||
|
||||
@ -66,7 +58,6 @@ public class FBaseCommand {
|
||||
this.parameters = parameters;
|
||||
|
||||
if ( ! validateCall()) {
|
||||
sendMessage("try /help factions");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -137,7 +128,7 @@ public class FBaseCommand {
|
||||
// -------------------------------------------- //
|
||||
// Help and usage description
|
||||
// -------------------------------------------- //
|
||||
public String getUseageTemplate(boolean withColor) {
|
||||
public String getUseageTemplate(boolean withColor, boolean withDescription) {
|
||||
String ret = "";
|
||||
|
||||
if (withColor) {
|
||||
@ -161,9 +152,17 @@ public class FBaseCommand {
|
||||
}
|
||||
|
||||
ret += TextUtil.implode(parts, " ");
|
||||
|
||||
if (withDescription) {
|
||||
ret += " "+Conf.colorSystem + this.helpDescription;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public String getUseageTemplate(boolean withColor) {
|
||||
return getUseageTemplate(withColor, false);
|
||||
}
|
||||
|
||||
public String getUseageTemplate() {
|
||||
return getUseageTemplate(true);
|
||||
}
|
||||
@ -260,4 +259,16 @@ public class FBaseCommand {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean parseBool(String str) {
|
||||
List<String> aliasTrue = new ArrayList<String>();
|
||||
aliasTrue.add("true");
|
||||
aliasTrue.add("yes");
|
||||
aliasTrue.add("y");
|
||||
aliasTrue.add("ok");
|
||||
aliasTrue.add("on");
|
||||
aliasTrue.add("+");
|
||||
|
||||
return aliasTrue.contains(str.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,9 @@ import com.bukkit.mcteam.factions.struct.Role;
|
||||
public class FCommandAdmin extends FBaseCommand {
|
||||
|
||||
public FCommandAdmin() {
|
||||
aliases = new ArrayList<String>();
|
||||
aliases.add("admin");
|
||||
|
||||
requiredParameters = new ArrayList<String>();
|
||||
optionalParameters = new ArrayList<String>();
|
||||
requiredParameters.add("player name");
|
||||
|
@ -5,6 +5,10 @@ import java.util.ArrayList;
|
||||
public class FCommandChat extends FBaseCommand {
|
||||
|
||||
public FCommandChat() {
|
||||
aliases = new ArrayList<String>();
|
||||
aliases.add("chat");
|
||||
aliases.add("c");
|
||||
|
||||
requiredParameters = new ArrayList<String>();
|
||||
optionalParameters = new ArrayList<String>();
|
||||
|
||||
|
@ -12,6 +12,9 @@ import com.bukkit.mcteam.factions.struct.Role;
|
||||
public class FCommandClaim extends FBaseCommand {
|
||||
|
||||
public FCommandClaim() {
|
||||
aliases = new ArrayList<String>();
|
||||
aliases.add("claim");
|
||||
|
||||
requiredParameters = new ArrayList<String>();
|
||||
optionalParameters = new ArrayList<String>();
|
||||
|
||||
|
@ -10,6 +10,9 @@ import com.bukkit.mcteam.factions.struct.Role;
|
||||
public class FCommandCreate extends FBaseCommand {
|
||||
|
||||
public FCommandCreate() {
|
||||
aliases = new ArrayList<String>();
|
||||
aliases.add("create");
|
||||
|
||||
requiredParameters = new ArrayList<String>();
|
||||
optionalParameters = new ArrayList<String>();
|
||||
requiredParameters.add("faction tag");
|
||||
@ -51,8 +54,8 @@ public class FCommandCreate extends FBaseCommand {
|
||||
follower.sendMessage(me.getNameAndRelevant(follower)+Conf.colorSystem+" created a new faction "+faction.getTag(follower));
|
||||
}
|
||||
|
||||
sendMessage("Now update your faction description. Use:");
|
||||
sendMessage(Conf.colorCommand+Conf.aliasBase.get(0)+" "+Conf.aliasDescription.get(0)+" "+"[description]");
|
||||
sendMessage("You should now:");
|
||||
sendMessage( new FCommandDescription().getUseageTemplate() );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,10 @@ import com.bukkit.mcteam.factions.struct.Role;
|
||||
public class FCommandDeinvite extends FBaseCommand {
|
||||
|
||||
public FCommandDeinvite() {
|
||||
aliases = new ArrayList<String>();
|
||||
aliases.add("deinvite");
|
||||
aliases.add("deinv");
|
||||
|
||||
requiredParameters = new ArrayList<String>();
|
||||
optionalParameters = new ArrayList<String>();
|
||||
requiredParameters.add("player name");
|
||||
@ -41,6 +45,7 @@ public class FCommandDeinvite extends FBaseCommand {
|
||||
|
||||
if (you.getFaction() == myFaction) {
|
||||
sendMessage(you.getName()+" is already a member of "+myFaction.getTag());
|
||||
sendMessage(new FCommandKick().getUseageTemplate());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -10,9 +10,12 @@ import com.bukkit.mcteam.factions.util.TextUtil;
|
||||
public class FCommandDescription extends FBaseCommand {
|
||||
|
||||
public FCommandDescription() {
|
||||
aliases = new ArrayList<String>();
|
||||
aliases.add("desc");
|
||||
|
||||
requiredParameters = new ArrayList<String>();
|
||||
optionalParameters = new ArrayList<String>();
|
||||
requiredParameters.add("description");
|
||||
requiredParameters.add("desc");
|
||||
|
||||
permissions = "";
|
||||
|
||||
|
@ -8,6 +8,11 @@ import com.bukkit.mcteam.factions.util.TextUtil;
|
||||
public class FCommandHelp extends FBaseCommand {
|
||||
|
||||
public FCommandHelp() {
|
||||
aliases = new ArrayList<String>();
|
||||
aliases.add("help");
|
||||
aliases.add("h");
|
||||
aliases.add("?");
|
||||
|
||||
requiredParameters = new ArrayList<String>();
|
||||
optionalParameters = new ArrayList<String>();
|
||||
optionalParameters.add("page");
|
||||
@ -48,36 +53,36 @@ public class FCommandHelp extends FBaseCommand {
|
||||
ArrayList<String> pageLines;
|
||||
|
||||
pageLines = new ArrayList<String>();
|
||||
pageLines.add( new FCommandHelp().getUseageTemplate() );
|
||||
pageLines.add( new FCommandList().getUseageTemplate() );
|
||||
pageLines.add( new FCommandShow().getUseageTemplate() );
|
||||
pageLines.add( new FCommandMap().getUseageTemplate() );
|
||||
pageLines.add( new FCommandJoin().getUseageTemplate() );
|
||||
pageLines.add( new FCommandLeave().getUseageTemplate() );
|
||||
pageLines.add( new FCommandChat().getUseageTemplate() );
|
||||
pageLines.add( new FCommandCreate().getUseageTemplate() );
|
||||
pageLines.add( new FCommandTag().getUseageTemplate() );
|
||||
pageLines.add( new FCommandDescription().getUseageTemplate() );
|
||||
pageLines.add( new FCommandHelp().getUseageTemplate(true, true) );
|
||||
pageLines.add( new FCommandList().getUseageTemplate(true, true) );
|
||||
pageLines.add( new FCommandShow().getUseageTemplate(true, true) );
|
||||
pageLines.add( new FCommandMap().getUseageTemplate(true, true) );
|
||||
pageLines.add( new FCommandJoin().getUseageTemplate(true, true) );
|
||||
pageLines.add( new FCommandLeave().getUseageTemplate(true, true) );
|
||||
pageLines.add( new FCommandChat().getUseageTemplate(true, true) );
|
||||
pageLines.add( new FCommandCreate().getUseageTemplate(true, true) );
|
||||
pageLines.add( new FCommandTag().getUseageTemplate(true, true) );
|
||||
pageLines.add( new FCommandDescription().getUseageTemplate(true, true) );
|
||||
|
||||
helpPages.add(pageLines);
|
||||
pageLines = new ArrayList<String>();
|
||||
|
||||
pageLines.add( new FCommandOpen().getUseageTemplate() );
|
||||
pageLines.add( new FCommandTitle().getUseageTemplate() );
|
||||
pageLines.add( new FCommandInvite().getUseageTemplate() );
|
||||
pageLines.add( new FCommandDeinvite().getUseageTemplate() );
|
||||
pageLines.add( new FCommandClaim().getUseageTemplate() );
|
||||
pageLines.add( new FCommandUnclaim().getUseageTemplate() );
|
||||
pageLines.add( new FCommandKick().getUseageTemplate() );
|
||||
pageLines.add( new FCommandMod().getUseageTemplate() );
|
||||
pageLines.add( new FCommandAdmin().getUseageTemplate() );
|
||||
pageLines.add( new FCommandOpen().getUseageTemplate(true, true) );
|
||||
pageLines.add( new FCommandTitle().getUseageTemplate(true, true) );
|
||||
pageLines.add( new FCommandInvite().getUseageTemplate(true, true) );
|
||||
pageLines.add( new FCommandDeinvite().getUseageTemplate(true, true) );
|
||||
pageLines.add( new FCommandClaim().getUseageTemplate(true, true) );
|
||||
pageLines.add( new FCommandUnclaim().getUseageTemplate(true, true) );
|
||||
pageLines.add( new FCommandKick().getUseageTemplate(true, true) );
|
||||
pageLines.add( new FCommandMod().getUseageTemplate(true, true) );
|
||||
pageLines.add( new FCommandAdmin().getUseageTemplate(true, true) );
|
||||
|
||||
helpPages.add(pageLines);
|
||||
pageLines = new ArrayList<String>();
|
||||
|
||||
pageLines.add( new FCommandRelationAlly().getUseageTemplate() );
|
||||
pageLines.add( new FCommandRelationNeutral().getUseageTemplate() );
|
||||
pageLines.add( new FCommandRelationEnemy().getUseageTemplate() );
|
||||
pageLines.add( new FCommandRelationAlly().getUseageTemplate(true, true) );
|
||||
pageLines.add( new FCommandRelationNeutral().getUseageTemplate(true, true) );
|
||||
pageLines.add( new FCommandRelationEnemy().getUseageTemplate(true, true) );
|
||||
pageLines.add("");
|
||||
pageLines.add(Conf.colorSystem+"Set the relation you WISH to have with another faction.");
|
||||
pageLines.add(Conf.colorSystem+"Your default relation with other factions will be neutral.");
|
||||
@ -114,7 +119,7 @@ public class FCommandHelp extends FBaseCommand {
|
||||
helpPages.add(pageLines);
|
||||
pageLines = new ArrayList<String>();
|
||||
|
||||
pageLines.add( new FCommandVersion().getUseageTemplate() );
|
||||
pageLines.add( new FCommandVersion().getUseageTemplate(true, true) );
|
||||
|
||||
helpPages.add(pageLines);
|
||||
}
|
||||
|
@ -10,6 +10,10 @@ import com.bukkit.mcteam.factions.struct.Role;
|
||||
public class FCommandInvite extends FBaseCommand {
|
||||
|
||||
public FCommandInvite() {
|
||||
aliases = new ArrayList<String>();
|
||||
aliases.add("invite");
|
||||
aliases.add("inv");
|
||||
|
||||
requiredParameters = new ArrayList<String>();
|
||||
optionalParameters = new ArrayList<String>();
|
||||
requiredParameters.add("player name");
|
||||
@ -41,7 +45,8 @@ public class FCommandInvite extends FBaseCommand {
|
||||
|
||||
if (you.getFaction() == myFaction) {
|
||||
sendMessage(you.getName()+" is already a member of "+myFaction.getTag());
|
||||
sendMessage("You might want to "+Conf.colorCommand+Conf.aliasBase.get(0)+" "+Conf.aliasKick.get(0)+Conf.colorParameter+" "+you.getName());
|
||||
sendMessage("You might want to :");
|
||||
sendMessage(new FCommandKick().getUseageTemplate());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,9 @@ import com.bukkit.mcteam.factions.Faction;
|
||||
public class FCommandJoin extends FBaseCommand {
|
||||
|
||||
public FCommandJoin() {
|
||||
aliases = new ArrayList<String>();
|
||||
aliases.add("join");
|
||||
|
||||
requiredParameters = new ArrayList<String>();
|
||||
optionalParameters = new ArrayList<String>();
|
||||
requiredParameters.add("faction name");
|
||||
|
@ -9,6 +9,9 @@ import com.bukkit.mcteam.factions.Faction;
|
||||
public class FCommandKick extends FBaseCommand {
|
||||
|
||||
public FCommandKick() {
|
||||
aliases = new ArrayList<String>();
|
||||
aliases.add("kick");
|
||||
|
||||
requiredParameters = new ArrayList<String>();
|
||||
optionalParameters = new ArrayList<String>();
|
||||
requiredParameters.add("player name");
|
||||
@ -37,7 +40,8 @@ public class FCommandKick extends FBaseCommand {
|
||||
|
||||
if (me == you) {
|
||||
sendMessage("You cannot kick yourself.");
|
||||
sendMessage("You might want to "+Conf.colorCommand+Conf.aliasBase.get(0)+" "+Conf.aliasLeave.get(0));
|
||||
sendMessage("You might want to:");
|
||||
sendMessage(new FCommandLeave().getUseageTemplate());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,9 @@ import com.bukkit.mcteam.factions.struct.Role;
|
||||
public class FCommandLeave extends FBaseCommand {
|
||||
|
||||
public FCommandLeave() {
|
||||
aliases = new ArrayList<String>();
|
||||
aliases.add("leave");
|
||||
|
||||
requiredParameters = new ArrayList<String>();
|
||||
optionalParameters = new ArrayList<String>();
|
||||
|
||||
|
@ -11,6 +11,10 @@ import com.bukkit.mcteam.factions.util.TextUtil;
|
||||
public class FCommandList extends FBaseCommand {
|
||||
|
||||
public FCommandList() {
|
||||
aliases = new ArrayList<String>();
|
||||
aliases.add("list");
|
||||
aliases.add("ls");
|
||||
|
||||
requiredParameters = new ArrayList<String>();
|
||||
optionalParameters = new ArrayList<String>();
|
||||
optionalParameters.add("page");
|
||||
|
@ -3,12 +3,14 @@ package com.bukkit.mcteam.factions.commands;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.bukkit.mcteam.factions.Board;
|
||||
import com.bukkit.mcteam.factions.Conf;
|
||||
import com.bukkit.mcteam.factions.FLocation;
|
||||
|
||||
public class FCommandMap extends FBaseCommand {
|
||||
|
||||
public FCommandMap() {
|
||||
aliases = new ArrayList<String>();
|
||||
aliases.add("map");
|
||||
|
||||
requiredParameters = new ArrayList<String>();
|
||||
optionalParameters = new ArrayList<String>();
|
||||
optionalParameters.add("on|off");
|
||||
@ -23,7 +25,7 @@ public class FCommandMap extends FBaseCommand {
|
||||
public void perform() {
|
||||
if (parameters.size() > 0) {
|
||||
String mapAutoUpdating = parameters.get(0);
|
||||
if (Conf.aliasTrue.contains(mapAutoUpdating.toLowerCase())) {
|
||||
if (parseBool(mapAutoUpdating)) {
|
||||
// Turn on
|
||||
me.setMapAutoUpdating(true);
|
||||
sendMessage("Map auto update ENABLED.");
|
||||
|
@ -10,6 +10,9 @@ import com.bukkit.mcteam.factions.struct.Role;
|
||||
public class FCommandMod extends FBaseCommand {
|
||||
|
||||
public FCommandMod() {
|
||||
aliases = new ArrayList<String>();
|
||||
aliases.add("mod");
|
||||
|
||||
requiredParameters = new ArrayList<String>();
|
||||
optionalParameters = new ArrayList<String>();
|
||||
requiredParameters.add("player name");
|
||||
|
@ -9,6 +9,10 @@ import com.bukkit.mcteam.factions.struct.Role;
|
||||
public class FCommandOpen extends FBaseCommand {
|
||||
|
||||
public FCommandOpen() {
|
||||
aliases = new ArrayList<String>();
|
||||
aliases.add("open");
|
||||
aliases.add("close");
|
||||
|
||||
requiredParameters = new ArrayList<String>();
|
||||
optionalParameters = new ArrayList<String>();
|
||||
|
||||
|
@ -1,9 +1,16 @@
|
||||
package com.bukkit.mcteam.factions.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.bukkit.mcteam.factions.struct.Relation;
|
||||
|
||||
public class FCommandRelationAlly extends FRelationCommand {
|
||||
|
||||
public FCommandRelationAlly() {
|
||||
aliases = new ArrayList<String>();
|
||||
aliases.add("ally");
|
||||
}
|
||||
|
||||
public void perform() {
|
||||
relation(Relation.ALLY, parameters.get(0));
|
||||
}
|
||||
|
@ -1,9 +1,16 @@
|
||||
package com.bukkit.mcteam.factions.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.bukkit.mcteam.factions.struct.Relation;
|
||||
|
||||
public class FCommandRelationEnemy extends FRelationCommand {
|
||||
|
||||
public FCommandRelationEnemy() {
|
||||
aliases = new ArrayList<String>();
|
||||
aliases.add("enemy");
|
||||
}
|
||||
|
||||
public void perform() {
|
||||
relation(Relation.ENEMY, parameters.get(0));
|
||||
}
|
||||
|
@ -1,9 +1,16 @@
|
||||
package com.bukkit.mcteam.factions.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.bukkit.mcteam.factions.struct.Relation;
|
||||
|
||||
public class FCommandRelationNeutral extends FRelationCommand {
|
||||
|
||||
public FCommandRelationNeutral() {
|
||||
aliases = new ArrayList<String>();
|
||||
aliases.add("neutral");
|
||||
}
|
||||
|
||||
public void perform() {
|
||||
relation(Relation.NEUTRAL, parameters.get(0));
|
||||
}
|
||||
|
@ -13,6 +13,10 @@ import com.bukkit.mcteam.factions.util.TextUtil;
|
||||
public class FCommandShow extends FBaseCommand {
|
||||
|
||||
public FCommandShow() {
|
||||
aliases = new ArrayList<String>();
|
||||
aliases.add("show");
|
||||
aliases.add("who");
|
||||
|
||||
requiredParameters = new ArrayList<String>();
|
||||
optionalParameters = new ArrayList<String>();
|
||||
optionalParameters.add("faction tag");
|
||||
|
@ -10,6 +10,9 @@ import com.bukkit.mcteam.factions.util.TextUtil;
|
||||
public class FCommandTag extends FBaseCommand {
|
||||
|
||||
public FCommandTag() {
|
||||
aliases = new ArrayList<String>();
|
||||
aliases.add("tag");
|
||||
|
||||
requiredParameters = new ArrayList<String>();
|
||||
optionalParameters = new ArrayList<String>();
|
||||
requiredParameters.add("faction tag");
|
||||
|
@ -10,6 +10,9 @@ import com.bukkit.mcteam.factions.util.TextUtil;
|
||||
public class FCommandTitle extends FBaseCommand {
|
||||
|
||||
public FCommandTitle() {
|
||||
aliases = new ArrayList<String>();
|
||||
aliases.add("title");
|
||||
|
||||
requiredParameters = new ArrayList<String>();
|
||||
optionalParameters = new ArrayList<String>();
|
||||
requiredParameters.add("player name");
|
||||
|
@ -11,6 +11,10 @@ import com.bukkit.mcteam.factions.struct.Role;
|
||||
public class FCommandUnclaim extends FBaseCommand {
|
||||
|
||||
public FCommandUnclaim() {
|
||||
aliases = new ArrayList<String>();
|
||||
aliases.add("unclaim");
|
||||
aliases.add("declaim");
|
||||
|
||||
requiredParameters = new ArrayList<String>();
|
||||
optionalParameters = new ArrayList<String>();
|
||||
|
||||
|
@ -7,6 +7,9 @@ import com.bukkit.mcteam.factions.Factions;
|
||||
public class FCommandVersion extends FBaseCommand {
|
||||
|
||||
public FCommandVersion() {
|
||||
aliases = new ArrayList<String>();
|
||||
aliases.add("version");
|
||||
|
||||
requiredParameters = new ArrayList<String>();
|
||||
optionalParameters = new ArrayList<String>();
|
||||
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.ChatColor;
|
||||
|
||||
import com.bukkit.mcteam.factions.Conf;
|
||||
import com.bukkit.mcteam.factions.Faction;
|
||||
import com.bukkit.mcteam.factions.Factions;
|
||||
import com.bukkit.mcteam.factions.struct.Relation;
|
||||
import com.bukkit.mcteam.factions.struct.Role;
|
||||
|
||||
@ -15,7 +16,7 @@ public class FRelationCommand extends FBaseCommand {
|
||||
requiredParameters = new ArrayList<String>();
|
||||
optionalParameters = new ArrayList<String>();
|
||||
requiredParameters.add("faction tag");
|
||||
helpDescription = "Declare your factions relation wish to another faction";
|
||||
helpDescription = "Set relation wish to another faction";
|
||||
permissions = "";
|
||||
|
||||
senderMustBePlayer = true;
|
||||
@ -54,7 +55,7 @@ public class FRelationCommand extends FBaseCommand {
|
||||
myFaction.sendMessage(Conf.colorSystem+"Your faction is now "+currentRelationColor+whishedRelation.toString()+Conf.colorSystem+" to "+currentRelationColor+otherFaction.getTag());
|
||||
} else {
|
||||
otherFaction.sendMessage(currentRelationColor+myFaction.getTag()+Conf.colorSystem+ " wishes to be your "+whishedRelation.getColor()+whishedRelation.toString());
|
||||
otherFaction.sendMessage(Conf.colorSystem+"Type "+Conf.colorCommand+Conf.aliasBase.get(0)+" "+whishedRelation+" "+myFaction.getTag()+Conf.colorSystem+" to accept.");
|
||||
otherFaction.sendMessage(Conf.colorSystem+"Type "+Conf.colorCommand+Factions.instance.getBaseCommand()+" "+whishedRelation+" "+myFaction.getTag()+Conf.colorSystem+" to accept.");
|
||||
myFaction.sendMessage(currentRelationColor+otherFaction.getTag()+Conf.colorSystem+ " were informed that you wish to be "+whishedRelation.getColor()+whishedRelation);
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,14 @@
|
||||
package com.bukkit.mcteam.factions.listeners;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.event.player.PlayerItemEvent;
|
||||
@ -13,6 +17,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
import com.bukkit.mcteam.factions.Board;
|
||||
import com.bukkit.mcteam.factions.Conf;
|
||||
import com.bukkit.mcteam.factions.FLocation;
|
||||
import com.bukkit.mcteam.factions.FPlayer;
|
||||
import com.bukkit.mcteam.factions.Faction;
|
||||
import com.bukkit.mcteam.factions.Factions;
|
||||
@ -21,43 +26,31 @@ import com.bukkit.mcteam.factions.util.TextUtil;
|
||||
|
||||
public class FactionsPlayerListener extends PlayerListener{
|
||||
|
||||
/**
|
||||
* If someone says something that starts with the factions base command
|
||||
* we handle that command.
|
||||
*/
|
||||
@Override
|
||||
public void onPlayerCommandPreprocess(PlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
String msg = event.getMessage();
|
||||
|
||||
if (handleCommandOrChat(player, msg)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerChat(PlayerChatEvent event) {
|
||||
if ((event.getMessage().startsWith(Factions.instance.getBaseCommand()+" ") || event.getMessage().equals(Factions.instance.getBaseCommand())) && Conf.allowNoSlashCommand) {
|
||||
List<String> parameters = TextUtil.split(event.getMessage().trim());
|
||||
parameters.remove(0);
|
||||
CommandSender sender = event.getPlayer();
|
||||
Factions.instance.handleCommand(sender, parameters);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return; // Some other plugin ate this...
|
||||
return;
|
||||
}
|
||||
|
||||
Player talkingPlayer = event.getPlayer();
|
||||
String msg = event.getMessage();
|
||||
|
||||
// Is this a faction command?...
|
||||
if ( handleCommandOrChat(talkingPlayer, msg) ) {
|
||||
// ... Yes it was! We should choke the chat message.
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// ... it was not a command. This means that it is a chat message!
|
||||
FPlayer me = FPlayer.get(talkingPlayer);
|
||||
|
||||
// Is it a faction chat message?
|
||||
if (me.isFactionChatting()) {
|
||||
String message = String.format(Conf.factionChatFormat, me.getNameAndRelevant(me), msg);
|
||||
me.getFaction().sendMessage(message, false);
|
||||
me.getFaction().sendMessage(message);
|
||||
Logger.getLogger("Minecraft").info("FactionChat "+me.getFaction().getTag()+": "+message);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -95,27 +88,16 @@ public class FactionsPlayerListener extends PlayerListener{
|
||||
}
|
||||
}
|
||||
|
||||
public boolean handleCommandOrChat(Player player, String msg) {
|
||||
ArrayList<String> tokens = TextUtil.split(msg.trim());
|
||||
if (Conf.aliasBase.contains(tokens.get(0))) {
|
||||
tokens.remove(0);
|
||||
FPlayer follower = FPlayer.get(player);
|
||||
Commands.base(follower, tokens);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerJoin(PlayerEvent event) {
|
||||
//Follower.get(event.getPlayer()).sendJoinInfo();
|
||||
// Make sure that all online players do have a fplayer.
|
||||
FPlayer.get(event.getPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerQuit(PlayerEvent event) {
|
||||
FPlayer follower = FPlayer.get(event.getPlayer());
|
||||
Log.debug("Saved follower on player quit: "+follower.getName());
|
||||
follower.save(); // We save the followers on logout in order to save their non autosaved state like power.
|
||||
// Save all players on player quit.
|
||||
FPlayer.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -123,22 +105,23 @@ public class FactionsPlayerListener extends PlayerListener{
|
||||
FPlayer me = FPlayer.get(event.getPlayer());
|
||||
|
||||
// Did we change coord?
|
||||
Coord coordFrom = me.lastStoodAt;
|
||||
Coord coordTo = Coord.from(event.getTo());
|
||||
if (coordFrom.equals(coordTo)) {
|
||||
FLocation from = me.getLastStoodAt();
|
||||
FLocation to = new FLocation(event.getTo());
|
||||
|
||||
if (from.equals(to)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Yes we did change coord (:
|
||||
me.lastStoodAt = coordTo;
|
||||
Board board = Board.get(event.getPlayer().getWorld());
|
||||
|
||||
me.setLastStoodAt(to);
|
||||
|
||||
if (me.isMapAutoUpdating()) {
|
||||
me.sendMessage(board.getMap(me.getFaction(), Coord.from(me), me.getPlayer().getLocation().getYaw()), false);
|
||||
me.sendMessage(Board.getMap(me.getFaction(), to, me.getPlayer().getLocation().getYaw()));
|
||||
} else {
|
||||
// Did we change "host"(faction)?
|
||||
Faction factionFrom = board.getFactionAt(coordFrom);
|
||||
Faction factionTo = board.getFactionAt(coordTo);
|
||||
Faction factionFrom = Board.getFactionAt(from);
|
||||
Faction factionTo = Board.getFactionAt(to);
|
||||
if ( factionFrom != factionTo) {
|
||||
me.sendFactionHereMessage();
|
||||
}
|
||||
@ -147,17 +130,15 @@ public class FactionsPlayerListener extends PlayerListener{
|
||||
|
||||
@Override
|
||||
public void onPlayerItem(PlayerItemEvent event) {
|
||||
// debug
|
||||
//event.getPlayer().sendMessage("Item in hand: " + event.getItem().getTypeId() + " Block clicked: " + event.getBlockClicked().getTypeId() + "(" + event.getBlockClicked().getType().toString() + ")");
|
||||
|
||||
if (event.isCancelled())
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getBlockClicked() == null)
|
||||
if (event.getBlockClicked() == null) {
|
||||
return; // right-clicked on air, not a block; no worries then
|
||||
}
|
||||
|
||||
if (!this.playerCanUseItemHere(event.getPlayer(), event.getBlockClicked(), event.getItem().getTypeId()))
|
||||
{
|
||||
if ( ! this.playerCanUseItemHere(event.getPlayer(), event.getBlockClicked(), event.getItem().getTypeId())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -171,14 +152,13 @@ public class FactionsPlayerListener extends PlayerListener{
|
||||
|
||||
public boolean playerCanUseItemHere(Player player, Block block, int itemId) {
|
||||
|
||||
if (!badItems.contains(new Integer(itemId))) {
|
||||
if ( ! badItems.contains(new Integer(itemId))) {
|
||||
return true; // Item isn't one we're preventing.
|
||||
}
|
||||
|
||||
Coord coord = Coord.parseCoord(block);
|
||||
Faction otherFaction = Board.get(player.getWorld()).getFactionAt(coord);
|
||||
Faction otherFaction = Board.getFactionAt(new FLocation(block));
|
||||
|
||||
if (otherFaction == null || otherFaction.id == 0) {
|
||||
if (otherFaction == null || otherFaction.getId() == 0) {
|
||||
return true; // This is not faction territory. Use whatever you like here.
|
||||
}
|
||||
|
||||
@ -187,7 +167,7 @@ public class FactionsPlayerListener extends PlayerListener{
|
||||
|
||||
// Cancel if we are not in our own territory
|
||||
if (myFaction != otherFaction) {
|
||||
me.sendMessage(Conf.colorSystem+"You can't use that in the territory of "+otherFaction.getTag(myFaction));
|
||||
me.sendMessage("You can't use that in the territory of "+otherFaction.getTag(myFaction));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user