Made /f kick command work on any player in any faction, if the person using the command has the admin-level "disband" permission
This commit is contained in:
parent
232ae5dce1
commit
787e6b867a
@ -581,8 +581,7 @@ public class FPlayer {
|
|||||||
|
|
||||||
public static FPlayer find(String playername) {
|
public static FPlayer find(String playername) {
|
||||||
for (Entry<String, FPlayer> entry : instances.entrySet()) {
|
for (Entry<String, FPlayer> entry : instances.entrySet()) {
|
||||||
// if (entry.getKey().equalsIgnoreCase(playername)) {
|
if (entry.getKey().equalsIgnoreCase(playername) || entry.getKey().startsWith(playername)) {
|
||||||
if (entry.getKey().startsWith(playername)) {
|
|
||||||
return entry.getValue();
|
return entry.getValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package org.mcteam.factions.commands;
|
|||||||
import org.mcteam.factions.Conf;
|
import org.mcteam.factions.Conf;
|
||||||
import org.mcteam.factions.FPlayer;
|
import org.mcteam.factions.FPlayer;
|
||||||
import org.mcteam.factions.Faction;
|
import org.mcteam.factions.Faction;
|
||||||
|
import org.mcteam.factions.Factions;
|
||||||
|
|
||||||
public class FCommandKick extends FBaseCommand {
|
public class FCommandKick extends FBaseCommand {
|
||||||
|
|
||||||
@ -29,19 +30,22 @@ public class FCommandKick extends FBaseCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Faction myFaction = me.getFaction();
|
|
||||||
|
|
||||||
if (you.getFaction() != myFaction) {
|
|
||||||
sendMessage(you.getNameAndRelevant(me)+Conf.colorSystem+" is not a member of "+myFaction.getTag(me));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (me == you) {
|
if (me == you) {
|
||||||
sendMessage("You cannot kick yourself.");
|
sendMessage("You cannot kick yourself.");
|
||||||
sendMessage("You might want to: " + new FCommandLeave().getUseageTemplate(false));
|
sendMessage("You might want to: " + new FCommandLeave().getUseageTemplate(false));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Faction yourFaction = you.getFaction();
|
||||||
|
Faction myFaction = me.getFaction();
|
||||||
|
|
||||||
|
// players with admin-level "disband" permission can bypass these requirements
|
||||||
|
if (!Factions.hasPermDisband(sender)) {
|
||||||
|
if (yourFaction != myFaction) {
|
||||||
|
sendMessage(you.getNameAndRelevant(me)+Conf.colorSystem+" is not a member of "+myFaction.getTag(me));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (you.getRole().value >= me.getRole().value) { // TODO add more informative messages.
|
if (you.getRole().value >= me.getRole().value) { // TODO add more informative messages.
|
||||||
sendMessage("Your rank is too low to kick this player.");
|
sendMessage("Your rank is too low to kick this player.");
|
||||||
return;
|
return;
|
||||||
@ -51,12 +55,24 @@ public class FCommandKick extends FBaseCommand {
|
|||||||
sendMessage("You cannot kick that member until their power is positive.");
|
sendMessage("You cannot kick that member until their power is positive.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
myFaction.deinvite(you);
|
yourFaction.sendMessage(me.getNameAndRelevant(yourFaction)+Conf.colorSystem+" kicked "+you.getNameAndRelevant(yourFaction)+Conf.colorSystem+" from the faction! :O");
|
||||||
|
you.sendMessage(me.getNameAndRelevant(you)+Conf.colorSystem+" kicked you from "+yourFaction.getTag(you)+Conf.colorSystem+"! :O");
|
||||||
|
if (yourFaction != myFaction) {
|
||||||
|
me.sendMessage(Conf.colorSystem+"You kicked "+you.getNameAndRelevant(myFaction)+Conf.colorSystem+" from the faction "+yourFaction.getTag(me)+Conf.colorSystem+"!");
|
||||||
|
}
|
||||||
|
|
||||||
|
yourFaction.deinvite(you);
|
||||||
you.resetFactionData();
|
you.resetFactionData();
|
||||||
|
|
||||||
myFaction.sendMessage(me.getNameAndRelevant(myFaction)+Conf.colorSystem+" kicked "+you.getNameAndRelevant(myFaction)+Conf.colorSystem+" from the faction! :O");
|
if (yourFaction.getFPlayers().isEmpty()) {
|
||||||
you.sendMessage(me.getNameAndRelevant(you)+Conf.colorSystem+" kicked you from "+myFaction.getTag(you)+Conf.colorSystem+"! :O");
|
// Remove this faction
|
||||||
|
for (FPlayer fplayer : FPlayer.getAllOnline()) {
|
||||||
|
fplayer.sendMessage("The faction "+yourFaction.getTag(fplayer)+Conf.colorSystem+" was disbanded.");
|
||||||
|
}
|
||||||
|
Faction.delete(yourFaction.getId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user