本文整理汇总了Java中net.daboross.bukkitdev.playerdata.api.PlayerData类的典型用法代码示例。如果您正苦于以下问题:Java PlayerData类的具体用法?Java PlayerData怎么用?Java PlayerData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PlayerData类属于net.daboross.bukkitdev.playerdata.api包,在下文中一共展示了PlayerData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compare
import net.daboross.bukkitdev.playerdata.api.PlayerData; //导入依赖的package包/类
@Override
public int compare(PlayerData o1, PlayerData o2) {
Long l1;
Long l2;
if (o1.isOnline()) {
l1 = System.currentTimeMillis();
} else {
l1 = o1.getLastSeen();
}
if (o2.isOnline()) {
l2 = System.currentTimeMillis();
} else {
l2 = o2.getLastSeen();
}
return l2.compareTo(l1);
}
示例2: logout
import net.daboross.bukkitdev.playerdata.api.PlayerData; //导入依赖的package包/类
private PlayerData logout(Player p, boolean endingServer) {
PlayerDataImpl pd = getPlayerData(p);
pd.loggedOut(p, this, endingServer);
if (!endingServer) {
synchronized (LIST_LOCK) {
int pos = playerDataList.indexOf(pd);
while (playerDataList.contains(pd)) {
playerDataList.remove(pd);
}
while (pos < playerDataList.size() && playerDataList.get(pos).isOnline()) {
pos++;
}
playerDataList.add(pos, pd);
}
}
return pd;
}
示例3: runCommand
import net.daboross.bukkitdev.playerdata.api.PlayerData; //导入依赖的package包/类
@Override
public void runCommand(CommandSender sender, Command baseCommand, String baseCommandLabel, String subCommandLabel, String[] subCommandArgs) {
List<String> usersList = new ArrayList<String>();
for (PlayerData player : playerHandler.getAllPlayerDatas()) {
for (LoginData login : player.getAllLogins()) {
String ip = login.getIP();
String[] ipSplit = ip.split(":")[0].split("/");
ip = ipSplit[ipSplit.length - 1];
if (ip.equalsIgnoreCase(subCommandArgs[0])) {
usersList.add(player.getUsername());
break;
}
}
}
if (usersList.isEmpty()) {
sender.sendMessage(ColorList.ERR + "No players found who have used the IP " + ColorList.ERR_ARGS + subCommandArgs[0]);
} else {
StringBuilder builder = new StringBuilder(usersList.get(0));
for (int i = 1; i < usersList.size(); i++) {
builder.append(", ").append(usersList.get(i));
}
sender.sendMessage(ColorList.TOP_SEPERATOR + " -- " + ColorList.TOP + "players who have used the IP '" + ColorList.DATA + subCommandArgs[0] + ColorList.TOP + "'" + ColorList.TOP_SEPERATOR + " --");
sender.sendMessage(builder.toString());
}
}
示例4: onCommand
import net.daboross.bukkitdev.playerdata.api.PlayerData; //导入依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length > 0) {
String partialName = ArrayHelpers.combinedWithSeperator(args, " ");
List<? extends PlayerData> playerDataList = playerHandler.getAllPlayerDatas();
sender.sendMessage(String.format(ColorList.TOP_FORMAT, "AutoCompletes for " + ColorList.NAME + partialName));
for (int numSent = 0, i = 0; i < playerDataList.size() && numSent < 10; i++) {
PlayerData pd = playerDataList.get(i);
if (pd.getUsername().equals(pd.getDisplayName())) {
if (StringUtils.containsIgnoreCase(pd.getUsername(), partialName)) {
sender.sendMessage(ColorList.NAME + pd.getUsername());
numSent++;
}
} else {
if (StringUtils.containsIgnoreCase(pd.getUsername(), partialName) || StringUtils.containsIgnoreCase(ChatColor.stripColor(pd.getDisplayName()), partialName)) {
sender.sendMessage(ColorList.NAME + pd.getUsername() + ColorList.DIVIDER + " | " + ColorList.NAME + pd.getDisplayName());
numSent++;
}
}
}
} else {
sender.sendMessage(ColorList.ERR + "Please specify a player");
sender.sendMessage(ColorList.CMD + "/" + label + ColorList.ARGS + " <Partial Name>");
}
return true;
}
示例5: addGroup
import net.daboross.bukkitdev.playerdata.api.PlayerData; //导入依赖的package包/类
public static void addGroup(Permission permissionHandler, PlayerData pData, String group, CommandSender ranker) {
if (permissionHandler == null || pData == null || group == null || ranker == null) {
throw new IllegalArgumentException("One or more null arguments");
}
if (!permissionHandler.playerInGroup((String) null, pData.getUsername(), group)) {
permissionHandler.playerAddGroup((String) null, pData.getUsername(), group);
List<String> rawData;
if (pData.hasExtraData("rankrecord")) {
rawData = new ArrayList<String>(Arrays.asList(pData.getExtraData("rankrecord")));
} else {
rawData = new ArrayList<String>();
}
rawData.add("ADD " + ranker.getName() + " " + group + " " + System.currentTimeMillis());
pData.addExtraData("rankrecord", rawData.toArray(new String[rawData.size()]));
ranker.sendMessage(ColorList.DATA + group + ColorList.REG + " has been added to " + ColorList.NAME + pData.getUsername());
} else {
ranker.sendMessage(ColorList.DATA + group + ColorList.REG + " has already been added to " + ColorList.NAME + pData.getUsername() + ColorList.REG + "...");
}
}
示例6: removeGroup
import net.daboross.bukkitdev.playerdata.api.PlayerData; //导入依赖的package包/类
public static void removeGroup(Permission permissionHandler, PlayerData pData, String group, CommandSender ranker) {
if (permissionHandler == null || pData == null || group == null || ranker == null) {
throw new IllegalArgumentException("One or more null arguments");
}
if (permissionHandler.playerInGroup((String) null, pData.getUsername(), group)) {
permissionHandler.playerRemoveGroup((String) null, pData.getUsername(), group);
List<String> rawData;
if (pData.hasExtraData("rankrecord")) {
rawData = new ArrayList<String>(Arrays.asList(pData.getExtraData("rankrecord")));
} else {
rawData = new ArrayList<String>();
}
rawData.add("REMOVE " + ranker.getName() + " " + group + " " + System.currentTimeMillis());
pData.addExtraData("rankrecord", rawData.toArray(new String[rawData.size()]));
ranker.sendMessage(ColorList.DATA + group + ColorList.REG + " has been removed from " + ColorList.NAME + pData.getUsername());
} else {
ranker.sendMessage(ColorList.DATA + group + ColorList.REG + " has already been removed from " + ColorList.NAME + pData.getUsername() + ColorList.REG + "...");
}
}
示例7: initAddCommands
import net.daboross.bukkitdev.playerdata.api.PlayerData; //导入依赖的package包/类
private void initAddCommands() {
for (final String group : groups) {
commandExecutorBase.addSubCommand(new SubCommand("add" + group, true, "rankdata.addgroup." + group, new String[]{"Player"}, "Adds " + group + " to the given Player", new SubCommandHandler() {
@Override
public void runCommand(CommandSender sender, Command baseCommand, String baseCommandLabel, SubCommand subCommand, String subCommandLabel, String[] subCommandArgs) {
if (!groups.contains(group)) {
sender.sendMessage("This group doesn't exist? This is an error with RankData! Try reloading it with /rd reload!");
return;
}
PlayerData pData = getPDataFromCommand(sender, subCommand, baseCommandLabel, subCommandLabel, subCommandArgs);
if (pData != null) {
RankTracker.addGroup(pData, group, sender);
}
}
}));
}
}
示例8: initRemoveCommands
import net.daboross.bukkitdev.playerdata.api.PlayerData; //导入依赖的package包/类
private void initRemoveCommands() {
for (final String group : groups) {
commandExecutorBase.addSubCommand(new SubCommand("remove" + group, true, "rankdata.removegroup." + group, new String[]{"Player"}, "Removes " + group + " from the given Player", new SubCommandHandler() {
@Override
public void runCommand(CommandSender sender, Command baseCommand, String baseCommandLabel, SubCommand subCommand, String subCommandLabel, String[] subCommandArgs) {
if (!groups.contains(group)) {
sender.sendMessage("This group doesn't exist? This is an error with RankData! Try reloading it with /rd reload!");
}
PlayerData pData = getPDataFromCommand(sender, subCommand, baseCommandLabel, subCommandLabel, subCommandArgs);
if (pData != null) {
RankTracker.removeGroup(pData, group, sender);
}
}
}));
}
}
示例9: initSetCommands
import net.daboross.bukkitdev.playerdata.api.PlayerData; //导入依赖的package包/类
private void initSetCommands() {
for (final String group : groups) {
commandExecutorBase.addSubCommand(new SubCommand("set" + group, true, "rankdata.setgroup." + group, new String[]{"Player"}, "Removes all groups from and then adds " + group + " to the given Player", new SubCommandHandler() {
@Override
public void runCommand(CommandSender sender, Command baseCommand, String baseCommandLabel, SubCommand subCommand, String subCommandLabel, String[] subCommandArgs) {
if (!groups.contains(group)) {
sender.sendMessage("This group doesn't exist? This is an error with RankData! Try reloading it with /rd reload!");
}
PlayerData pData = getPDataFromCommand(sender, subCommand, baseCommandLabel, subCommandLabel, subCommandArgs);
if (pData != null) {
RankTracker.setGroups(pData, new String[]{group}, sender);
}
}
}));
}
}
示例10: runCommand
import net.daboross.bukkitdev.playerdata.api.PlayerData; //导入依赖的package包/类
@Override
public void runCommand(CommandSender sender, Command baseCommand, String baseCommandLabel, SubCommand subCommand, String subCommandLabel, String[] subCommandArgs) {
if (subCommand.getName().equals("checksurvivors")) {
sender.sendMessage(ColorList.REG + "Checking for survivor");
rankDataBukkit.getSurvivorChecker().reload();
sender.sendMessage(ColorList.REG + "Done checking. Results sent to console");
} else if (subCommand.getName().equals("viewrecords")) {
PlayerData pData = getPDataFromCommand(sender, subCommand, baseCommandLabel, subCommandLabel, subCommandArgs);
if (pData != null) {
String[] rankData = pData.getExtraData("rankrecord");
if (rankData == null) {
sender.sendMessage(ColorList.REG + "No rank record found for player '" + ColorList.NAME + pData.getUsername() + ColorList.REG + "'");
return;
}
sender.sendMessage(ColorList.TOP_SEPERATOR + " -- " + ColorList.NAME + pData.getUsername() + ColorList.TOP + "'s Rank Data" + ColorList.TOP_SEPERATOR + " --");
for (int i = 0; i < rankData.length; i++) {
rankData[i] = formatDataLine(rankData[i]);
}
sender.sendMessage(rankData);
}
}
}
示例11: getPDataFromCommand
import net.daboross.bukkitdev.playerdata.api.PlayerData; //导入依赖的package包/类
private PlayerData getPDataFromCommand(CommandSender sender, SubCommand subCommand, String baseCommandLabel, String subCommandLabel, String[] subCommandArgs) {
if (subCommandArgs.length < 1) {
sender.sendMessage(ColorList.ERR + "Please specify a player");
sender.sendMessage(subCommand.getHelpMessage(baseCommandLabel, subCommandLabel));
return null;
}
if (subCommandArgs.length > 1) {
sender.sendMessage(ColorList.ERR + "Please only use one argument");
sender.sendMessage(subCommand.getHelpMessage(baseCommandLabel, subCommandLabel));
return null;
}
PlayerData pData = playerDataHandler.getPlayerDataPartial(subCommandArgs[0]);
if (pData == null) {
sender.sendMessage(ColorList.ERR + "Player '" + ColorList.ERR_ARGS + subCommandArgs[0] + ColorList.ERR + "' not found");
return null;
}
return pData;
}
示例12: reload
import net.daboross.bukkitdev.playerdata.api.PlayerData; //导入依赖的package包/类
protected void reload() {
Logger l = rankDataBukkit.getLogger();
rankDataBukkit.getLogger().info("Starting Survivor Check");
PlayerHandler handler = rankDataBukkit.getPlayerDataPlugin().getHandler();
if (handler == null) {
return;
}
List<? extends PlayerData> pDataList = rankDataBukkit.getPlayerDataPlugin().getHandler().getAllPlayerDatas();
int foundReady = 0;
for (int i = 0; i < pDataList.size(); i++) {
PlayerData current = pDataList.get(i);
Permission perm = PlayerDataStatic.getPermissionHandler();
if (isReadyCheck(perm, current)) {
foundReady++;
setSurvivor(perm, current);
}
}
if (foundReady != 0) {
l.log(Level.INFO, "Added Survivor to {0} users", foundReady);
} else {
l.log(Level.INFO, "Done Checking Survivors");
}
}
示例13: isReadyCheck
import net.daboross.bukkitdev.playerdata.api.PlayerData; //导入依赖的package包/类
private boolean isReadyCheck(Permission p, PlayerData pd) {
if (pd != null) {
if (isCorrectGroup(p, pd)) {
if (System.currentTimeMillis() - pd.getLastSeen() >= daysSinceOnlineAllowedInMillis) {
if (TimeUnit.MILLISECONDS.toDays(System.currentTimeMillis() - pd.getAllLogins().get(0).getDate()) >= daysSinceJoin) {
if (TimeUnit.MILLISECONDS.toHours(pd.getTimePlayed()) >= hoursSpentOnline) {
return true;
} else {
rankDataBukkit.getLogger().log(Level.FINER, "{0} would be ready for Survivor, but time spent online is not enough", pd.getUsername());
return false;
}
}
}
}
}
return false;
}
示例14: PlayerDataInfoEvent
import net.daboross.bukkitdev.playerdata.api.PlayerData; //导入依赖的package包/类
public PlayerDataInfoEvent(CommandSender infoRequester, PlayerData playerDataRequested, PlayerHandler handler) {
super(false);
this.infoRequester = infoRequester;
this.playerDataRequested = playerDataRequested;
this.handler = handler;
this.extraInfo = new ArrayList<String>();
}
示例15: getPlayerDataPartial
import net.daboross.bukkitdev.playerdata.api.PlayerData; //导入依赖的package包/类
@Override
public PlayerData getPlayerDataPartial(String partialName) {
ArgumentCheck.notNull(partialName);
PlayerData[] possibleMatches = new PlayerData[2];
synchronized (LIST_LOCK) {
for (int i = 0; i < playerDataList.size(); i++) {
PlayerData pd = playerDataList.get(i);
if (pd.getUsername().equalsIgnoreCase(partialName)) {
return pd;
}
if (StringUtils.containsIgnoreCase(pd.getUsername(), partialName)) {
if (possibleMatches[0] == null) {
possibleMatches[0] = pd;
}
}
if (StringUtils.containsIgnoreCase(ChatColor.stripColor(pd.getDisplayName()), partialName)) {
if (possibleMatches[1] == null) {
possibleMatches[1] = pd;
}
}
}
}
for (int i = 0; i < possibleMatches.length; i++) {
if (possibleMatches[i] != null) {
return possibleMatches[i];
}
}
return null;
}