From 654e3b159b485617bd2f649a43f91fd0530e8e84 Mon Sep 17 00:00:00 2001 From: Brettflan Date: Sun, 29 May 2011 16:41:50 -0500 Subject: [PATCH] New option to disallow players from leaving, joining, or being kicked from a faction while they have a negative power level - code by sp1ky, adapted from a pull request --- src/org/mcteam/factions/Conf.java | 3 +++ src/org/mcteam/factions/FPlayer.java | 5 +++++ src/org/mcteam/factions/commands/FCommandJoin.java | 5 +++++ src/org/mcteam/factions/commands/FCommandKick.java | 5 +++++ 4 files changed, 18 insertions(+) diff --git a/src/org/mcteam/factions/Conf.java b/src/org/mcteam/factions/Conf.java index c148cc47..d41cee2b 100644 --- a/src/org/mcteam/factions/Conf.java +++ b/src/org/mcteam/factions/Conf.java @@ -38,6 +38,9 @@ public class Conf { public static boolean showMapFactionKey = true; + // Disallow joining/leaving/kicking while power is negative + public static boolean CanLeaveWithNegativePower = true; + // Configuration on the Faction tag in chat messages. public static boolean chatTagEnabled = true; diff --git a/src/org/mcteam/factions/FPlayer.java b/src/org/mcteam/factions/FPlayer.java index 4bf8e552..342e0b94 100644 --- a/src/org/mcteam/factions/FPlayer.java +++ b/src/org/mcteam/factions/FPlayer.java @@ -375,6 +375,11 @@ public class FPlayer { return; } + if (!Conf.CanLeaveWithNegativePower && this.getPower() < 0) { + sendMessage("You cannot leave until your power is positive."); + return; + } + if (myFaction.isNormal()) { myFaction.sendMessage(this.getNameAndRelevant(myFaction) + Conf.colorSystem + " left your faction."); } diff --git a/src/org/mcteam/factions/commands/FCommandJoin.java b/src/org/mcteam/factions/commands/FCommandJoin.java index cc62e6cb..b0ad3460 100644 --- a/src/org/mcteam/factions/commands/FCommandJoin.java +++ b/src/org/mcteam/factions/commands/FCommandJoin.java @@ -42,6 +42,11 @@ public class FCommandJoin extends FBaseCommand { return; } + if (!Conf.CanLeaveWithNegativePower && me.getPower() < 0) { + sendMessage("You cannot join a faction until your power is positive."); + return; + } + if( ! faction.getOpen() && ! faction.isInvited(me)) { sendMessage("This guild requires invitation."); faction.sendMessage(me.getNameAndRelevant(faction)+Conf.colorSystem+" tried to join your faction."); diff --git a/src/org/mcteam/factions/commands/FCommandKick.java b/src/org/mcteam/factions/commands/FCommandKick.java index 663b7239..c390d560 100644 --- a/src/org/mcteam/factions/commands/FCommandKick.java +++ b/src/org/mcteam/factions/commands/FCommandKick.java @@ -46,6 +46,11 @@ public class FCommandKick extends FBaseCommand { return; } + if (!Conf.CanLeaveWithNegativePower && you.getPower() < 0) { + sendMessage("You cannot kick that member until their power is positive."); + return; + } + myFaction.deinvite(you); you.resetFactionData();