Search in sources :

Example 1 with JailHandler

use of io.github.nucleuspowered.nucleus.modules.jail.handlers.JailHandler in project Nucleus by NucleusPowered.

the class JailModule method performEnableTasks.

@Override
public void performEnableTasks() {
    createSeenModule(CheckJailCommand.class, (c, u) -> {
        // If we have a ban service, then check for a ban.
        JailHandler jh = Nucleus.getNucleus().getInternalServiceManager().getService(JailHandler.class).get();
        if (jh.isPlayerJailed(u)) {
            JailData jd = jh.getPlayerJailDataInternal(u).get();
            Text.Builder m;
            if (jd.getRemainingTime().isPresent()) {
                m = NucleusPlugin.getNucleus().getMessageProvider().getTextMessageWithFormat("seen.isjailed.temp", Util.getTimeToNow(jd.getEndTimestamp().get())).toBuilder();
            } else {
                m = NucleusPlugin.getNucleus().getMessageProvider().getTextMessageWithFormat("seen.isjailed.perm").toBuilder();
            }
            return Lists.newArrayList(m.onClick(TextActions.runCommand("/checkjail " + u.getName())).onHover(TextActions.showText(NucleusPlugin.getNucleus().getMessageProvider().getTextMessageWithFormat("standard.clicktoseemore"))).build(), NucleusPlugin.getNucleus().getMessageProvider().getTextMessageWithFormat("standard.reason", jd.getReason()));
        }
        return Lists.newArrayList(NucleusPlugin.getNucleus().getMessageProvider().getTextMessageWithFormat("seen.notjailed"));
    });
}
Also used : JailHandler(io.github.nucleuspowered.nucleus.modules.jail.handlers.JailHandler) JailData(io.github.nucleuspowered.nucleus.modules.jail.data.JailData) Text(org.spongepowered.api.text.Text)

Example 2 with JailHandler

use of io.github.nucleuspowered.nucleus.modules.jail.handlers.JailHandler 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;
    }
}
Also used : PermissionService(org.spongepowered.api.service.permission.PermissionService) Nucleus(io.github.nucleuspowered.nucleus.Nucleus) JailHandler(io.github.nucleuspowered.nucleus.modules.jail.handlers.JailHandler)

Aggregations

JailHandler (io.github.nucleuspowered.nucleus.modules.jail.handlers.JailHandler)2 Nucleus (io.github.nucleuspowered.nucleus.Nucleus)1 JailData (io.github.nucleuspowered.nucleus.modules.jail.data.JailData)1 PermissionService (org.spongepowered.api.service.permission.PermissionService)1 Text (org.spongepowered.api.text.Text)1