public static void link(Player p, int tsDbId){
String uuid = p.getUniqueId().toString();
UtilsStorage storageType = Utils.getStorageType();
if(storageType == UtilsStorage.FILE){
if(!isLinked(p)){
ConfigurationSection cs = UltimateTs.linkedPlayers.getConfigurationSection("linked");
cs.set(uuid, tsDbId);
UltimateTs.linkedPlayers.save();
}
}else if(storageType == UtilsStorage.SQL){
if(!UltimateTs.main().sql.isUUIDLinked(uuid)){
UltimateTs.main().sql.validLink(uuid, tsDbId);
}
}
assignRanks(p, tsDbId);
}
java类org.bukkit.configuration.ConfigurationSection的实例源码
PlayerManager.java 文件源码
项目:UltimateTs
阅读 24
收藏 0
点赞 0
评论 0
RootConfig.java 文件源码
项目:CropControl
阅读 27
收藏 0
点赞 0
评论 0
public static RootConfig from(String index) {
RootConfig config = rootConfigs.get(index);
if (config != null) {
return config;
}
config = new RootConfig();
config.index = index;
config.baseSection = CropControl.getPlugin().getConfig().getConfigurationSection(index);
if (config.baseSection != null) {
ConfigurationSection drops = config.baseSection.getConfigurationSection("drops");
if (drops != null) {
config.baseDrops = new ConcurrentHashMap<String, DropModifiers>();
for (String key : drops.getKeys(false)) {
DropConfig.byIdent(key); // preload it.
config.baseDrops.put(key, config.new DropModifiers(drops.getConfigurationSection(key)));
}
}
}
rootConfigs.put(index, config);
return config;
}
MinecraftUtils.java 文件源码
项目:VanillaPlus
阅读 25
收藏 0
点赞 0
评论 0
public static PotionEffect craftPotionEffect(String name, ConfigurationSection section) {
if(section == null){
Error.MISSING.add();
return null;
}
PotionEffectType effect = PotionEffectType.getByName(name);
if( effect == null ) {
ErrorLogger.addError(name + " is not a valid potion effect type !");
return null;
}
int duration = section.getInt(Node.DURATION.get(), 120)*20;
int amplifier = section.getInt(Node.LEVEL.get(), 1) - 1;
boolean ambient = section.getBoolean(Node.AMBIANT.get(), true);
boolean particles = section.getBoolean(Node.PARTICLE.get(), true);
return new PotionEffect(effect, duration, amplifier, ambient, particles);
}
CPChannelSet.java 文件源码
项目:VanillaPlus
阅读 18
收藏 0
点赞 0
评论 0
public CPChannelSet(ConfigurationSection section, MessageManager manager, String name){
super(section, manager, name);
channel = VanillaPlusCore.getChannelManager().get(section.getString(Node.CHANNEL.get()), true);
switchState = section.getBoolean(Node.SWITCH.get(), false);
if(!switchState)
leave = section.getBoolean(Node.LEAVE.get(), false);
if(leave || switchState) {
this.canceled = manager.get(section.getString("CANCELED"));
this.canceledOther = manager.get(section.getString("CANCELED_OTHER"));
this.canceledTo = manager.get(section.getString("CANCELED_TO"));
return;
}
join = section.getBoolean(Node.JOIN.get(), false);
set = section.getBoolean(Node.SET.get(), false);
if(!join && !set)
Error.INVALID.add();
}
PlayerManager.java 文件源码
项目:UltimateTs
阅读 22
收藏 0
点赞 0
评论 0
public static void unlink(Player p){
String uuid = p.getUniqueId().toString();
UtilsStorage storageType = Utils.getStorageType();
removeRanks(p);
if(storageType == UtilsStorage.FILE){
if(isLinked(p)){
ConfigurationSection cs = UltimateTs.linkedPlayers.getConfigurationSection("linked");
cs.set(uuid, 0);
UltimateTs.linkedPlayers.save();
}
}else if(storageType == UtilsStorage.SQL){
if(UltimateTs.main().sql.isUUIDLinked(uuid)){
UltimateTs.main().sql.unlink(uuid);
}
}
}
HelpYamlReader.java 文件源码
项目:Uranium
阅读 19
收藏 0
点赞 0
评论 0
/**
* Extracts a list of all index topics from help.yml
*
* @return A list of index topics.
*/
public List<HelpTopic> getIndexTopics() {
List<HelpTopic> topics = new LinkedList<HelpTopic>();
ConfigurationSection indexTopics = helpYaml.getConfigurationSection("index-topics");
if (indexTopics != null) {
for (String topicName : indexTopics.getKeys(false)) {
ConfigurationSection section = indexTopics.getConfigurationSection(topicName);
String shortText = ChatColor.translateAlternateColorCodes(ALT_COLOR_CODE, section.getString("shortText", ""));
String preamble = ChatColor.translateAlternateColorCodes(ALT_COLOR_CODE, section.getString("preamble", ""));
String permission = ChatColor.translateAlternateColorCodes(ALT_COLOR_CODE, section.getString("permission", ""));
List<String> commands = section.getStringList("commands");
topics.add(new CustomIndexHelpTopic(server.getHelpMap(), topicName, shortText, permission, commands, preamble));
}
}
return topics;
}
SpigotConfig.java 文件源码
项目:Uranium
阅读 23
收藏 0
点赞 0
评论 0
private static void stats()
{
disableStatSaving = getBoolean( "stats.disable-saving", false );
if ( !config.contains( "stats.forced-stats" ) ) {
config.createSection( "stats.forced-stats" );
}
ConfigurationSection section = config.getConfigurationSection( "stats.forced-stats" );
for ( String name : section.getKeys( true ) )
{
if ( section.isInt( name ) )
{
forcedStats.put( name, section.getInt( name ) );
}
}
if ( disableStatSaving && section.getInt( "achievement.openInventory", 0 ) < 1 )
{
Bukkit.getLogger().warning( "*** WARNING *** stats.disable-saving is true but stats.forced-stats.achievement.openInventory" +
" isn't set to 1. Disabling stat saving without forcing the achievement may cause it to get stuck on the player's " +
"screen." );
}
}
CPChannelState.java 文件源码
项目:VanillaPlus
阅读 15
收藏 0
点赞 0
评论 0
public CPChannelState(ConfigurationSection section, MessageManager manager, String name){
super(section, manager, name);
channel = VanillaPlusCore.getChannelManager().get(section.getString(Node.CHANNEL.get()), true);
switchIn = section.getBoolean("SWITCH_IN", false);
switchOut = section.getBoolean("SWITCH_OUT", false);
if(!switchIn){
muteIn = section.getBoolean("MUTE_IN", false);
if(!muteIn)
unmuteIn = section.getBoolean("UNMUTE_IN", false);
}
if(!switchOut){
muteOut = section.getBoolean("MUTE_OUT", false);
if(!muteOut)
unmuteOut = section.getBoolean("UNMUTE_OUT", false);
}
if(!( switchIn || switchOut || muteIn || muteOut || unmuteIn || unmuteOut ))
Error.INVALID.add();
}
PlayerManager.java 文件源码
项目:UltimateTs
阅读 20
收藏 0
点赞 0
评论 0
public static void link(Player p, int tsDbId){
String uuid = p.getUniqueId().toString();
UtilsStorage storageType = Utils.getStorageType();
if(storageType == UtilsStorage.FILE){
if(!isLinked(p)){
ConfigurationSection cs = UltimateTs.linkedPlayers.getConfigurationSection("linked");
cs.set(uuid, tsDbId);
UltimateTs.linkedPlayers.save();
}
}else if(storageType == UtilsStorage.SQL){
if(!UltimateTs.main().sql.isUUIDLinked(uuid)){
UltimateTs.main().sql.validLink(uuid, tsDbId);
}
}
assignRanks(p, tsDbId);
}
FileRotationProviderFactory.java 文件源码
项目:ProjectAres
阅读 19
收藏 0
点赞 0
评论 0
public Set<RotationProviderInfo> parse(MapLibrary mapLibrary, Path dataPath, Configuration config) {
ConfigurationSection base = config.getConfigurationSection("rotation.providers.file");
if(base == null) return Collections.emptySet();
Set<RotationProviderInfo> providers = new HashSet<>();
for(String name : base.getKeys(false)) {
ConfigurationSection provider = base.getConfigurationSection(name);
Path rotationFile = Paths.get(provider.getString("path"));
if(!rotationFile.isAbsolute()) rotationFile = dataPath.resolve(rotationFile);
int priority = provider.getInt("priority", 0);
if(Files.isRegularFile(rotationFile)) {
providers.add(new RotationProviderInfo(new FileRotationProvider(mapLibrary, name, rotationFile, dataPath), name, priority));
} else if(minecraftService.getLocalServer().startup_visibility() == ServerDoc.Visibility.PUBLIC) {
// This is not a perfect way to decide whether or not to throw an error, but it's the best we can do right now
mapLibrary.getLogger().severe("Missing rotation file: " + rotationFile);
}
}
return providers;
}
MinecraftUtils.java 文件源码
项目:VanillaPlus
阅读 19
收藏 0
点赞 0
评论 0
public static ItemStack addMeta(ConfigurationSection section, ItemStack item){
NBTItem nbtItem = new NBTItem(item);
for(String key : section.getKeys(false)){
Object value = section.get(key);
if(value instanceof Integer){
nbtItem.setInteger(key, (int)value);
}else if(value instanceof Double){
nbtItem.setDouble(key, (double)value);
}else if(value instanceof Boolean){
nbtItem.setBoolean(key, (boolean)value);
}else if(value instanceof String){
nbtItem.setString(key, (String)value);
}else if(value instanceof ConfigurationSection) {
NBTCompound compound = nbtItem.getCompound(key);
if(compound == null)
compound = nbtItem.addCompound(key);
applyCompound((ConfigurationSection) value, compound);
}
}
return nbtItem.getItem();
}
CPGamemode.java 文件源码
项目:VanillaPlus
阅读 20
收藏 0
点赞 0
评论 0
@SuppressWarnings("deprecation")
public CPGamemode(ConfigurationSection section, MessageManager manager, String name){
super(section, manager, name);
ErrorLogger.addPrefix("GAMEMODE");
Object o = section.get("GAMEMODE");
if(o instanceof Integer){
gm = GameMode.getByValue((int) o);
if(gm == null){
Error.INVALID.add();
}
}else if(o instanceof String){
gm = GameMode.valueOf((String) o);
if(gm == null){
Error.INVALID.add();
}
}else {
gm = GameMode.SURVIVAL;
Error.INVALID.add();
}
ErrorLogger.removePrefix();
}
Currency.java 文件源码
项目:VanillaPlus
阅读 29
收藏 0
点赞 0
评论 0
public Currency(int id, ConfigurationSection section, MComponentManager manager){
this.id = id;
this.name = manager.get(section.getString(Node.NAME.get()));
this.single = manager.get(section.getString("SINGLE"));
this.alias = section.getString("ALIAS");
int type = section.getInt("FORMAT_TYPE", 0);
this.format = (DecimalFormat) NumberFormat.getNumberInstance( type == 0 ? Locale.GERMAN : type == 1 ? Locale.ENGLISH : Locale.FRENCH);
format.applyPattern(section.getString("FORMAT", "###,###.### "));
this.step = section.getDouble("STEP", 0.001);
double temp = ((int)(step*1000))/1000.0;
if(step < 0.001 || temp != step)
ErrorLogger.addError("Invalid step amount : " + step);
this.min = ((int)section.getDouble("MIN", 0)/step)*step;
this.max = ((int)section.getDouble("MAX", 9999999999.999)/step)*step;
this.allowPay = section.getBoolean("ALLOW_PAY", false);
this.useServer = section.getBoolean("USE_SERVER", false);
this.booster = 1.0;
}
LobbyModule.java 文件源码
项目:OpenUHC
阅读 25
收藏 0
点赞 0
评论 0
@Override
public void onEnable() {
world = Bukkit.createWorld(new WorldCreator(OpenUHC.WORLD_DIR_PREFIX + "lobby"));
// Read lobby yml if it exists
File lobbyFile = new File(OpenUHC.WORLD_DIR_PREFIX + "lobby/lobby.yml");
if (lobbyFile.exists()) {
FileConfiguration lobbyConfig = YamlConfiguration.loadConfiguration(lobbyFile);
ConfigurationSection spawn = lobbyConfig.getConfigurationSection("spawn");
if (spawn != null) {
double x = spawn.getDouble("x", 0);
double y = spawn.getDouble("y", 64);
double z = spawn.getDouble("z", 0);
double r = spawn.getDouble("r", 1);
this.spawn = new Vector(x, y, z);
radius = (float) r;
}
}
OpenUHC.registerEvents(this);
}
PlayerManager.java 文件源码
项目:UltimateTs
阅读 17
收藏 0
点赞 0
评论 0
public static void unlink(Player p){
String uuid = p.getUniqueId().toString();
UtilsStorage storageType = Utils.getStorageType();
removeRanks(p);
if(storageType == UtilsStorage.FILE){
if(isLinked(p)){
ConfigurationSection cs = UltimateTs.linkedPlayers.getConfigurationSection("linked");
cs.set(uuid, 0);
UltimateTs.linkedPlayers.save();
}
}else if(storageType == UtilsStorage.SQL){
if(UltimateTs.main().sql.isUUIDLinked(uuid)){
UltimateTs.main().sql.unlink(uuid);
}
}
}
StatManager.java 文件源码
项目:VanillaPlus
阅读 24
收藏 0
点赞 0
评论 0
public void init(VanillaPlusCore core) {
ConfigurationSection section = ConfigUtils.getYaml(core.getInstance(), "Stat", false);
ErrorLogger.addPrefix("Stat.yml");
ConfigurationSection settings = section == null ? null : section.getConfigurationSection(Node.SETTINGS.get());
ErrorLogger.addPrefix(Node.SETTINGS.get());
if(settings==null){
startDataBase(VanillaPlusCore.getIConnectionManager().get(null));
}else{
startDataBase(VanillaPlusCore.getIConnectionManager().get(settings.getString("STORAGE")));
}
ErrorLogger.removePrefix();
if(!extensions.isEmpty()) {
new BukkitRunnable() {
@Override
public void run() {
for(VPPlayer player : VanillaPlusCore.getPlayerManager().getOnlinePlayers())
update(player);
}
}.runTaskTimer(VanillaPlus.getInstance(), 20*60, 20*60);
}
ErrorLogger.removePrefix();
}
PlayerManager.java 文件源码
项目:UltimateTs
阅读 31
收藏 0
点赞 0
评论 0
public static boolean isLinked(Player p){
String uuid = p.getUniqueId().toString();
UtilsStorage storageType = Utils.getStorageType();
if(storageType == UtilsStorage.FILE){
if(UltimateTs.linkedPlayers.getConfigurationSection("linked") == null) UltimateTs.linkedPlayers.createSection("linked");
ConfigurationSection cs = UltimateTs.linkedPlayers.getConfigurationSection("linked");
if((cs.contains(uuid)) && (cs.getInt(uuid) > 0)) return true;
}else if(storageType == UtilsStorage.SQL){
if(UltimateTs.main().sql.isUUIDLinked(uuid)){
int linkedId = UltimateTs.main().sql.getLinkedId(uuid);
if(linkedId > 0){
return true;
}
}
}
return false;
}
CropControlEventHandler.java 文件源码
项目:CropControl
阅读 27
收藏 0
点赞 0
评论 0
/**
* Bootstraps the standalone tools configurations, if any are defined.
*/
private void prefillToolList() {
ToolConfig.clear();
ConfigurationSection toolDefinitions = config.getConfigurationSection("tools");
if (toolDefinitions != null) {
for (String toolDefine : toolDefinitions.getKeys(false)) {
ToolConfig.initTool(toolDefinitions.getConfigurationSection(toolDefine));
}
} else {
CropControl.getPlugin().warning("No tools defined; if any crop configuration uses a tool config, it will result in a new warning.");
}
}
CropControlDatabaseHandler.java 文件源码
项目:CropControl
阅读 21
收藏 0
点赞 0
评论 0
private boolean configureData(ConfigurationSection config) {
String host = config.getString("host", "localhost");
int port = config.getInt("port", 3306);
String dbname = config.getString("database", "cropcontrol");
String username = config.getString("user");
String password = config.getString("password");
int poolsize = config.getInt("poolsize", 5);
long connectionTimeout = config.getLong("connection_timeout", 10000l);
long idleTimeout = config.getLong("idle_timeout", 600000l);
long maxLifetime = config.getLong("max_lifetime", 7200000l);
try {
data = new ManagedDatasource(CropControl.getPlugin(), username, password, host, port, dbname,
poolsize, connectionTimeout, idleTimeout, maxLifetime);
data.getConnection().close();
} catch (Exception se) {
CropControl.getPlugin().info("Failed to initialize Database connection");
return false;
}
initializeTables();
stageUpdates();
long begin_time = System.currentTimeMillis();
try {
CropControl.getPlugin().info("Update prepared, starting database update.");
if (!data.updateDatabase()) {
CropControl.getPlugin().info( "Update failed, disabling plugin.");
return false;
}
} catch (Exception e) {
CropControl.getPlugin().severe("Update failed, disabling plugin. Cause:", e);
return false;
}
CropControl.getPlugin().info(String.format("Database update took %d seconds", (System.currentTimeMillis() - begin_time) / 1000));
activateDirtySave(config.getConfigurationSection("dirtysave"));
return true;
}
RequirementTitle.java 文件源码
项目:VanillaPlus
阅读 18
收藏 0
点赞 0
评论 0
public RequirementTitle(ConfigurationSection section, MComponentManager manager) {
ErrorLogger.addPrefix(Node.ID.get());
this.title = VanillaPlusCore.getTitleManager().get(section.getInt(Node.ID.get()));
ErrorLogger.removePrefix();
boolean keep = section.getBoolean("KEEP", false);
this.keep = keep;
format = manager.get(section.getString(Node.FORMAT.get(), "REQUIREMENT.TITLE"));
}
ScriptManager.java 文件源码
项目:uppercore
阅读 27
收藏 0
点赞 0
评论 0
public void reloadConfig(File configFile) {
extensionsToEngineName = new HashMap<>();
FileConfiguration config = YamlConfiguration.loadConfiguration(configFile);
ConfigurationSection section = config.getConfigurationSection("engines");
for (Map.Entry<String, Object> obj : section.getValues(false).entrySet())
extensionsToEngineName.put(obj.getKey(), obj.getValue().toString());
}
CPMessageSend.java 文件源码
项目:VanillaPlus
阅读 22
收藏 0
点赞 0
评论 0
public CPMessageSend(ConfigurationSection section, MessageManager manager, String name){
super(section, manager, name);
message = manager.get(section.getString(Node.MESSAGE.get()));
all = section.getBoolean("ALL", false);
priv = section.getBoolean("PRIVATE", false);
other = new Requirement(section.get(Node.OTHER_REQUIREMENT.get()), manager.getComponentManager());
successOther = manager.get(section.getString(Node.SUCCESS.getOther()));
}
PetManager.java 文件源码
项目:EchoPet
阅读 25
收藏 0
点赞 0
评论 0
@Override
public void loadRiderFromFile(String type, IPet pet) {
if (pet.getOwner() != null) {
String path = type + "." + pet.getOwnerIdentification();
if (EchoPet.getConfig(EchoPet.ConfigType.DATA).get(path + ".rider.type") != null) {
PetType riderPetType = PetType.valueOf(EchoPet.getConfig(EchoPet.ConfigType.DATA).getString(path + ".rider.type"));
String riderName = EchoPet.getConfig(EchoPet.ConfigType.DATA).getString(path + ".rider.name");
if (riderName.equalsIgnoreCase("") || riderName == null) {
riderName = riderPetType.getDefaultName(pet.getNameOfOwner());
}
if (riderPetType == null) return;
if (EchoPet.getOptions().allowRidersFor(pet.getPetType())) {
IPet rider = pet.createRider(riderPetType, true);
if(rider != null && rider.getEntityPet() != null){
rider.setPetName(riderName);
ArrayList<PetData> riderData = new ArrayList<PetData>();
ConfigurationSection mcs = EchoPet.getConfig(EchoPet.ConfigType.DATA).getConfigurationSection(path + ".rider.data");
if (mcs != null) {
for (String key : mcs.getKeys(false)) {
if (GeneralUtil.isEnumType(PetData.class, key.toUpperCase())) {
PetData pd = PetData.valueOf(key.toUpperCase());
riderData.add(pd);
} else {
Logger.log(Logger.LogLevel.WARNING, "Error whilst loading data Pet Rider Save Data for " + pet.getNameOfOwner() + ". Unknown enum type: " + key + ".", true);
}
}
}
if (!riderData.isEmpty()) {
setData(pet, riderData.toArray(new PetData[riderData.size()]), true);
}
}
}
}
}
}
CPOther.java 文件源码
项目:VanillaPlus
阅读 19
收藏 0
点赞 0
评论 0
public CPOther(ConfigurationSection section, MessageManager manager, String name){
super(section, manager, name);
this.otherRequirement = new Requirement(section.get(Node.REQUIREMENT.getOther()), manager.getComponentManager());
this.alreadyOther = manager.get(section.getString(Node.ALREADY.getOther()));
this.alreadyTo = manager.get(section.getString(Node.ALREADY.get()+"_TO"));
this.successOther = manager.get(section.getString(Node.SUCCESS.getOther()));
this.successTo = manager.get(section.getString(Node.SUCCESS.get()+"_TO"));
}
MongoDatabaseCredentials.java 文件源码
项目:helper
阅读 20
收藏 0
点赞 0
评论 0
@Nonnull
public static MongoDatabaseCredentials fromConfig(@Nonnull ConfigurationSection config) {
return of(
config.getString("address", "localhost"),
config.getInt("port", 27017),
config.getString("database", "minecraft"),
config.getString("username", "root"),
config.getString("password", "passw0rd")
);
}
DatabaseCredentials.java 文件源码
项目:helper
阅读 18
收藏 0
点赞 0
评论 0
@Nonnull
public static DatabaseCredentials fromConfig(@Nonnull ConfigurationSection config) {
return of(
config.getString("address", "localhost"),
config.getInt("port", 3306),
config.getString("database", "minecraft"),
config.getString("username", "root"),
config.getString("password", "passw0rd")
);
}
PlayerConfig.java 文件源码
项目:Ourtown
阅读 20
收藏 0
点赞 0
评论 0
@Override
public void serialize(ConfigurationSection config) {
config.set("spawn", null);
ISerializable.serialize(config, this);
ConfigurationSection cfg = config.createSection("spawn");
for (UUID uuid : playerSpawn.keySet()) {
cfg.set(uuid.toString(), playerSpawn.get(uuid));
}
}
ConfigDataManger.java 文件源码
项目:KevsPermissions
阅读 19
收藏 0
点赞 0
评论 0
@Override
public HashMap<String, Object> fetchGroupByName(String name) {
ConfigurationSection section = config.getConfigurationSection("groups." + name);
if (section == null)
return null;
return (HashMap<String, Object>) section.getValues(true);
}
ConfigDataManger.java 文件源码
项目:KevsPermissions
阅读 19
收藏 0
点赞 0
评论 0
@Override
public HashMap<String, Object> getGroupList() {
ConfigurationSection section = config.getConfigurationSection("groups");
if (section == null)
return null;
return (HashMap<String, Object>) section.getValues(false);
}
RequirementCurrency.java 文件源码
项目:VanillaPlus
阅读 18
收藏 0
点赞 0
评论 0
public RequirementCurrency(ConfigurationSection section, MComponentManager manager) {
ErrorLogger.addPrefix(Node.ID.get());
this.money = VanillaPlusCore.getCurrencyManager().get((short) section.getInt(Node.ID.get()));
ErrorLogger.removePrefix();
boolean keep = section.getBoolean("KEEP", false);
this.amount = ((int)(section.getDouble(Node.AMOUNT.get(), 0)*1000))/1000.0;
if(amount <= 0){
ErrorLogger.addError(Node.AMOUNT.get() + " " + Error.INVALID.getMessage());
keep = true;
}
this.keep = keep;
format = manager.get(section.getString(Node.FORMAT.get(), "REQUIREMENT.CURRENCY"));
}