• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Resident类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.palmergames.bukkit.towny.object.Resident的典型用法代码示例。如果您正苦于以下问题:Java Resident类的具体用法?Java Resident怎么用?Java Resident使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Resident类属于com.palmergames.bukkit.towny.object包,在下文中一共展示了Resident类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: get

import com.palmergames.bukkit.towny.object.Resident; //导入依赖的package包/类
@Override
@Nullable
protected String[] get(Event e) {

	String natname = null;
	Resident res;
	try {
		res = TownyUniverse.getDataSource().getResident(resident.getSingle(e).getName());
		natname = res.getTown().getNation().getName();

	} catch (NotRegisteredException ex) {
		ex.printStackTrace();
	}

	return new String[] { natname };
}
 
开发者ID:Sharpjaws,项目名称:SharpSK,代码行数:17,代码来源:ExprTownyNationOfPlayer.java


示例2: OnCommand

import com.palmergames.bukkit.towny.object.Resident; //导入依赖的package包/类
@Override
public boolean OnCommand(Player player, String alias, String[] args) {
	Resident res;
	// System.out.println("contains: " + PluginMain.TU.getResidentMap().contains(player.getName().toLowerCase()));
	// System.out.println("res: " + PluginMain.TU.getResidentMap().get(player.getName().toLowerCase()));
	// System.out.println("mayor: " + PluginMain.TU.getResidentMap().get(player.getName().toLowerCase()).isMayor());
	if (!(PluginMain.TU.getResidentMap().containsKey(player.getName().toLowerCase())
			&& (res = PluginMain.TU.getResidentMap().get(player.getName().toLowerCase())).isMayor())) {
		player.sendMessage("§cYou need to be the mayor of a town to set it's colors.");
		return true;
	}
	if (args.length > ColorCount) {
		player.sendMessage("You can only use " + ColorCount + " color" + (ColorCount > 1 ? "(s)" : "") + ".");
		return true;
	}
	String[] a = new String[args.length + 1];
	System.arraycopy(args, 0, a, 1, args.length);
	try {
		a[0] = res.getTown().getName().toLowerCase();
	} catch (NotRegisteredException e) {
		TBMCCoreAPI.SendException("Failed to set town color for player " + player + "!", e);
		player.sendMessage("§cCouldn't find your town... Error reported.");
		return true;
	}
	return buttondevteam.chat.commands.ucmds.admin.TownColorCommand.SetTownColor(player, alias, a);
}
 
开发者ID:TBMCPlugins,项目名称:ButtonChat,代码行数:27,代码来源:TownColorCommand.java


示例3: isInGroup

import com.palmergames.bukkit.towny.object.Resident; //导入依赖的package包/类
@Override
public boolean isInGroup(Player player, String groupName) {
    try {
        Resident resident = TownyUniverse.getDataSource().getResident(player.getName());
        Town town = resident.getTown();
        if (town.getName().equalsIgnoreCase(groupName)) {
            return true;
        }

        Nation nation = town.getNation();
        if (nation.getName().equalsIgnoreCase(groupName)) {
            return true;
        }

        return false;
    } catch (Exception e) {
        // Cannot use catch (NotRegisteredException e) because the class
        // cannot be loaded then when Towny isn't present
        if (e instanceof NotRegisteredException) {
            return false;
        }
        throw new RuntimeException(e);
    }
}
 
开发者ID:rutgerkok,项目名称:BlockLocker,代码行数:25,代码来源:TownyGroupSystem.java


示例4: getTownPlayers

import com.palmergames.bukkit.towny.object.Resident; //导入依赖的package包/类
public static Collection<Player> getTownPlayers( Player player ) {
    Collection<Player> townPlayers = new ArrayList<>();
    Resident r;
    try {
        r = TownyUniverse.getDataSource().getResident( player.getName() );
        Town t = r.getTown();
        for ( Player ps : TownyUniverse.getOnlinePlayers( t ) ) {
            if ( ps.hasPermission( "bungeesuite.chat.channel.town" ) ) {
                townPlayers.add( ps );
            }
        }
    } catch ( NotRegisteredException e ) {
        e.printStackTrace();
    }

    return townPlayers;
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:18,代码来源:ChannelManager.java


示例5: getNationPlayers

import com.palmergames.bukkit.towny.object.Resident; //导入依赖的package包/类
public static Collection<Player> getNationPlayers( Player player ) {
    Collection<Player> townPlayers = new ArrayList<>();
    Resident r;
    try {
        r = TownyUniverse.getDataSource().getResident( player.getName() );
        Nation n = r.getTown().getNation();
        for ( Player ps : TownyUniverse.getOnlinePlayers( n ) ) {
            if ( ps.hasPermission( "bungeesuite.chat.channel.nation" ) ) {
                townPlayers.add( ps );
            }
        }
    } catch ( NotRegisteredException e ) {
        e.printStackTrace();
    }

    return townPlayers;
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:18,代码来源:ChannelManager.java


示例6: getTown

import com.palmergames.bukkit.towny.object.Resident; //导入依赖的package包/类
public String getTown(Player player) {
		try {
			Resident r = TownyUniverse.getDataSource().getResident(player.getName());
			//Resident re = TownyUniverse.getDataSource().getResident(rec.getName());
//			List<String> ranks = r.getTownRanks();
//			String title = "";
//			if (ranks.size() > 0) {
//				String t = ranks.get(0);
//				title = ":" + String.valueOf(t.charAt(0)).toUpperCase() + t.substring(1, t.length());
//			}
			//some type of relational string
			ChatColor color = ChatColor.AQUA;
			String str = r.getTown().getName() + " ";
//			if (str.startsWith("|")) {
//				str = str.substring(1, str.length());
//			}
			if (str.length() > 0) {
				return color + "\u00BB" + str;
			}
		} catch (NotRegisteredException e) {}
		return "";
	}
 
开发者ID:Esaych,项目名称:DDCustomPlugin,代码行数:23,代码来源:ChatFacsTowns.java


示例7: getTownPlayers

import com.palmergames.bukkit.towny.object.Resident; //导入依赖的package包/类
public ArrayList<Player> getTownPlayers(Player player) {
	if (!testTown(player)) {
		return new ArrayList<Player>();
	} else {
		ArrayList<Player> players = new ArrayList<Player>();
		try {
			Resident r = TownyUniverse.getDataSource().getResident(player.getName());
			//Resident re = TownyUniverse.getDataSource().getResident(rec.getName());
			for (Resident res : r.getTown().getResidents()) {
				Player member = Bukkit.getPlayer(res.getName());
				if (member != null)
					players.add(member);
			}
			for (Player p : Bukkit.getOnlinePlayers()) {
				if (p.hasPermission("ddchat.staffchat") && !players.contains(p))
					players.add(p);
			}
		} catch (NotRegisteredException e) {}
		return players;
	}
}
 
开发者ID:Esaych,项目名称:DDCustomPlugin,代码行数:22,代码来源:ChatFacsTowns.java


示例8: getNationPlayers

import com.palmergames.bukkit.towny.object.Resident; //导入依赖的package包/类
public ArrayList<Player> getNationPlayers(Player player) {
	if (!testNation(player)) {
		return new ArrayList<Player>();
	} else {
		ArrayList<Player> players = new ArrayList<Player>();
		try {
			Resident r = TownyUniverse.getDataSource().getResident(player.getName());
			if (r.getTown().getNation() == null || r.getTown().getNation().getName().equals("")) {
				return new ArrayList<Player>();
			} else {
				for (Resident res : r.getTown().getNation().getResidents()) {
					Player member = Bukkit.getPlayer(res.getName());
					if (member != null)
						players.add(member);
				}
				for (Player p : Bukkit.getOnlinePlayers()) {
					if (p.hasPermission("ddchat.staffchat") && !players.contains(p))
						players.add(p);
				}
				return players;
			}
		} catch (NotRegisteredException e) {}
		return players;
	}
}
 
开发者ID:Esaych,项目名称:DDCustomPlugin,代码行数:26,代码来源:ChatFacsTowns.java


示例9: get

import com.palmergames.bukkit.towny.object.Resident; //导入依赖的package包/类
@Override
@Nullable
protected String[] get(Event e) {

	try {
		Resident a = TownyUniverse.getDataSource().getResident(resident.getSingle(e).getName());
		return new String[] { a.getTown().getName() };
	} catch (NotRegisteredException ex) {
		ex.printStackTrace();
	}
	return new String[] {};

}
 
开发者ID:Sharpjaws,项目名称:SharpSK,代码行数:14,代码来源:ExprTownyTownOfPlayer.java


示例10: checkTownNationChat

import com.palmergames.bukkit.towny.object.Resident; //导入依赖的package包/类
/**
 * Return the error message for the message sender if they can't send it and the score
 */
private static RecipientTestResult checkTownNationChat(CommandSender sender, boolean nationchat) {
	if (!(sender instanceof Player))
		return new RecipientTestResult("§cYou are not a player!");
	Resident resident = PluginMain.TU.getResidentMap().get(sender.getName().toLowerCase());
	RecipientTestResult result = checkTownNationChatInternal(sender, nationchat, resident);
	if (result.errormessage != null && resident != null && resident.getModes().contains("spy")) // Only use spy if they wouldn't see it
		result = new RecipientTestResult(1000); // There won't be more than a thousand towns/nations probably
	return result;
}
 
开发者ID:TBMCPlugins,项目名称:ButtonChat,代码行数:13,代码来源:PluginMain.java


示例11: checkTownNationChatInternal

import com.palmergames.bukkit.towny.object.Resident; //导入依赖的package包/类
private static RecipientTestResult checkTownNationChatInternal(CommandSender sender, boolean nationchat,
		Resident resident) {
	try {
		/*
		 * p.sendMessage(String.format("[SPY-%s] - %s: %s", channel.DisplayName, ((Player) sender).getDisplayName(), message));
		 */
		Town town = null;
		if (resident != null && resident.hasTown())
			town = resident.getTown();
		if (town == null)
			return new RecipientTestResult("You aren't in a town.");
		Nation nation = null;
		int index;
		if (nationchat) {
			if (town.hasNation())
				nation = town.getNation();
			if (nation == null)
				return new RecipientTestResult("Your town isn't in a nation.");
			index = PluginMain.Nations.indexOf(nation);
			if (index < 0) {
				PluginMain.Nations.add(nation);
				index = PluginMain.Nations.size() - 1;
			}
		} else {
			index = PluginMain.Towns.indexOf(town);
			if (index < 0) {
				PluginMain.Towns.add(town);
				index = PluginMain.Towns.size() - 1;
			}
		}
		return new RecipientTestResult(index);
	} catch (NotRegisteredException e) {
		return new RecipientTestResult("You (probably) aren't knwon by Towny! (Not in a town)");
	}
}
 
开发者ID:TBMCPlugins,项目名称:ButtonChat,代码行数:36,代码来源:PluginMain.java


示例12: isGroupLeader

import com.palmergames.bukkit.towny.object.Resident; //导入依赖的package包/类
@Override
public boolean isGroupLeader(Player player, String groupName) {
    try {
        Resident resident = TownyUniverse.getDataSource().getResident(player.getName());
        Town town = resident.getTown();
        if (town.getName().equalsIgnoreCase(groupName)) {
            if (town.isMayor(resident) || town.hasAssistant(resident)) {
                return true;
            }
        }

        Nation nation = town.getNation();
        if (nation.getName().equalsIgnoreCase(groupName)) {
            if (nation.isKing(resident) || nation.hasAssistant(resident)) {
                return true;
            }
        }

        return false;
    } catch (Exception e) {
        // Cannot use catch (NotRegisteredException e) because the class
        // cannot be loaded then when Towny isn't present
        if (e instanceof NotRegisteredException) {
            return false;
        }
        throw new RuntimeException(e);
    }
}
 
开发者ID:rutgerkok,项目名称:BlockLocker,代码行数:29,代码来源:TownyGroupSystem.java


示例13: getTownyChannelPerm

import com.palmergames.bukkit.towny.object.Resident; //导入依赖的package包/类
public static boolean getTownyChannelPerm( CommandSender sender ) {
    if ( !BungeeSuiteChat.towny ) {
        return false;
    }
    Resident r;
    try {
        r = TownyUniverse.getDataSource().getResident( sender.getName() );
    } catch ( NotRegisteredException e ) {
        return false;
    }
    if ( !r.hasTown() ) {
        return false;
    }
    return true;
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:16,代码来源:ChannelManager.java


示例14: testTown

import com.palmergames.bukkit.towny.object.Resident; //导入依赖的package包/类
public boolean testTown(Player p) {
	try {
		Resident r = TownyUniverse.getDataSource().getResident(p.getName());
		if (r.getTown() == null) {
			return false;
		}
	} catch (NotRegisteredException e) {
		return false;
	}
	return true;
}
 
开发者ID:Esaych,项目名称:DDCustomPlugin,代码行数:12,代码来源:ChatFacsTowns.java


示例15: testNation

import com.palmergames.bukkit.towny.object.Resident; //导入依赖的package包/类
public boolean testNation(Player p) {
	try {
		Resident r = TownyUniverse.getDataSource().getResident(p.getName());
		if (r.getTown().getNation() == null) {
			return false;
		}
	} catch (NotRegisteredException e) {
		return false;
	}
	return true;
}
 
开发者ID:Esaych,项目名称:DDCustomPlugin,代码行数:12,代码来源:ChatFacsTowns.java


示例16: isTownyFriendly

import com.palmergames.bukkit.towny.object.Resident; //导入依赖的package包/类
public boolean isTownyFriendly(Player player, Player target) {
    Resident playerResident = getTownyResident(player);
    Resident targetResident = getTownyResident(target);
    if (playerResident == null || targetResident == null) return false;

    if (playerResident.hasFriend(targetResident)) return true;

    try {
        if (playerResident.hasTown() && targetResident.hasTown()) {
            Town playerTown = playerResident.getTown();
            Town targetTown = targetResident.getTown();
            if (playerTown == targetTown) {
                return true;
            } else if (playerTown.hasNation() && targetTown.hasNation()) {
                Nation playerNation = playerTown.getNation();
                Nation targetNation = targetTown.getNation();
                if (playerNation == targetNation || playerNation.hasAlly(targetNation)) {
                    return true;
                }
            }
        }
    } catch (Exception ex) {
        // never happens
    }

    return false;
}
 
开发者ID:galaran,项目名称:PvpRealm,代码行数:28,代码来源:TownyFacade.java


示例17: execute

import com.palmergames.bukkit.towny.object.Resident; //导入依赖的package包/类
@Override
protected void execute(Event e) {
	main core = (main) Bukkit.getPluginManager().getPlugin("SharpSK");

	// Town Generator

	try {

		TownyWorld world = TownyUniverse.getDataSource().getWorld(homespawn.getSingle(e).getWorld().getName());
		Coord loc = Coord.parseCoord(homespawn.getSingle(e));

		world.newTownBlock(loc);
		TownyUniverse.getDataSource().newTown(s.getSingle(e));
		Town town = TownyUniverse.getDataSource().getTown(s.getSingle(e));
		if (owner != null) {
			Resident resident = TownyUniverse.getDataSource().getResident(owner.getSingle(e).getName());
			town.addResident(resident);
			town.setMayor(resident);
			TownyUniverse.getDataSource().saveResident(resident);
		}
		if (members != null) {

			for (OfflinePlayer member : members.getAll(e)) {
				Resident loopresident = TownyUniverse.getDataSource().getResident(member.getName());
				town.addResident(loopresident);
				TownyUniverse.getDataSource().saveResident(loopresident);
			}

		}

		TownBlock TB = world.getTownBlock(loc);
		TB.setTown(town);
		town.setHomeBlock(TB);

		TB.setType(TB.getType());
		town.setSpawn(homespawn.getSingle(e));
		if (sb != null) {
			town.setBalance(sb.getSingle(e).doubleValue(), "Town Creation");
		} else {
			town.setBalance(0, "Town Creation");
		}

		TownyUniverse.getDataSource().saveTownBlock(TB);
		TownyUniverse.getDataSource().saveTown(town);
		TownyUniverse.getDataSource().saveWorld(world);

		TownyUniverse.getDataSource().saveTownList();
		TownyUniverse.getDataSource().saveTownBlockList();

	} catch (NotRegisteredException ex1) {
		core.getLogger().warning("Could not register town: " + "\"" + s.getSingle(e) + "\"");
	} catch (AlreadyRegisteredException ex2) {
		core.getLogger()
				.warning("Could not register town: " + "\"" + s.getSingle(e) + "\"" + ". Town already exists");
	} catch (TownyException ex3) {
		core.getLogger().warning("Could not register town: " + "\"" + s.getSingle(e) + "\"");
	} catch (EconomyException ex4) {
		core.getLogger().warning("Could not register town: " + "\"" + s.getSingle(e) + "\"");
	}

}
 
开发者ID:Sharpjaws,项目名称:SharpSK,代码行数:62,代码来源:EffTownyCreateTown.java


示例18: OnCommand

import com.palmergames.bukkit.towny.object.Resident; //导入依赖的package包/类
@Override
public boolean OnCommand(Player player, String alias, String[] args) {
	Resident res;
	Town town;
	try {
		if ((res = PluginMain.TU.getResidentMap().get(player.getName().toLowerCase())) == null || !res.hasTown()
				|| (town = res.getTown()) == null) {
			player.sendMessage("§cYou need to be in a town.");
			return true;
		}
	} catch (Exception e) {
		player.sendMessage("§cYou need to be in a town. (" + e + ")");
		return true;
	}
	if (args.length == 0)
		return false;
	if (!args[0].replace("|", "").equalsIgnoreCase(ChatColor.stripColor(player.getDisplayName()))) {
		player.sendMessage("§cThe name you gave doesn't match your name. Make sure to use "
				+ ChatColor.stripColor(player.getDisplayName()) + "§c with added vertical lines (|).");
		return true;
	}
	String[] nameparts = args[0].split("\\|");
	Color[] towncolors = PluginMain.TownColors.get(town.getName().toLowerCase());
	if (towncolors == null) {
		player.sendMessage("§cYour town doesn't have a color set. The town mayor can set it using /u towncolor.");
		return true;
	}
	if (nameparts.length < towncolors.length) {
		player.sendMessage("§cYou need more vertical lines (|) in your name.");
		return true;
	}
	if (nameparts.length > towncolors.length * 2) {
		player.sendMessage("§cYou have waay too many vertical lines (|) in your name.");
		return true;
	}
	if (nameparts.length > towncolors.length) {
		player.sendMessage("§cYou have too many vertical lines (|) in your name.");
		return true;
	}
	ChatPlayer.getPlayer(player.getUniqueId(), ChatPlayer.class).NameColorLocations()
			.set(new ArrayList<>(Arrays.stream(nameparts).map(np -> np.length()).collect(Collectors.toList()))); // No byte[], no TIntArrayList
	player.sendMessage("§bName colors set.");
	return true;
}
 
开发者ID:TBMCPlugins,项目名称:ButtonChat,代码行数:45,代码来源:NColorCommand.java


示例19: getTownyResident

import com.palmergames.bukkit.towny.object.Resident; //导入依赖的package包/类
public Resident getTownyResident(Player player) {
    return townyUniv.getResidentMap().get(player.getName().toLowerCase());
}
 
开发者ID:galaran,项目名称:PvpRealm,代码行数:4,代码来源:TownyFacade.java



注:本文中的com.palmergames.bukkit.towny.object.Resident类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MetadataComponent类代码示例发布时间:2022-05-23
下一篇:
Java ElementSequentialTimeContainer类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap