This would be v1.0 beta2. Just live testing on mcteam.org left to do.

This commit is contained in:
Olof Larsson 2011-02-07 21:42:14 +01:00
parent d370dcf8c2
commit 46a814a11e
13 changed files with 71 additions and 106 deletions

View File

@ -47,7 +47,7 @@ You can download it here: [http://bamboo.lukegb.com/browse/BUKKIT-BUKKITMAIN/](h
<b>You will also need Google GSON in your build path.</b><br/>
You can download it here: [http://code.google.com/p/google-gson/](http://code.google.com/p/google-gson/)<br/>
<b>OR</b> you can use the file in this repo `/packaging/gson.jar`<br/>
<b>OR</b> you can use the file in this repo `/packaging/your_minecraft_server/gson.jar`<br/>
However you won't get javadocs and source that way.
You will need to include the MANIFEST.MF and plugin.yml in your jar. All bukkit plugins need a plugin.yml and the MANIFEST.MF is needed for the plugin to find the gson.jar (wich should be in the same folder as the main server jar when running the server).

View File

@ -1,3 +1,3 @@
name: Factions
version: 1.0 beta1
version: 1.0 beta2
main: com.bukkit.mcteam.factions.Factions

View File

@ -24,7 +24,7 @@ public class Commands {
pageLines.add(TextUtil.commandHelp(Conf.aliasHelp, "[page]", "Display this, or the next help page"));
pageLines.add(TextUtil.commandHelp(Conf.aliasList, "", "List all factions"));
pageLines.add(TextUtil.commandHelp(Conf.aliasShow, "*[faction name]", "Show faction information")); // TODO display relations!
pageLines.add(TextUtil.commandHelp(Conf.aliasMap, "*[on|off]", "Show territory map, set optional auto update.")); // TODO COMPASS
pageLines.add(TextUtil.commandHelp(Conf.aliasMap, "*[on|off]", "Show territory map, set optional auto update."));
pageLines.add(TextUtil.commandHelp(Conf.aliasJoin, "[faction name]", "Join a faction"));
pageLines.add(TextUtil.commandHelp(Conf.aliasLeave, "", "Leave your faction"));
pageLines.add(TextUtil.commandHelp(Conf.aliasCreate, "[faction name]", "Create new faction"));
@ -38,8 +38,8 @@ public class Commands {
pageLines.add(TextUtil.commandHelp(Conf.aliasInvite, "[player name]", "Invite player"));
pageLines.add(TextUtil.commandHelp(Conf.aliasDeinvite, "[player name]", "Remove a pending invitation"));
pageLines.add(TextUtil.commandHelp(Conf.aliasKick, "[player name]", "Kick a player from the faction"));
pageLines.add(TextUtil.commandHelp(Conf.aliasModerator, "[player name]", "Give or revoke moderator rights")); // TODO
pageLines.add(TextUtil.commandHelp(Conf.aliasAdmin, "[player name]", "Hand over your admin rights")); // TODO
pageLines.add(TextUtil.commandHelp(Conf.aliasModerator, "[player name]", "Give or revoke moderator rights"));
pageLines.add(TextUtil.commandHelp(Conf.aliasAdmin, "[player name]", "Hand over your admin rights"));
pageLines.add(TextUtil.commandHelp(Conf.aliasClaim, "", "Claim the land where you are standing"));
pageLines.add(TextUtil.commandHelp(Conf.aliasUnclaim, "", "Unclaim the land where you are standing"));
@ -213,9 +213,7 @@ public class Commands {
} else if (Conf.aliasVersion.contains(command)) {
version(me);
} else {
//me.sendMessage(Conf.colorSystem+"Unknown faction command"+Conf.colorCommand+" "+command);
me.sendMessage(Conf.colorSystem+"Unknown faction command"+Conf.colorCommand+" "+command);
//me.getPlayer().sendMessage(TextUtil.repeat(tokens.get(0), Integer.parseInt(tokens.get(1))));
}
}
@ -243,14 +241,14 @@ public class Commands {
me.sendMessage(errors);
if (errors.size() == 0) {
faction.sendMessage(me.getFullName(faction)+Conf.colorAction+" left your faction.");
faction.sendMessage(me.getFullName(faction)+Conf.colorSystem+" left your faction.");
me.sendMessage("You left "+faction.getName(me));
}
if (faction.getFollowersAll().size() == 0) {
// Remove this faction
for (Follower follower : Follower.getAll()) {
follower.sendMessage(Conf.colorAction+"The faction "+faction.getName(follower)+Conf.colorAction+" was disbandoned.");
follower.sendMessage(Conf.colorSystem+"The faction "+faction.getName(follower)+Conf.colorSystem+" was disbandoned.");
}
EM.factionDelete(faction.id);
}
@ -268,18 +266,38 @@ public class Commands {
if (errors.size() > 0) {
faction.sendMessage(me.getFullName(faction)+Conf.colorSystem+" tried to join your faction.");
} else {
me.sendMessage(Conf.colorAction+"You successfully joined "+faction.getName(me));
faction.sendMessage(me.getFullName(faction)+Conf.colorAction+" joined your faction.");
me.sendMessage(Conf.colorSystem+"You successfully joined "+faction.getName(me));
faction.sendMessage(me.getFullName(faction)+Conf.colorSystem+" joined your faction.");
}
}
// TODO MOVE OUT
public static void create(Follower me, String name) {
ArrayList<String> errors = me.createFaction(name);
me.sendMessage(errors);
ArrayList<String> errors = new ArrayList<String>();
if (errors.size() == 0) {
me.sendMessage(Conf.colorAction+"Faction created!");
if (me.factionId != 0) {
errors.add(Conf.colorSystem+"You must leave your current faction first.");
}
if (Faction.isNameTaken(name)) {
errors.add(Conf.colorSystem+"That name is already in use.");
}
errors.addAll(Faction.validateName(name));
if (errors.size() > 0) {
me.sendMessage(errors);
return;
}
Faction faction = EM.factionCreate();
faction.setName(name);
faction.save();
me.join(faction);
me.role = Role.ADMIN;
me.save();
for (Follower follower : Follower.getAll()) {
follower.sendMessage(me.getFullName(follower)+Conf.colorSystem+" created a new faction "+faction.getName(follower));
}
}
@ -392,11 +410,11 @@ public class Commands {
if (Conf.aliasTrue.contains(mapAutoUpdating.toLowerCase())) {
// Turn on
me.setMapAutoUpdating(true);
me.sendMessage(Conf.colorAction + "Map auto update ENABLED.");
me.sendMessage(Conf.colorSystem + "Map auto update ENABLED.");
} else {
// Turn off
me.setMapAutoUpdating(false);
me.sendMessage(Conf.colorAction + "Map auto update DISABLED.");
me.sendMessage(Conf.colorSystem + "Map auto update DISABLED.");
}
} else {
me.sendMessage(Board.getMap(me.getFaction(), Coord.from(me), me.getPlayer().getLocation().getYaw()), false);
@ -416,7 +434,6 @@ public class Commands {
ChatColor relationColor = me.getRelationColor(follower);
follower.sendMessage(relationColor+me.getFullName()+Conf.colorSystem+" invited you to "+relationColor+me.getFaction().getName());
me.getFaction().sendMessage(me.getFullName(me)+Conf.colorSystem+" invited "+follower.getFullName(me)+Conf.colorSystem+" to your faction.");
//me.sendMessage(Conf.colorAction+"You invited "+relationColor+follower.getFullName()+Conf.colorAction+" to "+Relation.MEMBER.getColor()+me.getFaction().getName());
}
}
@ -690,7 +707,7 @@ public class Commands {
me.getFaction().setDescription(desc);
me.sendMessage(Conf.colorAction+"The new decription was set :D");
me.sendMessage(Conf.colorSystem+"The new decription was set :D");
// Broadcast the description to everyone
for (Follower follower : EM.followerGetAll()) {

View File

@ -10,6 +10,9 @@ import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import com.bukkit.mcteam.factions.entities.*;
import com.bukkit.mcteam.factions.listeners.FactionsBlockListener;
import com.bukkit.mcteam.factions.listeners.FactionsEntityListener;
import com.bukkit.mcteam.factions.listeners.FactionsPlayerListener;
import com.bukkit.mcteam.factions.util.Log;
public class Factions extends JavaPlugin {

View File

@ -114,10 +114,7 @@ public class Board {
// Get the compass
ArrayList<String> asciiCompass = AsciiCompass.getAsciiCompass(inDegrees, ChatColor.RED, Conf.colorChrome);
// Pad the compass some
asciiCompass.set(0, asciiCompass.get(0));
asciiCompass.set(1, asciiCompass.get(1));
asciiCompass.set(2, asciiCompass.get(2));
// Add the compass
ret.set(1, asciiCompass.get(0)+ret.get(1).substring(3*3));
ret.set(2, asciiCompass.get(1)+ret.get(2).substring(3*3));

View File

@ -30,7 +30,6 @@ public class Conf {
public static ChatColor colorEnemy;
public static ChatColor colorSystem;
public static ChatColor colorAction;
public static ChatColor colorChrome;
public static ChatColor colorCommand;
public static ChatColor colorParameter;
@ -43,8 +42,6 @@ public class Conf {
public static List<String> aliasShow = new ArrayList<String>();
public static List<String> aliasMap = new ArrayList<String>();
public static List<String> aliasHere = new ArrayList<String>();
public static List<String> aliasJoin = new ArrayList<String>();
public static List<String> aliasLeave = new ArrayList<String>();
@ -76,11 +73,9 @@ public class Conf {
public static List<String> aliasTrue = new ArrayList<String>();
// Power
public static double powerPerLand;
public static double powerPerPlayer;
public static double powerPerMinute; // Default health rate
public static double powerPerDeath;
public static double powerDefaultBonus;
// Protected blocks
public static List<Material> territoryProtectedMaterials = new ArrayList<Material>();
@ -89,15 +84,18 @@ public class Conf {
logThreshold = 10;
prefixAdmin = "**";
prefixMod = "*";
factionNameMinLength = 3;
factionNameMaxLength = 40;
useRelationColoredChat = true;
mapHeight = 8;
mapWidth = 49;
powerPerPlayer = 10; // One player has 10 power
powerPerMinute = 0.2; // Default health rate... it takes 5 min to heal one power
powerPerDeath = 2; //A death makes you loose 2 power
territoryShieldFactor = 0.5;
useRelationColoredChat = true;
territoryProtectedMaterials.add(Material.WOODEN_DOOR);
territoryProtectedMaterials.add(Material.DISPENSER);
territoryProtectedMaterials.add(Material.CHEST);
territoryProtectedMaterials.add(Material.FURNACE);
colorMember = ChatColor.GREEN;
colorAlly = ChatColor.LIGHT_PURPLE;
@ -105,7 +103,6 @@ public class Conf {
colorEnemy = ChatColor.RED;
colorSystem = ChatColor.YELLOW;
colorAction = ChatColor.LIGHT_PURPLE;
colorChrome = ChatColor.GOLD;
colorCommand = ChatColor.AQUA;
colorParameter = ChatColor.DARK_AQUA;
@ -128,7 +125,6 @@ public class Conf {
aliasShow.add("who");
aliasMap.add("map");
aliasHere.add("here");
aliasJoin.add("join");
@ -177,16 +173,11 @@ public class Conf {
aliasTrue.add("on");
aliasTrue.add("+");
powerPerLand = 1; // 1 power grants one land Perhaps this should not even be a config value...
powerPerPlayer = 10; // One player has 10 power
powerPerMinute = 0.2; // Default health rate... it takes 5 min to heal one power
powerPerDeath = 2; //A death makes you loose 2 power
powerDefaultBonus = 0; //A faction normally has a power bonus
factionNameMinLength = 3;
factionNameMaxLength = 40;
territoryProtectedMaterials.add(Material.WOODEN_DOOR);
territoryProtectedMaterials.add(Material.DISPENSER);
territoryProtectedMaterials.add(Material.CHEST);
territoryProtectedMaterials.add(Material.FURNACE);
mapHeight = 8;
mapWidth = 49;
}
//----------------------------------------------//

View File

@ -36,6 +36,7 @@ public class EM {
.create();
public static void loadAll() {
folderBase.mkdirs();
configLoad();
Log.threshold = Conf.logThreshold;
boardLoad();
@ -59,11 +60,12 @@ public class EM {
}
}
Log.info("No conf.json found! Creating a new one with the default values");
//configSave(); // FOR DEBUGGING...
configSave();
return true;
}
public static boolean configSave() {
folderBase.mkdirs();
try {
DiscUtil.write(fileConfig, gson.toJson(new Conf()));
Log.debug("Config was saved to disc");
@ -91,11 +93,12 @@ public class EM {
}
}
Log.info("No board.json found! Creating a new one with the default values");
//boardSave(); // FOR DEBUGGING...
boardSave();
return true;
}
public static boolean boardSave() {
folderBase.mkdirs();
try {
DiscUtil.write(fileBoard, gson.toJson(new Board()));
Log.debug("Board was saved to disc");

View File

@ -72,19 +72,15 @@ public class Faction {
// Power
//----------------------------------------------//
public double getPower() {
double ret = this.getPowerBonus();
double ret = 0;
for (Follower follower : this.getFollowersAll()) {
ret += follower.getPower();
}
return ret;
}
public double getPowerBonus() {
return Conf.powerDefaultBonus; // TODO this could be modified by commands later on
}
public double getPowerMax() {
double ret = this.getPowerBonus();
double ret = 0;
for (Follower follower : this.getFollowersAll()) {
ret += follower.getPowerMax();
}
@ -104,7 +100,7 @@ public class Faction {
}
public double getLandMax() {
return this.getPower() / Conf.powerPerLand;
return this.getPower();
}
public int getLandMaxRounded() {

View File

@ -203,33 +203,6 @@ public class Follower {
return errors;
}
public ArrayList<String> createFaction(String name) {
ArrayList<String> errors = new ArrayList<String>();
if (this.factionId != 0) {
errors.add(Conf.colorSystem+"You must leave your current faction first.");
}
if (Faction.isNameTaken(name)) {
errors.add(Conf.colorSystem+"That name is already in use.");
}
errors.addAll(Faction.validateName(name));
if (errors.size() > 0) {
return errors;
}
Faction faction = EM.factionCreate();
faction.setName(name);
faction.save();
this.join(faction);
this.role = Role.ADMIN;
this.save();
return errors;
}
public ArrayList<String> invite(Follower follower) {
ArrayList<String> errors = new ArrayList<String>();

View File

@ -1,4 +1,4 @@
package com.bukkit.mcteam.factions;
package com.bukkit.mcteam.factions.listeners;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -9,8 +9,9 @@ import org.bukkit.event.block.BlockInteractEvent;
import org.bukkit.event.block.BlockListener;
import org.bukkit.event.block.BlockPlaceEvent;
import com.bukkit.mcteam.factions.Factions;
import com.bukkit.mcteam.factions.entities.*;
import com.bukkit.mcteam.factions.util.TextUtil;
import com.bukkit.mcteam.factions.util.*;
public class FactionsBlockListener extends BlockListener {
public Factions plugin;

View File

@ -1,4 +1,4 @@
package com.bukkit.mcteam.factions;
package com.bukkit.mcteam.factions.listeners;
import java.text.DecimalFormat;
@ -9,6 +9,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityListener;
import com.bukkit.mcteam.factions.Factions;
import com.bukkit.mcteam.factions.entities.Conf;
import com.bukkit.mcteam.factions.entities.Follower;
import com.bukkit.mcteam.factions.struct.Relation;

View File

@ -1,4 +1,4 @@
package com.bukkit.mcteam.factions;
package com.bukkit.mcteam.factions.listeners;
import java.util.*;
@ -10,6 +10,8 @@ import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerMoveEvent;
import com.bukkit.mcteam.factions.Commands;
import com.bukkit.mcteam.factions.Factions;
import com.bukkit.mcteam.factions.entities.*;
import com.bukkit.mcteam.factions.util.*;

View File

@ -9,7 +9,6 @@ public enum Relation {
ALLY(2, "ally"),
NEUTRAL(1, "neutral"),
ENEMY(0, "enemy");
//UNKNOWN(-1, "unknown");
public final int value;
public final String nicename;
@ -27,22 +26,4 @@ public enum Relation {
public ChatColor getColor() {
return Conf.relationColor(this);
}
/*public String getChartDot() {
return Conf.chartDot(this);
}
public static Relation from(String str) {
if (str.equalsIgnoreCase("member")) {
return Relation.MEMBER;
} else if (str.equalsIgnoreCase("ally")) {
return Relation.ALLY;
} else if (str.equalsIgnoreCase("neutral")) {
return Relation.NEUTRAL;
} else if (str.equalsIgnoreCase("enemy")) {
return Relation.ENEMY;
}
return Relation.UNKNOWN;
}*/
}