当前位置: 首页>>代码示例>>Java>>正文


Java EventContext类代码示例

本文整理汇总了Java中org.spongepowered.api.event.cause.EventContext的典型用法代码示例。如果您正苦于以下问题:Java EventContext类的具体用法?Java EventContext怎么用?Java EventContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EventContext类属于org.spongepowered.api.event.cause包,在下文中一共展示了EventContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: reload

import org.spongepowered.api.event.cause.EventContext; //导入依赖的package包/类
public void reload() {
    deleteHolograms();
    created_managers.clear();
    config.reload();
    language_config.reload();
    virtual_cases_config.reload();
    virtual_keys_config.reload();
    timed_cases_delays_config.reload();
    timed_keys_delays_config.reload();
    saved_super_objects_config.reload();
    super_objects.clear();
    saved_super_objects.clear();
    loadConfigValues();
    default_cause = Cause.of(EventContext.empty(), plugin_container);
    register();
    optional_economy_service = Optional.empty();
    optional_holograms_service = Optional.empty();
    loadEconomy();
    loadHologramsService();
    loadSavedSuperObjects();
    loadManagers();
    if (check_updates) {
        checkUpdates();
    }
    logger.info("Plugin has been reloaded.");
}
 
开发者ID:GreWeMa,项目名称:gwm_Crates,代码行数:27,代码来源:GWMCrates.java

示例2: handleBasicStats

import org.spongepowered.api.event.cause.EventContext; //导入依赖的package包/类
private void handleBasicStats(ChannelHandlerContext ctx, DatagramPacket packet, int sessionId) {
    LanternServer server = this.queryServer.getGame().getServer();

    // TODO: Find out how to support the size and max size properties
    final Cause cause = Cause.of(EventContext.empty(),
            new SimpleRemoteConnection((InetSocketAddress) ctx.channel().remoteAddress(), null));
    final QueryServerEvent.Basic event = SpongeEventFactory.createQueryServerEventBasic(cause,
            (InetSocketAddress) ctx.channel().localAddress(), "SMP", this.getWorldName(), server.getMotd().toPlain(),
            server.getMaxPlayers(), Integer.MAX_VALUE, server.getOnlinePlayers().size(), 0);
    Sponge.getEventManager().post(event);

    final InetSocketAddress address = event.getAddress();

    final ByteBuf buf = ctx.alloc().buffer();
    buf.writeByte(ACTION_STATS);
    buf.writeInt(sessionId);
    writeString(buf, event.getMotd());
    writeString(buf, event.getGameType());
    writeString(buf, event.getMap());
    writeString(buf, String.valueOf(event.getPlayerCount()));
    writeString(buf, String.valueOf(event.getMaxPlayerCount()));
    buf.writeShortLE(address.getPort());
    writeString(buf, address.getHostString());
    ctx.write(new DatagramPacket(buf, packet.sender()));
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:26,代码来源:QueryHandler.java

示例3: channelActive

import org.spongepowered.api.event.cause.EventContext; //导入依赖的package包/类
@Override
public void channelActive(ChannelHandlerContext ctx) {
    final Channel channel = ctx.channel();
    final RconSource source = this.server.newSource(channel);

    final Cause cause = Cause.of(EventContext.empty(), source.getConnection());
    final RconConnectionEvent.Connect event = SpongeEventFactory.createRconConnectionEventConnect(cause, source);
    Sponge.getEventManager().post(event);
    if (event.isCancelled()) {
        ctx.channel().close();
        return;
    }

    if (!channel.attr(SOURCE).compareAndSet(null, source)) {
        throw new IllegalStateException("Rcon source may not be set more than once!");
    }

    this.server.onChannelActive(source);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:20,代码来源:RconHandler.java

示例4: handleLogin

import org.spongepowered.api.event.cause.EventContext; //导入依赖的package包/类
private static void handleLogin(ChannelHandlerContext ctx, String payload, String password, int requestId) {
    final RconSource source = ctx.channel().attr(SOURCE).get();
    if (password.equals(payload)) {
        final Cause cause = Cause.of(EventContext.empty(), source.getConnection());
        final RconConnectionEvent.Login event = SpongeEventFactory.createRconConnectionEventLogin(cause, source);

        if (!Sponge.getEventManager().post(event)) {
            source.setLoggedIn(true);
            sendResponse(ctx, requestId, TYPE_COMMAND, "");

            Lantern.getLogger().info("Rcon connection from [" + ctx.channel().remoteAddress() + "]");
            return;
        }
    }
    source.setLoggedIn(false);
    sendResponse(ctx, FAILURE, TYPE_COMMAND, "");
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:18,代码来源:RconHandler.java

示例5: addFunds

import org.spongepowered.api.event.cause.EventContext; //导入依赖的package包/类
private void addFunds(double amount, Player player) {
    String virt = JobsLite.getOption("virtual-draw");
    if (virt.equalsIgnoreCase("none")) {
        // Generate money
        account.deposit(JobsLite.getEconomyService().getDefaultCurrency(), BigDecimal.valueOf(amount),
                Cause.of(EventContext.empty(),(JobsLite.getInstance().container)));
    } else {
        // Transfer money
        Optional<Account> aOpt = JobsLite.getEconomyService().getOrCreateAccount(virt);
        if (aOpt.isPresent()) {
            if (!aOpt.get()
                    .transfer(account, JobsLite.getEconomyService().getDefaultCurrency(), BigDecimal.valueOf(amount),
                            Cause.of(EventContext.empty(),(JobsLite.getInstance().container))).getResult().equals(ResultType.SUCCESS)) {
                // Transfer failed
                if (!JobsLite.msgCache.contains(player.getUniqueId())) {
                    player.sendMessage(messageStorage.getMessage("working.nofunds"));
                    JobsLite.msgCache.add(player.getUniqueId());
                }
            }
        } else {
            // Failed to find account
            JobsLite.getInstance().logger.error("Failed to find virtual account! Payment will not be given!");
        }
    }
}
 
开发者ID:Flibio,项目名称:JobsLite,代码行数:26,代码来源:MobDeathListener.java

示例6: addFunds

import org.spongepowered.api.event.cause.EventContext; //导入依赖的package包/类
private void addFunds(double amount, Player player) {
    String virt = JobsLite.getOption("virtual-draw");
    if (virt.equalsIgnoreCase("none")) {
        // Generate money
        account.deposit(JobsLite.getEconomyService().getDefaultCurrency(), BigDecimal.valueOf(amount),
                Cause.of(EventContext.empty(), JobsLite.getInstance().container));
    } else {
        // Transfer money
        Optional<Account> aOpt = JobsLite.getEconomyService().getOrCreateAccount(virt);
        if (aOpt.isPresent()) {
            if (!aOpt.get()
                    .transfer(account, JobsLite.getEconomyService().getDefaultCurrency(), BigDecimal.valueOf(amount),
                            Cause.of(EventContext.empty(),JobsLite.getInstance().container)).getResult().equals(ResultType.SUCCESS)) {
                // Transfer failed
                if (!JobsLite.msgCache.contains(player.getUniqueId())) {
                    player.sendMessage(messageStorage.getMessage("working.nofunds"));
                    JobsLite.msgCache.add(player.getUniqueId());
                }
            }
        } else {
            // Failed to find account
            JobsLite.getInstance().logger.error("Failed to find virtual account! Payment will not be given!");
        }
    }
}
 
开发者ID:Flibio,项目名称:JobsLite,代码行数:26,代码来源:PlayerPlaceBlockListener.java

示例7: addFunds

import org.spongepowered.api.event.cause.EventContext; //导入依赖的package包/类
private void addFunds(double amount, Player player) {
    String virt = JobsLite.getOption("virtual-draw");
    if (virt.equalsIgnoreCase("none")) {
        // Generate money
        account.deposit(JobsLite.getEconomyService().getDefaultCurrency(), BigDecimal.valueOf(amount),
                Cause.of(EventContext.empty(), JobsLite.getInstance().container));
    } else {
        // Transfer money
        Optional<Account> aOpt = JobsLite.getEconomyService().getOrCreateAccount(virt);
        if (aOpt.isPresent()) {
            if (!aOpt.get()
                    .transfer(account, JobsLite.getEconomyService().getDefaultCurrency(), BigDecimal.valueOf(amount),
                            Cause.of(EventContext.empty(), JobsLite.getInstance().container)).getResult().equals(ResultType.SUCCESS)) {
                // Transfer failed
                if (!JobsLite.msgCache.contains(player.getUniqueId())) {
                    player.sendMessage(messageStorage.getMessage("working.nofunds"));
                    JobsLite.msgCache.add(player.getUniqueId());
                }
            }
        } else {
            // Failed to find account
            JobsLite.getInstance().logger.error("Failed to find virtual account! Payment will not be given!");
        }
    }
}
 
开发者ID:Flibio,项目名称:JobsLite,代码行数:26,代码来源:PlayerBlockBreakListener.java

示例8: run

import org.spongepowered.api.event.cause.EventContext; //导入依赖的package包/类
@Override
public void run(CommandSource src, CommandContext args) {
    if (args.getOne("player").isPresent() && args.getOne("amount").isPresent()) {
        User target = args.<User>getOne("player").get();
        String targetName = target.getName();
        BigDecimal toRemove = BigDecimal.valueOf(args.<Double>getOne("amount").get());
        Optional<UniqueAccount> uOpt = EconomyLite.getEconomyService().getOrCreateAccount(target.getUniqueId());
        if (uOpt.isPresent()) {
            UniqueAccount targetAccount = uOpt.get();
            if (targetAccount.withdraw(EconomyLite.getCurrencyService().getCurrentCurrency(), toRemove,
                    Cause.of(EventContext.empty(),(EconomyLite.getInstance()))).getResult().equals(ResultType.SUCCESS)) {
                src.sendMessage(messageStorage.getMessage("command.econ.removesuccess", "name", targetName));
                attemptNotify(target);
            } else {
                src.sendMessage(messageStorage.getMessage("command.econ.removefail", "name", targetName));
            }
        } else {
            src.sendMessage(messageStorage.getMessage("command.error"));
        }
    } else {
        src.sendMessage(messageStorage.getMessage("command.error"));
    }
}
 
开发者ID:Flibio,项目名称:EconomyLite,代码行数:24,代码来源:RemoveCommand.java

示例9: run

import org.spongepowered.api.event.cause.EventContext; //导入依赖的package包/类
@Override
public void run(CommandSource src, CommandContext args) {
    if (args.getOne("player").isPresent() && args.getOne("balance").isPresent()) {
        User target = args.<User>getOne("player").get();
        String targetName = target.getName();
        BigDecimal newBal = BigDecimal.valueOf(args.<Double>getOne("balance").get());
        Optional<UniqueAccount> uOpt = EconomyLite.getEconomyService().getOrCreateAccount(target.getUniqueId());
        if (uOpt.isPresent()) {
            UniqueAccount targetAccount = uOpt.get();
            if (targetAccount.setBalance(EconomyLite.getCurrencyService().getCurrentCurrency(), newBal,
                    Cause.of(EventContext.empty(),(EconomyLite.getInstance()))).getResult().equals(ResultType.SUCCESS)) {
                src.sendMessage(messageStorage.getMessage("command.econ.setsuccess", "name", targetName));
                attemptNotify(target);
            } else {
                src.sendMessage(messageStorage.getMessage("command.econ.setfail", "name", targetName));
            }
        } else {
            src.sendMessage(messageStorage.getMessage("command.error"));
        }
    } else {
        src.sendMessage(messageStorage.getMessage("command.error"));
    }
}
 
开发者ID:Flibio,项目名称:EconomyLite,代码行数:24,代码来源:SetCommand.java

示例10: run

import org.spongepowered.api.event.cause.EventContext; //导入依赖的package包/类
@Override
public void run(CommandSource src, CommandContext args) {
    if (args.getOne("player").isPresent() && args.getOne("amount").isPresent()) {
        User target = args.<User>getOne("player").get();
        String targetName = target.getName();
        BigDecimal toAdd = BigDecimal.valueOf(args.<Double>getOne("amount").get());
        Optional<UniqueAccount> uOpt = EconomyLite.getEconomyService().getOrCreateAccount(target.getUniqueId());
        if (uOpt.isPresent()) {
            UniqueAccount targetAccount = uOpt.get();
            if (targetAccount.deposit(EconomyLite.getCurrencyService().getCurrentCurrency(), toAdd,
                    Cause.of(EventContext.empty(),(EconomyLite.getInstance()))).getResult().equals(ResultType.SUCCESS)) {
                src.sendMessage(messageStorage.getMessage("command.econ.addsuccess", "name", targetName));
                attemptNotify(target);
            } else {
                src.sendMessage(messageStorage.getMessage("command.econ.addfail", "name", targetName));
            }
        } else {
            src.sendMessage(messageStorage.getMessage("command.error"));
        }
    } else {
        src.sendMessage(messageStorage.getMessage("command.error"));
    }
}
 
开发者ID:Flibio,项目名称:EconomyLite,代码行数:24,代码来源:AddCommand.java

示例11: run

import org.spongepowered.api.event.cause.EventContext; //导入依赖的package包/类
@Override
public void run(Player src, CommandContext args) {
    if (args.getOne("target").isPresent() && args.getOne("amount").isPresent()) {
        String target = args.<String>getOne("target").get();
        BigDecimal amount = BigDecimal.valueOf(args.<Double>getOne("amount").get());
        Optional<Account> aOpt = EconomyLite.getEconomyService().getOrCreateAccount(target);
        Optional<UniqueAccount> uOpt = EconomyLite.getEconomyService().getOrCreateAccount(src.getUniqueId());
        // Check for negative payments
        if (amount.doubleValue() <= 0) {
            src.sendMessage(messageStorage.getMessage("command.pay.invalid"));
        } else {
            if (aOpt.isPresent() && uOpt.isPresent()) {
                Account receiver = aOpt.get();
                UniqueAccount payer = uOpt.get();
                if (payer.transfer(receiver, ecoService.getDefaultCurrency(), amount, Cause.of(EventContext.empty(),(EconomyLite.getInstance())))
                        .getResult().equals(ResultType.SUCCESS)) {
                    src.sendMessage(messageStorage.getMessage("command.pay.success", "target", receiver.getDisplayName()));
                } else {
                    src.sendMessage(messageStorage.getMessage("command.pay.failed", "target", receiver.getDisplayName()));
                }
            }
        }
    } else {
        src.sendMessage(messageStorage.getMessage("command.error"));
    }
}
 
开发者ID:Flibio,项目名称:EconomyLite,代码行数:27,代码来源:PayVirtualCommand.java

示例12: run

import org.spongepowered.api.event.cause.EventContext; //导入依赖的package包/类
@Override
public void run(CommandSource src, CommandContext args) {
    if (args.getOne("account").isPresent() && args.getOne("amount").isPresent()) {
        String target = args.<String>getOne("account").get();
        BigDecimal newBal = BigDecimal.valueOf(args.<Double>getOne("amount").get());
        Optional<Account> aOpt = EconomyLite.getEconomyService().getOrCreateAccount(target);
        if (aOpt.isPresent()) {
            Account targetAccount = aOpt.get();
            if (targetAccount.setBalance(EconomyLite.getCurrencyService().getCurrentCurrency(), newBal,
                    Cause.of(EventContext.empty(),(EconomyLite.getInstance()))).getResult().equals(ResultType.SUCCESS)) {
                src.sendMessage(messageStorage.getMessage("command.econ.setsuccess", "name", targetAccount.getDisplayName()));
            } else {
                src.sendMessage(messageStorage.getMessage("command.econ.setfail", "name", targetAccount.getDisplayName()));
            }
        } else {
            src.sendMessage(messageStorage.getMessage("command.error"));
        }
    } else {
        src.sendMessage(messageStorage.getMessage("command.error"));
    }
}
 
开发者ID:Flibio,项目名称:EconomyLite,代码行数:22,代码来源:VirtualSetCommand.java

示例13: run

import org.spongepowered.api.event.cause.EventContext; //导入依赖的package包/类
@Override
public void run(CommandSource src, CommandContext args) {
    if (args.getOne("account").isPresent() && args.getOne("amount").isPresent()) {
        String target = args.<String>getOne("account").get();
        BigDecimal toRemove = BigDecimal.valueOf(args.<Double>getOne("amount").get());
        Optional<Account> aOpt = EconomyLite.getEconomyService().getOrCreateAccount(target);
        if (aOpt.isPresent()) {
            Account targetAccount = aOpt.get();
            if (targetAccount.withdraw(EconomyLite.getCurrencyService().getCurrentCurrency(), toRemove,
                    Cause.of(EventContext.empty(),(EconomyLite.getInstance()))).getResult().equals(ResultType.SUCCESS)) {
                src.sendMessage(messageStorage.getMessage("command.econ.removesuccess", "name", target));
            } else {
                src.sendMessage(messageStorage.getMessage("command.econ.removefail", "name", target));
            }
        } else {
            src.sendMessage(messageStorage.getMessage("command.error"));
        }
    } else {
        src.sendMessage(messageStorage.getMessage("command.error"));
    }
}
 
开发者ID:Flibio,项目名称:EconomyLite,代码行数:22,代码来源:VirtualRemoveCommand.java

示例14: run

import org.spongepowered.api.event.cause.EventContext; //导入依赖的package包/类
@Override
public void run(CommandSource src, CommandContext args) {
    if (args.getOne("account").isPresent() && args.getOne("amount").isPresent()) {
        String target = args.<String>getOne("account").get();
        BigDecimal toAdd = BigDecimal.valueOf(args.<Double>getOne("amount").get());
        Optional<Account> aOpt = EconomyLite.getEconomyService().getOrCreateAccount(target);
        if (aOpt.isPresent()) {
            Account targetAccount = aOpt.get();
            if (targetAccount.deposit(EconomyLite.getCurrencyService().getCurrentCurrency(), toAdd,
                    Cause.of(EventContext.empty(),(EconomyLite.getInstance()))).getResult().equals(ResultType.SUCCESS)) {
                src.sendMessage(messageStorage.getMessage("command.econ.addsuccess", "name", target));
            } else {
                src.sendMessage(messageStorage.getMessage("command.econ.addfail", "name", target));
            }
        } else {
            src.sendMessage(messageStorage.getMessage("command.error"));
        }
    } else {
        src.sendMessage(messageStorage.getMessage("command.error"));
    }
}
 
开发者ID:Flibio,项目名称:EconomyLite,代码行数:22,代码来源:VirtualAddCommand.java

示例15: onItemUse

import org.spongepowered.api.event.cause.EventContext; //导入依赖的package包/类
@Listener
public void onItemUse(FishingEvent.Start event, @Root Player player, @Getter("getContext") EventContext context) {

    context.get(EventContextKeys.USED_ITEM).ifPresent(itemStackSnapshot -> {
        ItemType itemType = itemStackSnapshot.getType();
        String itemId = itemType.getId();

        PermHandler ph = PermHandler.getInstance();

        if (!ph.checkPerm(player, "protectionperms.item.use." + itemId + ".on.self")) {
            event.setCancelled(true);
            player.sendMessage(ChatTypes.ACTION_BAR, Text.of(TextColors.RED, "You don't have permission to use " + itemType.getName() + '!'));
        }
    });
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:16,代码来源:FishingStartListener.java


注:本文中的org.spongepowered.api.event.cause.EventContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。