mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-12-27 02:58:07 +01:00
New command /f powerboost <p|f|player|faction> <name> <#>, which will apply a permanent power bonus/penalty to a specified player or faction. When applied to a player, it will affect their max power and min power. When applied to a faction, it will be applied to current and max power levels. Whether it is a bonus or a penalty depends on whether the number you specify is positive or negative.
New permission factions.powerboost which is required to use the above command. This permission is added to the factions.kit.mod permission kit. example usage: /f powerboost p Player1 1.5 (give player "Player1" a bonus of 1.5 power) /f powerboost f SomeFaction -6 (give faction "SomeFaction" a penalty of -6 power)
This commit is contained in:
parent
ff91cdfed7
commit
58e7e5e3f1
@ -25,9 +25,10 @@ permissions:
|
|||||||
children:
|
children:
|
||||||
factions.kit.halfmod: true
|
factions.kit.halfmod: true
|
||||||
factions.disband.any: true
|
factions.disband.any: true
|
||||||
|
factions.setpeaceful: true
|
||||||
factions.setpermanent: true
|
factions.setpermanent: true
|
||||||
factions.setpermanentpower: true
|
factions.setpermanentpower: true
|
||||||
factions.setpeaceful: true
|
factions.powerboost: true
|
||||||
factions.sethome.any: true
|
factions.sethome.any: true
|
||||||
factions.money.*: true
|
factions.money.*: true
|
||||||
factions.join.any: true
|
factions.join.any: true
|
||||||
@ -194,6 +195,8 @@ permissions:
|
|||||||
description: show player power info
|
description: show player power info
|
||||||
factions.power.any:
|
factions.power.any:
|
||||||
description: view an other players power level
|
description: view an other players power level
|
||||||
|
factions.powerboost:
|
||||||
|
description: apply permanent power bonus/penalty to specified player or faction
|
||||||
factions.relation:
|
factions.relation:
|
||||||
description: set relation wish to another faction
|
description: set relation wish to another faction
|
||||||
factions.reload:
|
factions.reload:
|
||||||
|
@ -62,6 +62,12 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
// FIELD: power
|
// FIELD: power
|
||||||
private double power;
|
private double power;
|
||||||
|
|
||||||
|
// FIELD: powerBoost
|
||||||
|
// special increase/decrease to min and max power for this player
|
||||||
|
private double powerBoost;
|
||||||
|
public double getPowerBoost() { return this.powerBoost; }
|
||||||
|
public void setPowerBoost(double powerBoost) { this.powerBoost = powerBoost; }
|
||||||
|
|
||||||
// FIELD: lastPowerUpdateTime
|
// FIELD: lastPowerUpdateTime
|
||||||
private long lastPowerUpdateTime;
|
private long lastPowerUpdateTime;
|
||||||
|
|
||||||
@ -161,6 +167,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
this.autoWarZoneEnabled = false;
|
this.autoWarZoneEnabled = false;
|
||||||
this.loginPvpDisabled = (Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0) ? true : false;
|
this.loginPvpDisabled = (Conf.noPVPDamageToOthersForXSecondsAfterLogin > 0) ? true : false;
|
||||||
this.deleteMe = false;
|
this.deleteMe = false;
|
||||||
|
this.powerBoost = 0.0;
|
||||||
|
|
||||||
if ( ! Conf.newPlayerStartingFactionID.equals("0") && Factions.i.exists(Conf.newPlayerStartingFactionID))
|
if ( ! Conf.newPlayerStartingFactionID.equals("0") && Factions.i.exists(Conf.newPlayerStartingFactionID))
|
||||||
{
|
{
|
||||||
@ -453,23 +460,19 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
|||||||
{
|
{
|
||||||
this.power += delta;
|
this.power += delta;
|
||||||
if (this.power > this.getPowerMax())
|
if (this.power > this.getPowerMax())
|
||||||
{
|
|
||||||
this.power = this.getPowerMax();
|
this.power = this.getPowerMax();
|
||||||
} else if (this.power < this.getPowerMin())
|
else if (this.power < this.getPowerMin())
|
||||||
{
|
|
||||||
this.power = this.getPowerMin();
|
this.power = this.getPowerMin();
|
||||||
}
|
}
|
||||||
//Log.debug("Power of "+this.getName()+" is now: "+this.power);
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getPowerMax()
|
public double getPowerMax()
|
||||||
{
|
{
|
||||||
return Conf.powerPlayerMax;
|
return Conf.powerPlayerMax + this.powerBoost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPowerMin()
|
public double getPowerMin()
|
||||||
{
|
{
|
||||||
return Conf.powerPlayerMin;
|
return Conf.powerPlayerMin + this.powerBoost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPowerRounded()
|
public int getPowerRounded()
|
||||||
|
@ -136,6 +136,13 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
public void setPermanentPower(Integer permanentPower) { this.permanentPower = permanentPower; }
|
public void setPermanentPower(Integer permanentPower) { this.permanentPower = permanentPower; }
|
||||||
public boolean hasPermanentPower() { return this.permanentPower != null; }
|
public boolean hasPermanentPower() { return this.permanentPower != null; }
|
||||||
|
|
||||||
|
// FIELD: powerBoost
|
||||||
|
// special increase/decrease to default and max power for this faction
|
||||||
|
private double powerBoost;
|
||||||
|
public double getPowerBoost() { return this.powerBoost; }
|
||||||
|
public void setPowerBoost(double powerBoost) { this.powerBoost = powerBoost; }
|
||||||
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// Construct
|
// Construct
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -152,6 +159,7 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
this.peacefulExplosionsEnabled = false;
|
this.peacefulExplosionsEnabled = false;
|
||||||
this.permanent = false;
|
this.permanent = false;
|
||||||
this.money = 0.0;
|
this.money = 0.0;
|
||||||
|
this.powerBoost = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -268,7 +276,7 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
{
|
{
|
||||||
ret = Conf.powerFactionMax;
|
ret = Conf.powerFactionMax;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret + this.powerBoost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getPowerMax()
|
public double getPowerMax()
|
||||||
@ -287,7 +295,7 @@ public class Faction extends Entity implements EconomyParticipator
|
|||||||
{
|
{
|
||||||
ret = Conf.powerFactionMax;
|
ret = Conf.powerFactionMax;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret + this.powerBoost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPowerRounded()
|
public int getPowerRounded()
|
||||||
|
@ -174,10 +174,16 @@ public class CmdHelp extends FCommand
|
|||||||
pageLines.add( p.cmdBase.cmdChatSpy.getUseageTemplate(true) );
|
pageLines.add( p.cmdBase.cmdChatSpy.getUseageTemplate(true) );
|
||||||
pageLines.add( p.cmdBase.cmdPermanent.getUseageTemplate(true) );
|
pageLines.add( p.cmdBase.cmdPermanent.getUseageTemplate(true) );
|
||||||
pageLines.add( p.cmdBase.cmdPermanentPower.getUseageTemplate(true) );
|
pageLines.add( p.cmdBase.cmdPermanentPower.getUseageTemplate(true) );
|
||||||
|
pageLines.add( p.cmdBase.cmdPowerBoost.getUseageTemplate(true) );
|
||||||
|
pageLines.add( p.cmdBase.cmdConfig.getUseageTemplate(true) );
|
||||||
|
helpPages.add(pageLines);
|
||||||
|
|
||||||
|
pageLines = new ArrayList<String>();
|
||||||
|
pageLines.add(p.txt.parse("<i>Even more commands for server admins:"));
|
||||||
pageLines.add( p.cmdBase.cmdLock.getUseageTemplate(true) );
|
pageLines.add( p.cmdBase.cmdLock.getUseageTemplate(true) );
|
||||||
pageLines.add( p.cmdBase.cmdReload.getUseageTemplate(true) );
|
pageLines.add( p.cmdBase.cmdReload.getUseageTemplate(true) );
|
||||||
pageLines.add( p.cmdBase.cmdSaveAll.getUseageTemplate(true) );
|
pageLines.add( p.cmdBase.cmdSaveAll.getUseageTemplate(true) );
|
||||||
pageLines.add( p.cmdBase.cmdConfig.getUseageTemplate(true) );
|
pageLines.add( p.cmdBase.cmdVersion.getUseageTemplate(true) );
|
||||||
helpPages.add(pageLines);
|
helpPages.add(pageLines);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,9 @@ public class CmdPower extends FCommand
|
|||||||
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
|
||||||
if ( ! payForCommand(Conf.econCostPower, "to show player power info", "for showing player power info")) return;
|
if ( ! payForCommand(Conf.econCostPower, "to show player power info", "for showing player power info")) return;
|
||||||
|
|
||||||
msg("%s<a> - Power / Maxpower: <i>%d / %d", target.describeTo(fme, true), target.getPowerRounded(), target.getPowerMaxRounded());
|
double powerBoost = target.getPowerBoost();
|
||||||
|
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? " (bonus: " : " (penalty: ") + powerBoost + ")";
|
||||||
|
msg("%s<a> - Power / Maxpower: <i>%d / %d %s", target.describeTo(fme, true), target.getPowerRounded(), target.getPowerMaxRounded(), boost);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
72
src/com/massivecraft/factions/cmd/CmdPowerBoost.java
Normal file
72
src/com/massivecraft/factions/cmd/CmdPowerBoost.java
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
package com.massivecraft.factions.cmd;
|
||||||
|
|
||||||
|
import com.massivecraft.factions.Faction;
|
||||||
|
import com.massivecraft.factions.FPlayer;
|
||||||
|
import com.massivecraft.factions.P;
|
||||||
|
import com.massivecraft.factions.struct.Permission;
|
||||||
|
|
||||||
|
public class CmdPowerBoost extends FCommand
|
||||||
|
{
|
||||||
|
public CmdPowerBoost()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
this.aliases.add("powerboost");
|
||||||
|
|
||||||
|
this.requiredArgs.add("p|f|player|faction");
|
||||||
|
this.requiredArgs.add("name");
|
||||||
|
this.requiredArgs.add("#");
|
||||||
|
|
||||||
|
this.permission = Permission.POWERBOOST.node;
|
||||||
|
this.disableOnLock = true;
|
||||||
|
|
||||||
|
senderMustBePlayer = false;
|
||||||
|
senderMustBeMember = false;
|
||||||
|
senderMustBeModerator = false;
|
||||||
|
senderMustBeAdmin = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void perform()
|
||||||
|
{
|
||||||
|
String type = this.argAsString(0).toLowerCase();
|
||||||
|
boolean doPlayer = true;
|
||||||
|
if (type.equals("f") || type.equals("faction"))
|
||||||
|
{
|
||||||
|
doPlayer = false;
|
||||||
|
}
|
||||||
|
else if (!type.equals("p") && !type.equals("player"))
|
||||||
|
{
|
||||||
|
msg("<b>You must specify \"p\" or \"player\" to target a player or \"f\" or \"faction\" to target a faction.");
|
||||||
|
msg("<b>ex. /f powerboost p SomePlayer 0.5 -or- /f powerboost f SomeFaction -5");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Double targetPower = this.argAsDouble(2);
|
||||||
|
if (targetPower == null)
|
||||||
|
{
|
||||||
|
msg("<b>You must specify a valid numeric value for the power bonus/penalty amount.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String target;
|
||||||
|
|
||||||
|
if (doPlayer)
|
||||||
|
{
|
||||||
|
FPlayer targetPlayer = this.argAsBestFPlayerMatch(1);
|
||||||
|
if (targetPlayer == null) return;
|
||||||
|
targetPlayer.setPowerBoost(targetPower);
|
||||||
|
target = "Player \""+targetPlayer.getName()+"\"";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Faction targetFaction = this.argAsFaction(1);
|
||||||
|
if (targetFaction == null) return;
|
||||||
|
targetFaction.setPowerBoost(targetPower);
|
||||||
|
target = "Faction \""+targetFaction.getTag()+"\"";
|
||||||
|
}
|
||||||
|
|
||||||
|
msg("<i>"+target+" now has a power bonus/penalty of "+targetPower+" to min and max power levels.");
|
||||||
|
if (!senderIsConsole)
|
||||||
|
P.p.log(fme.getName()+" has set the power bonus/penalty for "+target+" to "+targetPower+".");
|
||||||
|
}
|
||||||
|
}
|
@ -61,7 +61,10 @@ public class CmdShow extends FCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
msg("<a>Joining: <i>"+(faction.getOpen() ? "no invitation is needed" : "invitation is required")+peaceStatus);
|
msg("<a>Joining: <i>"+(faction.getOpen() ? "no invitation is needed" : "invitation is required")+peaceStatus);
|
||||||
msg("<a>Land / Power / Maxpower: <i> %d/%d/%d", faction.getLandRounded(), faction.getPowerRounded(), faction.getPowerMaxRounded());
|
|
||||||
|
double powerBoost = faction.getPowerBoost();
|
||||||
|
String boost = (powerBoost == 0.0) ? "" : (powerBoost > 0.0 ? " (bonus: " : " (penalty: ") + powerBoost + ")";
|
||||||
|
msg("<a>Land / Power / Maxpower: <i> %d/%d/%d %s", faction.getLandRounded(), faction.getPowerRounded(), faction.getPowerMaxRounded(), boost);
|
||||||
|
|
||||||
if (faction.isPermanent())
|
if (faction.isPermanent())
|
||||||
{
|
{
|
||||||
|
@ -35,6 +35,7 @@ public class FCmdRoot extends FCommand
|
|||||||
public CmdPeaceful cmdPeaceful = new CmdPeaceful();
|
public CmdPeaceful cmdPeaceful = new CmdPeaceful();
|
||||||
public CmdPermanent cmdPermanent = new CmdPermanent();
|
public CmdPermanent cmdPermanent = new CmdPermanent();
|
||||||
public CmdPermanentPower cmdPermanentPower = new CmdPermanentPower();
|
public CmdPermanentPower cmdPermanentPower = new CmdPermanentPower();
|
||||||
|
public CmdPowerBoost cmdPowerBoost = new CmdPowerBoost();
|
||||||
public CmdPower cmdPower = new CmdPower();
|
public CmdPower cmdPower = new CmdPower();
|
||||||
public CmdRelationAlly cmdRelationAlly = new CmdRelationAlly();
|
public CmdRelationAlly cmdRelationAlly = new CmdRelationAlly();
|
||||||
public CmdRelationEnemy cmdRelationEnemy = new CmdRelationEnemy();
|
public CmdRelationEnemy cmdRelationEnemy = new CmdRelationEnemy();
|
||||||
@ -103,6 +104,7 @@ public class FCmdRoot extends FCommand
|
|||||||
this.addSubCommand(this.cmdPermanent);
|
this.addSubCommand(this.cmdPermanent);
|
||||||
this.addSubCommand(this.cmdPermanentPower);
|
this.addSubCommand(this.cmdPermanentPower);
|
||||||
this.addSubCommand(this.cmdPower);
|
this.addSubCommand(this.cmdPower);
|
||||||
|
this.addSubCommand(this.cmdPowerBoost);
|
||||||
this.addSubCommand(this.cmdRelationAlly);
|
this.addSubCommand(this.cmdRelationAlly);
|
||||||
this.addSubCommand(this.cmdRelationEnemy);
|
this.addSubCommand(this.cmdRelationEnemy);
|
||||||
this.addSubCommand(this.cmdRelationNeutral);
|
this.addSubCommand(this.cmdRelationNeutral);
|
||||||
|
@ -50,6 +50,7 @@ public enum Permission
|
|||||||
SET_PEACEFUL("setpeaceful"),
|
SET_PEACEFUL("setpeaceful"),
|
||||||
SET_PERMANENT("setpermanent"),
|
SET_PERMANENT("setpermanent"),
|
||||||
SET_PERMANENTPOWER("setpermanentpower"),
|
SET_PERMANENTPOWER("setpermanentpower"),
|
||||||
|
POWERBOOST("powerboost"),
|
||||||
POWER("power"),
|
POWER("power"),
|
||||||
POWER_ANY("power.any"),
|
POWER_ANY("power.any"),
|
||||||
RELATION("relation"),
|
RELATION("relation"),
|
||||||
|
Loading…
Reference in New Issue
Block a user