use of io.github.nucleuspowered.nucleus.Nucleus in project Nucleus by NucleusPowered.
the class CoreTask method accept.
@Override
public void accept(Task task) {
Nucleus plugin = Nucleus.getNucleus();
plugin.getUserDataManager().removeOfflinePlayers();
if (this.printSave || Nucleus.getNucleus().isDebugMode()) {
plugin.getLogger().info(plugin.getMessageProvider().getMessageWithFormat("core.savetask.starting"));
}
plugin.saveData();
if (this.printSave || Nucleus.getNucleus().isDebugMode()) {
plugin.getLogger().info(plugin.getMessageProvider().getMessageWithFormat("core.savetask.complete"));
}
}
use of io.github.nucleuspowered.nucleus.Nucleus in project Nucleus by NucleusPowered.
the class TextParsingUtils method getTextForUrl.
private static Text getTextForUrl(String url, String msg, String whiteSpace, StyleTuple st, @Nullable String optionString) {
String toParse = TextSerializers.FORMATTING_CODE.stripCodes(url);
Nucleus plugin = Nucleus.getNucleus();
try {
URL urlObj;
if (!toParse.startsWith("http://") && !toParse.startsWith("https://")) {
urlObj = new URL("http://" + toParse);
} else {
urlObj = new URL(toParse);
}
Text.Builder textBuilder = Text.builder(msg).color(st.colour).style(st.style).onClick(TextActions.openUrl(urlObj));
if (optionString == null || !optionString.contains("h")) {
textBuilder.onHover(TextActions.showText(plugin.getMessageProvider().getTextMessageWithFormat("chat.url.click", url)));
}
if (!whiteSpace.isEmpty()) {
return Text.builder(whiteSpace).append(textBuilder.build()).build();
}
return textBuilder.build();
} catch (MalformedURLException e) {
// URL parsing failed, just put the original text in here.
plugin.getLogger().warn(plugin.getMessageProvider().getMessageWithFormat("chat.url.malformed", url));
if (Nucleus.getNucleus().isDebugMode()) {
e.printStackTrace();
}
Text ret = Text.builder(url).color(st.colour).style(st.style).build();
if (!whiteSpace.isEmpty()) {
return Text.builder(whiteSpace).append(ret).build();
}
return ret;
}
}
use of io.github.nucleuspowered.nucleus.Nucleus in project Nucleus by NucleusPowered.
the class CoreListener method onPlayerJoinLast.
@Listener
public void onPlayerJoinLast(final ClientConnectionEvent.Join event, @Getter("getTargetEntity") final Player player) {
if (Nucleus.getNucleus().getUserDataManager().get(player).map(x -> x.get(CoreUserDataModule.class).isFirstPlay()).orElse(true)) {
NucleusFirstJoinEvent firstJoinEvent = new OnFirstLoginEvent(event.getCause(), player, event.getOriginalChannel(), event.getChannel().orElse(null), event.getOriginalMessage(), event.isMessageCancelled(), event.getFormatter());
Sponge.getEventManager().post(firstJoinEvent);
event.setChannel(firstJoinEvent.getChannel().get());
event.setMessageCancelled(firstJoinEvent.isMessageCancelled());
Nucleus.getNucleus().getUserDataManager().getUnchecked(player).get(CoreUserDataModule.class).setStartedFirstJoin(false);
}
// Warn about wildcard.
if (!ServiceChangeListener.isOpOnly() && player.hasPermission("nucleus")) {
MessageProvider provider = this.plugin.getMessageProvider();
Nucleus.getNucleus().getLogger().warn("The player " + player.getName() + " has got either the nucleus wildcard or the * wildcard " + "permission. This may cause unintended side effects.");
if (this.warnOnWildcard) {
// warn
List<Text> text = Lists.newArrayList();
text.add(provider.getTextMessageWithFormat("core.permission.wildcard2"));
text.add(provider.getTextMessageWithFormat("core.permission.wildcard3"));
if (this.url != null) {
text.add(provider.getTextMessageWithFormat("core.permission.wildcard4").toBuilder().onClick(TextActions.openUrl(this.url)).build());
}
text.add(provider.getTextMessageWithFormat("core.permission.wildcard5"));
Sponge.getServiceManager().provideUnchecked(PaginationService.class).builder().title(provider.getTextMessageWithFormat("core.permission.wildcard")).contents(text).padding(Text.of(TextColors.GOLD, "-")).sendTo(player);
}
}
}
use of io.github.nucleuspowered.nucleus.Nucleus in project Nucleus by NucleusPowered.
the class JailModule method performPreTasks.
@Override
protected void performPreTasks() throws Exception {
try {
Nucleus nucleus = Nucleus.getNucleus();
JailHandler jh = new JailHandler(nucleus);
Sponge.getServiceManager().setProvider(nucleus, NucleusJailService.class, jh);
serviceManager.registerService(JailHandler.class, jh);
// Context
Sponge.getServiceManager().provide(PermissionService.class).ifPresent(x -> x.registerContextCalculator(jh));
} catch (Exception ex) {
Nucleus.getNucleus().getLogger().warn("Could not load the jail module for the reason below.");
ex.printStackTrace();
throw ex;
}
}
use of io.github.nucleuspowered.nucleus.Nucleus in project Nucleus by NucleusPowered.
the class ListWorldCommand method getWorldInfo.
static void getWorldInfo(List<Text> listContent, WorldProperties x, boolean canSeeSeeds) {
Nucleus plugin = Nucleus.getNucleus();
// Name of world
if (!listContent.isEmpty()) {
listContent.add(SPACE);
}
listContent.add(plugin.getMessageProvider().getTextMessageWithFormat("command.world.list.worlditem", x.getWorldName()));
// As requested by Pixelmon for use in their config.
x.getAdditionalProperties().getInt(DataQuery.of("SpongeData", "dimensionId")).ifPresent(i -> listContent.add(plugin.getMessageProvider().getTextMessageWithFormat("command.world.list.dimensionid", String.valueOf(i))));
Vector3i spawnPosition = x.getSpawnPosition();
listContent.add(plugin.getMessageProvider().getTextMessageWithFormat("command.world.list.spawnpoint", String.valueOf(spawnPosition.getX()), String.valueOf(spawnPosition.getY()), String.valueOf(spawnPosition.getZ())));
listContent.add(plugin.getMessageProvider().getTextMessageWithFormat("command.world.list.uuid", x.getUniqueId().toString()));
if (x.isEnabled()) {
boolean worldLoaded = Sponge.getServer().getWorld(x.getUniqueId()).isPresent();
String message = (worldLoaded ? "&a" : "&c") + plugin.getMessageProvider().getMessageWithFormat(worldLoaded ? "standard.true" : "standard.false");
listContent.add(plugin.getMessageProvider().getTextMessageWithFormat("command.world.list.enabled", message));
} else {
listContent.add(plugin.getMessageProvider().getTextMessageWithFormat("command.world.list.disabled"));
}
if (canSeeSeeds) {
listContent.add(plugin.getMessageProvider().getTextMessageWithFormat("command.world.list.seed", String.valueOf(x.getSeed())));
}
listContent.add(plugin.getMessageProvider().getTextMessageWithFormat("command.world.list.params", x.getDimensionType().getName(), x.getGeneratorType().getName(), CreateWorldCommand.modifierString(x.getGeneratorModifiers()), x.getGameMode().getName(), x.getDifficulty().getName()));
listContent.add(plugin.getMessageProvider().getTextMessageWithFormat("command.world.list.params2", String.valueOf(x.isHardcore()), String.valueOf(x.loadOnStartup()), String.valueOf(x.isPVPEnabled()), String.valueOf(x.doesKeepSpawnLoaded())));
}
Aggregations