mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-11-23 18:55:25 +01:00
/f showinvites for ability to see pending invites for current faction. Adds feature in ticket #76
This commit is contained in:
parent
bfc904332a
commit
a170a0f4ad
@ -114,17 +114,17 @@ public class CmdShow extends FCommand {
|
||||
enemyList = enemyList.substring(0, enemyList.length() - 2);
|
||||
}
|
||||
|
||||
if(allyList.length() > 2048) {
|
||||
if (allyList.length() > 2048) {
|
||||
String[] lines = splitString(allyList, 2048, 256000);
|
||||
for (int i=0; i < lines.length; i++) {
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
sendMessage(lines[i]);
|
||||
}
|
||||
} else {
|
||||
sendMessage(allyList);
|
||||
}
|
||||
if(enemyList.length() > 2048) {
|
||||
if (enemyList.length() > 2048) {
|
||||
String[] lines = splitString(enemyList, 2048, 256000);
|
||||
for (int i=0; i < lines.length; i++) {
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
sendMessage(lines[i]);
|
||||
}
|
||||
} else {
|
||||
@ -166,17 +166,17 @@ public class CmdShow extends FCommand {
|
||||
offlineList = offlineList.substring(0, offlineList.length() - 2);
|
||||
}
|
||||
|
||||
if(onlineList.length() > 2048) {
|
||||
if (onlineList.length() > 2048) {
|
||||
String[] lines = splitString(onlineList, 2048, 256000);
|
||||
for (int i=0; i < lines.length; i++) {
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
sendMessage(lines[i]);
|
||||
}
|
||||
} else {
|
||||
sendMessage(onlineList);
|
||||
}
|
||||
if(offlineList.length() > 2048) {
|
||||
if (offlineList.length() > 2048) {
|
||||
String[] lines = splitString(offlineList, 2048, 256000);
|
||||
for (int i=0; i < lines.length; i++) {
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
sendMessage(lines[i]);
|
||||
}
|
||||
} else {
|
||||
@ -186,11 +186,11 @@ public class CmdShow extends FCommand {
|
||||
|
||||
private String[] splitString(String text, int chunkSize, int maxLength) {
|
||||
char[] data = text.toCharArray();
|
||||
int len = Math.min(data.length,maxLength);
|
||||
String[] result = new String[(len+chunkSize-1)/chunkSize];
|
||||
int len = Math.min(data.length, maxLength);
|
||||
String[] result = new String[(len + chunkSize - 1) / chunkSize];
|
||||
int linha = 0;
|
||||
for (int i=0; i < len; i+=chunkSize) {
|
||||
result[linha] = new String(data, i, Math.min(chunkSize,len-i));
|
||||
for (int i = 0; i < len; i += chunkSize) {
|
||||
result[linha] = new String(data, i, Math.min(chunkSize, len - i));
|
||||
linha++;
|
||||
}
|
||||
return result;
|
||||
|
@ -0,0 +1,27 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdShowInvites extends FCommand {
|
||||
|
||||
public CmdShowInvites() {
|
||||
super();
|
||||
aliases.add("showinvites");
|
||||
permission = Permission.SHOW_INVITES.node;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBeMember = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String id : myFaction.getInvites()) {
|
||||
FPlayer fp = FPlayers.i.get(id);
|
||||
sb.append(fp != null ? fp.getName() : id).append(" ");
|
||||
}
|
||||
msg("<a>Players with pending invites: <i> %s", sb.toString().trim());
|
||||
}
|
||||
}
|
@ -52,6 +52,7 @@ public class FCmdRoot extends FCommand {
|
||||
public CmdVersion cmdVersion = new CmdVersion();
|
||||
public CmdWarunclaimall cmdWarunclaimall = new CmdWarunclaimall();
|
||||
public CmdSB cmdSB = new CmdSB();
|
||||
public CmdShowInvites cmdShowInvites = new CmdShowInvites();
|
||||
|
||||
public FCmdRoot() {
|
||||
super();
|
||||
@ -120,6 +121,7 @@ public class FCmdRoot extends FCommand {
|
||||
this.addSubCommand(this.cmdVersion);
|
||||
this.addSubCommand(this.cmdWarunclaimall);
|
||||
this.addSubCommand(this.cmdSB);
|
||||
this.addSubCommand(this.cmdShowInvites);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,6 +50,7 @@ public enum Permission {
|
||||
SET_PEACEFUL("setpeaceful"),
|
||||
SET_PERMANENT("setpermanent"),
|
||||
SET_PERMANENTPOWER("setpermanentpower"),
|
||||
SHOW_INVITES("showinvites"),
|
||||
POWERBOOST("powerboost"),
|
||||
POWER("power"),
|
||||
POWER_ANY("power.any"),
|
||||
|
Loading…
Reference in New Issue
Block a user