Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbeMiglio committed Apr 27, 2024
2 parents 5ecccd1 + daf8074 commit 7d400dd
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 20 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,12 @@ your plugin and rename its packages:
</plugin>
</plugins>
</build>
```
```

## Sponsors

[![YourKit](https://www.yourkit.com/images/yklogo.png)](https://www.yourkit.com/java/profiler/)

YourKit supports open source projects with innovative and intelligent tools for monitoring and profiling Java
and .NET applications. Their flagship products include the award-winning full-featured [YourKit Java Profiler](https://www.yourkit.com/java/profiler/)
and the [.NET Profiler](https://www.yourkit.com/dotnet-profiler/)!
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,18 @@ public ItemBuilder setMaterial(Material material) {
return this;
}

/**
* Adds a custom NBT tag to the item
*
* @param type The PersistentDataType
* @param key The key
* @param value The value
*/
public <V> ItemBuilder addPersistentValue(PersistentDataType<?, V> type, String key, V value) {
NBT.put(key, new Pair<>(type, value));
return this;
}

/**
* Sets the item's material getting it from a String
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package it.mycraft.powerlib.common.configuration;

import java.io.*;
import java.util.HashMap;
import java.util.Map;

/**
* Original fragments from bungeecord
Expand All @@ -11,24 +9,8 @@
*/
public abstract class ConfigurationProvider {

private static final Map<Class<? extends ConfigurationProvider>, ConfigurationProvider> providers = new HashMap<>();

static {
try {
providers.put(YamlConfiguration.class, new YamlConfiguration());
} catch (NoClassDefFoundError ex) {
// Ignore, no SnakeYAML
}

try {
providers.put(JsonConfiguration.class, new JsonConfiguration());
} catch (NoClassDefFoundError ex) {
// Ignore, no Gson
}
}

public static ConfigurationProvider getProvider(Class<? extends ConfigurationProvider> provider) {
return providers.get(provider);
return ProviderRegistry.getProvider(provider);
}

/*------------------------------------------------------------------------*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package it.mycraft.powerlib.common.configuration;

import java.util.HashMap;
import java.util.Map;

public class ProviderRegistry {

private static final Map<Class<? extends ConfigurationProvider>, ConfigurationProvider> providers = new HashMap<>();

static {
try {
providers.put(YamlConfiguration.class, new YamlConfiguration());
} catch (NoClassDefFoundError ex) {
// Ignore, no SnakeYAML
}

try {
providers.put(JsonConfiguration.class, new JsonConfiguration());
} catch (NoClassDefFoundError ex) {
// Ignore, no Gson
}
}

public static ConfigurationProvider getProvider(Class<? extends ConfigurationProvider> provider) {
return providers.get(provider);
}
}

0 comments on commit 7d400dd

Please sign in to comment.