This repository has been archived by the owner on Jul 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Utils Converters
Leonhard edited this page Sep 16, 2020
·
6 revisions
The converters are located in the simplixcore-common-api.
All classes of the Converter system are located in the simplixcore-common-api
module.
No other dependencies than described in getting started are required.
import dev.simplix.core.common.converter.Converter;
import dev.simplix.core.common.converter.Converters;
import java.util.UUID;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
public class ConvertablesExample {
public void registerConvertables() {
Converters.register(UUID.class, ProxiedPlayer.class, new Converter<UUID, ProxiedPlayer>() {
@Override
public ProxiedPlayer convert(UUID src) {
final ProxiedPlayer out = ProxyServer.getInstance().getPlayer(src);
if (out == null) {
throw new IllegalStateException("No player found for '" + src + "'");
}
return out;
}
});
}
public void exampleUsage(UUID uuid) {
final ProxiedPlayer player = Converters.convert(uuid, ProxiedPlayer.class);
}
}
2020 - SimplixSoftworks
- Introduction
- Getting started
- Maven Dependencies
- How to use the Dependency-Injection
- Localization
- Listener API
- SQL
- Libraries
- Utilities
- Contribute