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


Java Cause类代码示例

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


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

示例1: reload

import org.spongepowered.api.event.cause.Cause; //导入依赖的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: sendChat

import org.spongepowered.api.event.cause.Cause; //导入依赖的package包/类
private void sendChat(Player player, Text message) {
    Text rawMessage = Text.of(message);
    MessageChannelEvent.Chat event = SpongeEventFactory.createMessageChannelEventChat(
            Cause.source(player).named(NamedCause.notifier(player)).build(),
            player.getMessageChannel(),
            Optional.of(player.getMessageChannel()),
            new MessageEvent.MessageFormatter(
                    Text.builder(player.getName()).build(), rawMessage
            ),
            rawMessage,
            false
    );
    if (!Sponge.getEventManager().post(event)) {
        MessageEvent.MessageFormatter formatter = event.getFormatter();
        player.getMessageChannel().send(player, chatTemplate.apply(
                ImmutableMap.of(MessageEvent.PARAM_MESSAGE_HEADER, formatter.getHeader(),
                        MessageEvent.PARAM_MESSAGE_BODY, formatter.getBody(),
                        MessageEvent.PARAM_MESSAGE_FOOTER, formatter.getFooter())).build());
    }
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:21,代码来源:ClanChatCommands.java

示例3: withdraw

import org.spongepowered.api.event.cause.Cause; //导入依赖的package包/类
public static boolean withdraw(UUID uuid, double charge) {
    if (charge == 0) {
        return true;
    }

    EconomyService economyService = MCClans.getPlugin().getServiceHelper().economyService;
    Currency currency = MCClans.getPlugin().getServiceHelper().currency;
    Optional<UniqueAccount> accountOpt = economyService.getOrCreateAccount(uuid);
    if (!accountOpt.isPresent()) {
        return false;
    }

    UniqueAccount account = accountOpt.get();
    TransactionResult result = account.withdraw(
            currency,
            BigDecimal.valueOf(charge),
            Cause.of(NamedCause.of("MCClans", MCClans.getPlugin()))
    );
    return (result.getResult().equals(ResultType.SUCCESS));
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:21,代码来源:EconomyUtils.java

示例4: performRemoval

import org.spongepowered.api.event.cause.Cause; //导入依赖的package包/类
private void performRemoval(LookupLine line) {
	World w = Sponge.getServer().getWorld(line.getWorld()).orElse(null);
	if (w == null) return;
	
	if (line.getTarget() instanceof ItemType) {
		
		Optional<TileEntity> te = w.getTileEntity(line.getPos());
		if (te.isPresent() && te.get() instanceof TileEntityCarrier) {
			TileEntityCarrier c = (TileEntityCarrier) te.get();
			Inventory i = c.getInventory();
			
			Inventory slot = i.query(new SlotIndex(line.getSlot()));
			slot.set(ItemStack.of(ItemTypes.NONE, 0));
		}
		
	} else if (line.getTarget() instanceof BlockType) {
		
		BlockState block = BlockState.builder().blockType(BlockTypes.AIR).build();
		w.setBlock(line.getPos(), block, Cause.source(container).build());
		
	}
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:23,代码来源:RollbackManager.java

示例5: createItem

import org.spongepowered.api.event.cause.Cause; //导入依赖的package包/类
@Override
public CustomTool createItem(Cause cause) {
    PluginContainer plugin = getPluginContainer();
    ItemStack itemStack = itemStackSnapshot.createStack();
    ItemType itemType = itemStack.getItem();
    int durability = DurabilityRegistry.getInstance().getDurability(itemType, plugin, getDefaultModel())
            .orElseThrow(() -> new IllegalStateException("Could not get the durability for the default models."));

    itemStack.offer(Keys.UNBREAKABLE, true);
    itemStack.offer(Keys.ITEM_DURABILITY, durability);
    itemStack.offer(Keys.HIDE_UNBREAKABLE, true);
    itemStack.offer(Keys.HIDE_ATTRIBUTES, true);
    itemStack.offer(createDefaultCustomFeatureData());

    CustomTool tool = new CustomTool(itemStack, this);
    CustomItemCreationEvent event = new CustomItemCreationEvent(tool, cause);

    Sponge.getEventManager().post(event);

    return tool;
}
 
开发者ID:Limeth,项目名称:CustomItemLibrary,代码行数:22,代码来源:CustomToolDefinition.java

示例6: triggerExplosion

import org.spongepowered.api.event.cause.Cause; //导入依赖的package包/类
private static boolean triggerExplosion(World world, int x, int baseY,
        int z, Cause cause) {
    int y = baseY + EXPLOSION_Y_OFFSET;
    Optional<Entity> opt = world.createEntity(EntityTypes.PRIMED_TNT,
            new Vector3i(x, y, z));
    if (!opt.isPresent()) {
        APlugin.getInstance().getLogger().info("Couldn't spawn PTNT at "
                + String.format("(%s, %s, %s)", x, y, z));
        return false;
    }
    Entity e = opt.get();
    ((EntityTNTPrimed) e).fuse = EXPLOSION_TIMER;
    // if (!e.offer(Keys.FUSE_DURATION, EXPLOSION_TIMER).isSuccessful()) {
    // APlugin.getInstance().getLogger().info("Couldn't set data on " + e);
    // return false;
    // }
    return world.spawnEntity(e, cause);
}
 
开发者ID:kenzierocks,项目名称:Annointment,代码行数:19,代码来源:EasterEggCommand.java

示例7: checkLocationForLobbySign

import org.spongepowered.api.event.cause.Cause; //导入依赖的package包/类
private boolean checkLocationForLobbySign(Location3D location) throws IllegalArgumentException {
    checkArgument(location.getWorld().isPresent(), "Location for lobby sign must contain world");
    java.util.Optional<World> world = Sponge.getServer().getWorld(location.getWorld().get());
    if (!world.isPresent()) {
        throw new IllegalArgumentException("Invalid world for lobby sign location");
    }

    Location<World> loc = WorldLocationConverter.of(location);
    if (!getLobbySignMap().containsKey(location)) {
        java.util.Optional<TileEntity> tile = loc.getExtent().getTileEntity(LocationConverter.floor(location));
        if (!tile.isPresent() || tile.get().getType() != TileEntityTypes.SIGN) {
            //TODO: maybe detect which sign type it should be?
            loc.setBlockType(BlockTypes.WALL_SIGN,
                    Cause.of(NamedCause.of("inferno:lobbyCreation", InfernoPlugin.getInstance())));
        }
        return true;
    }
    return false;
}
 
开发者ID:caseif,项目名称:Inferno,代码行数:20,代码来源:InfernoArena.java

示例8: fireDropItemEvent

import org.spongepowered.api.event.cause.Cause; //导入依赖的package包/类
private void fireDropItemEvent(World world, Vector3i pos) {
    List<ItemStack> stacks = getDroppedItems();
    if (stacks.isEmpty()) {
        return;
    }
    List<Entity> entities = Lists.newArrayList();
    for (ItemStack stack : stacks) {
        Entity drop = createItemDrop(world, pos, stack);
        entities.add(drop);
    }
    Cause cause = Cause.source(BlockSpawnCause.builder()
            .type(SpawnTypes.DROPPED_ITEM)
            .block(world.createSnapshot(pos))
            .build())
            .build();
    DropItemEvent.Destruct harvestEvent = SpongeEventFactory.createDropItemEventDestruct(cause, entities);
    if (Sponge.getEventManager().post(harvestEvent)) {
        return;
    }
    for (Entity entity : harvestEvent.getEntities()) {
        world.spawnEntity(entity, cause);
    }
}
 
开发者ID:simon816,项目名称:Industrialization,代码行数:24,代码来源:PipeBlock.java

示例9: spawnItem

import org.spongepowered.api.event.cause.Cause; //导入依赖的package包/类
public void spawnItem(Location<World> location, ItemStackSnapshot snapshot, Object notifier) {
    World world = location.getExtent();
    Item rejectedItem = (Item) world.createEntity(EntityTypes.ITEM, location.getPosition());

    Cause cause = Cause.source(
            EntitySpawnCause.builder()
                    .entity(rejectedItem)
                    .type(SpawnTypes.PLUGIN)
                    .build()
            )
            .owner(CustomItemLibrary.getInstance().getPluginContainer())
            .notifier(notifier)
            .build();

    rejectedItem.offer(Keys.REPRESENTED_ITEM, snapshot);
    world.spawnEntity(rejectedItem, cause);
}
 
开发者ID:Limeth,项目名称:CustomItemLibrary,代码行数:18,代码来源:Util.java

示例10: deposit

import org.spongepowered.api.event.cause.Cause; //导入依赖的package包/类
@Override
public TransactionResult deposit(final Currency currency, final BigDecimal amount, final Cause cause, final Set<Context> contexts) {
	BigDecimal before = this.getBalance(currency);
	BigDecimal after = before.add(amount);
	
	// Quantité positive
	if (amount.compareTo(BigDecimal.ZERO) >= 0) {
		// Inférieur au max
		if (after.compareTo(ECurrency.getBalanceMax(currency)) <= 0) {
			// Transfére
			this.setBalance(currency, after);
			this.log(currency, before, after, TransactionTypes.DEPOSIT, cause);
			return new ETransactionResult(this.plugin, this, currency, amount, contexts, ResultType.SUCCESS, TransactionTypes.DEPOSIT);
		}
		return new ETransactionResult(this.plugin, this, currency, amount, contexts, ResultType.ACCOUNT_NO_SPACE, TransactionTypes.DEPOSIT);
	}
	return new ETransactionResult(this.plugin, this, currency, amount, contexts, ResultType.FAILED, TransactionTypes.DEPOSIT);
}
 
开发者ID:EverCraft,项目名称:EverEconomy,代码行数:19,代码来源:EAccount.java

示例11: reload

import org.spongepowered.api.event.cause.Cause; //导入依赖的package包/类
@Listener
public void reload(GameReloadEvent event) throws Exception {
	Cause cause = Cause.source(this).build();

	// Unregistering everything
	GameStoppingEvent gameStoppingEvent = SpongeEventFactory.createGameStoppingEvent(cause);
	stop(gameStoppingEvent);

	// Starting over
	GameInitializationEvent gameInitializationEvent = SpongeEventFactory.createGameInitializationEvent(cause);
	init(gameInitializationEvent);

	logger.info("Reloaded successfully!");
}
 
开发者ID:AuraDevelopmentTeam,项目名称:InvSync,代码行数:15,代码来源:InventorySync.java

示例12: transfer

import org.spongepowered.api.event.cause.Cause; //导入依赖的package包/类
private static boolean transfer(Account fromAccount, Account toAccount, Currency currency, double charge) {
    if (charge == 0) {
        return true;
    }

    TransactionResult result = fromAccount.transfer(
            toAccount,
            currency,
            BigDecimal.valueOf(charge),
            Cause.of(NamedCause.of("MCClans", MCClans.getPlugin()))
    );
    return (result.getResult().equals(ResultType.SUCCESS));
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:14,代码来源:EconomyUtils.java

示例13: ClanCreateEvent

import org.spongepowered.api.event.cause.Cause; //导入依赖的package包/类
public ClanCreateEvent(String clanTag, String clanName, ClanPlayer owner) {
    super("Clan creation cancelled by an external plugin", Cause.of(NamedCause.owner(owner)));

    this.clanTag = clanTag;
    this.clanName = clanName;
    this.owner = owner;
}
 
开发者ID:iLefty,项目名称:mcClans,代码行数:8,代码来源:ClanCreateEvent.java

示例14: Open

import org.spongepowered.api.event.cause.Cause; //导入依赖的package包/类
public CommandResult Open(CommandSource src, CommandContext args, org.spongepowered.api.item.inventory.Inventory i) {
    final Player player = Tools.getPlayer(src, vt);
    if (src.getCommandSource().isPresent() && src.getCommandSource().get() instanceof Player) {
        player.openInventory(i, Cause.of(NamedCause.of("plugin", vt), NamedCause.source(player)));
        return CommandResult.success();
    }
    return CommandResult.empty();
}
 
开发者ID:poqdavid,项目名称:VirtualTool,代码行数:9,代码来源:Invs.java

示例15: performAddition

import org.spongepowered.api.event.cause.Cause; //导入依赖的package包/类
private void performAddition(LookupLine line) {
	//TODO: Debug this function, blocks are not being added
	
	World w = Sponge.getServer().getWorld(line.getWorld()).orElse(null);
	if (w == null) return;
	
	if (line.getTarget() instanceof ItemType) {
		
		Optional<TileEntity> te = w.getTileEntity(line.getPos());
		if (te.isPresent() && te.get() instanceof TileEntityCarrier) {
			TileEntityCarrier c = (TileEntityCarrier) te.get();
			Inventory i = c.getInventory();
			
			ItemType type = (ItemType) line.getTarget();
			ItemStack stack = ItemStack.builder()
					.fromContainer(line.getDataAsView())
					.itemType(type)
					.quantity(line.getCount())
					.build();
			Inventory slot = i.query(new SlotIndex(line.getSlot()));
			slot.set(stack);
		}
		
	} else if (line.getTarget() instanceof BlockType) {
		
		BlockState block = BlockState.builder().build(line.getDataAsView()).orElse(null);
		if (block != null)
			w.setBlock(line.getPos(), block, Cause.source(container).build());
		
	}
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:32,代码来源:RollbackManager.java


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