当前位置: 首页>>代码示例>>Java>>正文


Java Town类代码示例

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


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

示例1: isInGroup

import com.palmergames.bukkit.towny.object.Town; //导入依赖的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

示例2: getTownPlayers

import com.palmergames.bukkit.towny.object.Town; //导入依赖的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

示例3: execute

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

	// Nation Generator

	try {

		TownyUniverse.getDataSource().newNation(nat.getSingle(e));
		Nation nation = TownyUniverse.getDataSource().getNation(nat.getSingle(e));
		Town town = TownyUniverse.getDataSource().getTown(tow.getSingle(e));
		nation.addTown(town);
		nation.setCapital(town);
		if (bal != null) {
			nation.setBalance(bal.getSingle(e).doubleValue(), "Nation Creation");
		} else {
			nation.setBalance(0, "Nation Creation");
		}
		TownyUniverse.getDataSource().saveTown(town);
		TownyUniverse.getDataSource().saveNation(nation);
		TownyUniverse.getDataSource().saveNationList();

	} catch (NotRegisteredException ex1) {
		core.getLogger().warning("Could not register nation: " + "\"" + nat.getSingle(e) + "\"");
	} catch (AlreadyRegisteredException ex2) {
		core.getLogger().warning(
				"Could not register nation: " + "\"" + nat.getSingle(e) + "\"" + ". Nation already exists in town");
	} catch (EconomyException ex3) {
		core.getLogger().warning("Could not register nation: " + "\"" + nat.getSingle(e) + "\"");
	}

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

示例4: checkTownNationChatInternal

import com.palmergames.bukkit.towny.object.Town; //导入依赖的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

示例5: isGroupLeader

import com.palmergames.bukkit.towny.object.Town; //导入依赖的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

示例6: WorldRestore

import com.palmergames.bukkit.towny.object.Town; //导入依赖的package包/类
public WorldRestore(World to, World from, boolean doWG, boolean doTowns, boolean doFactions) {
	this.to = to;
	this.from = from;
	PluginManager pm = Bukkit.getServer().getPluginManager();

	Arrays.sort(fragileBlocks);

	System.out.println("Beginning Preprocessing.");
	if (doWG) {
		Collection<ProtectedRegion> wgRegions = ((WorldGuardPlugin) pm.getPlugin("WorldGuard")).getRegionManager(from).getRegions().values();
		for (ProtectedRegion r : wgRegions) {
			preTasks.add(new WGPreprocessTask(r));
		}
		System.out.println("added worldguard to preprocess list.");
	}

	if (doTowns) {
		for (Town t : TownyUniverse.getDataSource().getTowns()) {
			preTasks.add(new TownyPreprocessTask(t));
		}
		System.out.println("added towny to preprocess list");
	}

	if (doFactions) {
		Collection<Faction> factions = FactionColl.get().getAll();
		for (Faction f : factions) {
			preTasks.add(new FactionsPreprocessTask(f));
		}
		System.out.println("added factions to preprocess list");
	}

}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:33,代码来源:WorldRestore.java

示例7: isTownyFriendly

import com.palmergames.bukkit.towny.object.Town; //导入依赖的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

示例8: execute

import com.palmergames.bukkit.towny.object.Town; //导入依赖的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

示例9: onEnable

import com.palmergames.bukkit.towny.object.Town; //导入依赖的package包/类
@Override
public void onEnable() {
	Instance = this;

	TBMCCoreAPI.RegisterEventsForExceptions(new PlayerListener(), this);
	TBMCChatAPI.AddCommands(this, YeehawCommand.class);
	Console = this.getServer().getConsoleSender();
	LoadFiles();

	SB = getServer().getScoreboardManager().getMainScoreboard(); // Main can be detected with @a[score_...]
	TU = ((Towny) Bukkit.getPluginManager().getPlugin("Towny")).getTownyUniverse();
	Towns = new ArrayList<Town>(TU.getTownsMap().values()); // Creates a snapshot of towns, new towns will be added when needed
	Nations = new ArrayList<Nation>(TU.getNationsMap().values()); // Same here but with nations

	TownColors.keySet().removeIf(t -> !TU.getTownsMap().containsKey(t.toLowerCase())); // Removes town colors for deleted/renamed towns

	TBMCChatAPI.RegisterChatChannel(
			TownChat = new Channel("§3TC§f", Color.DarkAqua, "tc", s -> checkTownNationChat(s, false)));
	TBMCChatAPI.RegisterChatChannel(
			NationChat = new Channel("§6NC§f", Color.Gold, "nc", s -> checkTownNationChat(s, true)));
	TBMCChatAPI.RegisterChatChannel(RPChannel = new Channel("§7RP§f", Color.Gray, "rp", Channel.noScoreResult(s -> {
		if (s instanceof ConsoleCommandSender)
			return true;
		return true; // TODO: Allow hiding it
	}, "You need to show the RP chat in order to speak in it.")));

	Bukkit.getScheduler().runTask(this, () -> {
		val dtp = (DynmapTownyPlugin) Bukkit.getPluginManager().getPlugin("Dynmap-Towny");
		if (dtp == null)
			return;
		for (val entry : TownColors.entrySet())
			setTownColor(dtp, entry.getKey(), entry.getValue());
	});

	setupChat();
	setupEconomy();
	setupPermissions();

	new Thread(this::FlairGetterThreadMethod).start();
	new Thread(new AnnouncerThread()).start();
}
 
开发者ID:TBMCPlugins,项目名称:ButtonChat,代码行数:42,代码来源:PluginMain.java

示例10: OnCommand

import com.palmergames.bukkit.towny.object.Town; //导入依赖的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

示例11: TownyPreprocessTask

import com.palmergames.bukkit.towny.object.Town; //导入依赖的package包/类
public TownyPreprocessTask(Town t){
	this.t = t;
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:4,代码来源:TownyPreprocessTask.java

示例12: get

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

	ArrayList<String> narr = new ArrayList<String>();
	for (Town a1 : TownyUniverse.getDataSource().getTowns()) {

		narr.add(a1.getName());
	}

	return narr.toArray(new String[narr.size()]);

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


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