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


Java ChangeSignEvent类代码示例

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


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

示例1: onChangeSignEvent

import org.spongepowered.api.event.block.tileentity.ChangeSignEvent; //导入依赖的package包/类
@Listener
public void onChangeSignEvent(ChangeSignEvent e, @First Player player) {
    if (plugin.getMainConfig().isUseSigns()) {
        if (player.hasPermission("minecraftmarket.signs")) {
            Optional<Text> optionalLine1 = e.getText().get(0);
            Optional<Text> optionalLine2 = e.getText().get(1);
            if (optionalLine1.isPresent() && optionalLine2.isPresent()) {
                String line1 = optionalLine1.get().toPlain();
                String line2 = optionalLine2.get().toPlain();
                if (line1.equals("[RecentDonor]") && Utils.isInt(line2)) {
                    int order = Utils.getInt(line2);
                    if (order > 0) {
                        if (plugin.getSignsConfig().addDonorSign(order, e.getTargetTile().getLocation())) {
                            player.sendMessage(Colors.color(I18n.tl("prefix") + " " + I18n.tl("sign_added")));
                            plugin.getSignsTask().updateSigns();
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:MinecraftMarket,项目名称:MinecraftMarket-Plugin,代码行数:23,代码来源:SignsListener.java

示例2: onSignChanged

import org.spongepowered.api.event.block.tileentity.ChangeSignEvent; //导入依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onSignChanged(ChangeSignEvent event, @First User player)
{
	if (!ConfigHandler.getNode("worlds").getNode(event.getTargetTile().getLocation().getExtent().getName()).getNode("enabled").getBoolean())
	{
		return;
	}
	if (player.hasPermission("nations.admin.bypass.perm.build"))
	{
		return;
	}
	if (!DataHandler.getPerm("build", player.getUniqueId(), event.getTargetTile().getLocation()))
	{
		event.setCancelled(true);
	}
}
 
开发者ID:Arckenver,项目名称:Nations,代码行数:17,代码来源:BuildPermListener.java

示例3: onSignChange

import org.spongepowered.api.event.block.tileentity.ChangeSignEvent; //导入依赖的package包/类
@Listener
public void onSignChange(ChangeSignEvent event, @First Subject cause)
{
    ListValue<Text> lines = event.getText().lines();
    if (!cause.hasPermission(SIGN_STYLED.getId()))
    {
        for (int i = 0; i < lines.size(); i++)
        {
            lines.set(i, Text.of(lines.get(i).toPlain().replaceAll("&[klmno]", "")));
        }
    }
    if (cause.hasPermission(SIGN_COLORED.getId()))
    {
        for (int i = 0; i < lines.size(); i++)
        {
            lines.set(i, Text.of(lines.get(i).toPlain().replaceAll("&[0123456789abcdef]", "")));
        }
    }

    for (int i = 0; i < lines.size(); i++)
    {
        lines.set(i, TextSerializers.FORMATTING_CODE.deserialize(lines.get(i).toPlain()));
    }
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:25,代码来源:ColoredSigns.java

示例4: onSignCreate

import org.spongepowered.api.event.block.tileentity.ChangeSignEvent; //导入依赖的package包/类
@Listener(order = Order.EARLY)
public void onSignCreate(ChangeSignEvent event, @Root Player p) {
    //Sign colors
    List<Text> lines = event.getText().lines().get();
    lines.set(0, TextUtil.replaceColors(lines.get(0), p, "uc.sign"));
    lines.set(1, TextUtil.replaceColors(lines.get(1), p, "uc.sign"));
    lines.set(2, TextUtil.replaceColors(lines.get(2), p, "uc.sign"));
    lines.set(3, TextUtil.replaceColors(lines.get(3), p, "uc.sign"));
    event.getText().setElements(lines);

    //Registered signs
    for (UCSign sign : UltimateCore.get().getSignService().get().getRegisteredSigns()) {
        if (event.getText().get(0).orElse(Text.of()).toPlain().equalsIgnoreCase("[" + sign.getIdentifier() + "]")) {
            if (!p.hasPermission(sign.getCreatePermission().get())) {
                Messages.send(p, "core.nopermissions");
            }
            SignCreateEvent cevent = new SignCreateEvent(sign, event.getTargetTile().getLocation(), Cause.builder().owner(UltimateCore.getContainer()).notifier(p).build());
            Sponge.getEventManager().post(cevent);
            if (!cevent.isCancelled() && sign.onCreate(p, event)) {
                //Color sign
                event.getTargetTile().offer(Keys.SIGN_LINES, event.getText().setElement(0, Text.of(TextColors.AQUA, "[" + StringUtil.firstUpperCase(sign.getIdentifier()) + "]")).asList());
                Messages.send(p, "sign.create", "%sign%", sign.getIdentifier());
            }
        }
    }
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:27,代码来源:SignListener.java

示例5: onSignChanged

import org.spongepowered.api.event.block.tileentity.ChangeSignEvent; //导入依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onSignChanged(ChangeSignEvent event)
{
	Optional<List<Shop>> shops = ShopsData.getShops(event.getTargetTile().getLocation());
	if (shops.isPresent()) {
		event.setCancelled(true);
	}
}
 
开发者ID:TheoKah,项目名称:CarrotShop,代码行数:9,代码来源:BlockBreakListener.java

示例6: onSignChange

import org.spongepowered.api.event.block.tileentity.ChangeSignEvent; //导入依赖的package包/类
@Listener(order = Order.POST)
public void onSignChange(ChangeSignEvent event) {
    for (Map.Entry<String, Minigame> entry : CommonCore.getMinigames().entrySet()) {
        if (event.getText().get(0).get().toPlain().equalsIgnoreCase("[" + entry.getKey() + "]")) {
            if (entry.getValue().getConfigValue(ConfigNode.ENABLE_LOBBY_WIZARD)) {
                Optional<Player> player = event.getCause().first(Player.class);
                if (!player.isPresent()) {
                    return;
                }

                if (player.get().hasPermission(entry.getKey() + ".lobby.create")
                        || player.get().hasPermission(entry.getKey() + ".lobby.*")) {
                    IWizardManager wm = ((InfernoMinigame) entry.getValue()).getLobbyWizardManager();
                    if (!wm.hasPlayer(player.get().getUniqueId())) {
                        wm.addPlayer(player.get().getUniqueId(),
                                WorldLocationConverter.of(event.getTargetTile().getLocation()));
                    } else {
                        player.get().sendMessage(Text.builder().color(TextColors.RED)
                                .append(LiteralText.of("You are already in a lobby sign wizard")).toText());
                    }
                } else {
                    player.get().sendMessage(Text.builder().color(TextColors.RED)
                            .append(LiteralText.of("You do not have permission to do this")).toText());
                }
            }
            return;
        }
    }
}
 
开发者ID:caseif,项目名称:Inferno,代码行数:30,代码来源:LobbyListener.java

示例7: onSignChange

import org.spongepowered.api.event.block.tileentity.ChangeSignEvent; //导入依赖的package包/类
@Listener
public void onSignChange(ChangeSignEvent event, @First Player player)
{
	SignData signData = event.getText();

	if (signData.getValue(Keys.SIGN_LINES).isPresent())
	{
		String line0 = signData.getValue(Keys.SIGN_LINES).get().get(0).toPlain();
		String line1 = signData.getValue(Keys.SIGN_LINES).get().get(1).toPlain();
		String line2 = signData.getValue(Keys.SIGN_LINES).get().get(2).toPlain();
		String line3 = signData.getValue(Keys.SIGN_LINES).get().get(3).toPlain();

		if (line0.equals("[Warp]"))
		{
			if (Utils.getWarps().contains(line1))
			{
				signData = signData.set(signData.getValue(Keys.SIGN_LINES).get().set(0, Text.of(TextColors.DARK_BLUE, "[Warp]")));
			}
			else
			{
				signData = signData.set(signData.getValue(Keys.SIGN_LINES).get().set(0, Text.of(TextColors.DARK_RED, "[Warp]")));
			}
		}
		else if (player != null && player.hasPermission("essentialcmds.color.sign.use"))
		{
			signData = signData.set(signData.getValue(Keys.SIGN_LINES).get().set(0, TextSerializers.formattingCode('&').deserialize(line0)));
			signData = signData.set(signData.getValue(Keys.SIGN_LINES).get().set(1, TextSerializers.formattingCode('&').deserialize(line1)));
			signData = signData.set(signData.getValue(Keys.SIGN_LINES).get().set(2, TextSerializers.formattingCode('&').deserialize(line2)));
			signData = signData.set(signData.getValue(Keys.SIGN_LINES).get().set(3, TextSerializers.formattingCode('&').deserialize(line3)));
		}
	}
}
 
开发者ID:hsyyid,项目名称:EssentialCmds,代码行数:33,代码来源:SignChangeListener.java

示例8: signChange

import org.spongepowered.api.event.block.tileentity.ChangeSignEvent; //导入依赖的package包/类
@Listener
public void signChange(ChangeSignEvent event) throws Exception {
    ListValue<Text> lines = event.getText().lines();

    // Check that the first line is [warp]
    if (lines.get(0).toPlain().equalsIgnoreCase(Constants.WARP_SIGN_PREFIX)) {
        // Second line has to be the name of the warp
        String warpName = lines.get(1).toPlain();
        Optional<Warp> optWarp = this.plugin.getWarpManager().getOne(warpName);
        if (!optWarp.isPresent()) {
            return;
        }
        event.getText().set(Util.generateWarpSignData(optWarp.get()).getValues());

        WarpDataManipulatorBuilder builder = (WarpDataManipulatorBuilder) Sponge.getDataManager().getManipulatorBuilder(WarpData.class).get();
        WarpData data = builder.createFrom(optWarp.get());
        DataTransactionResult result = event.getTargetTile().offer(data);

        if (!result.isSuccessful()) {
            // Couldn't offer WarpData to the sign - log in the console and
            // warn the possible player that placed the sign
            String error =
                    "Failed to offer WarpData " + data.toContainer().toString() + " to the Sign at "
                            + event.getTargetTile().getLocation().toString();
            plugin.getLogger().warn(error);
            Optional<Player> optPlayer = event.getCause().first(Player.class);
            if (optPlayer.isPresent()) {
                optPlayer.get().sendMessage(Text.of(TextColors.RED, Constants.PREFIX, " ", error));
            }

        }
    }

}
 
开发者ID:RobertHerhold,项目名称:BLWarps,代码行数:35,代码来源:ChangeSignEventHandler.java

示例9: onSignChange

import org.spongepowered.api.event.block.tileentity.ChangeSignEvent; //导入依赖的package包/类
@Listener
public void onSignChange(ChangeSignEvent event, @First Player player) {
    Sign signTile = event.getTargetTile();
    if (!signTile.get(LiteKeys.JOB_NAME).isPresent() && player.hasPermission("jobs.admin.sign.create")) {
        SignData data = event.getText();
        try {
            if (data.getValue(Keys.SIGN_LINES).get().get(0).toPlain().equals("[JobsLite]")) {
                String signJob = data.getValue(Keys.SIGN_LINES).get().get(1).toPlain();
                if (jobManager.jobExists(signJob)) {
                    signTile.offer(data.set(data.getValue(Keys.SIGN_LINES).get().set(0, Text.of("[Job]"))));
                    SignJobDataManipulatorBuilder builder =
                            (SignJobDataManipulatorBuilder) Sponge.getDataManager().getManipulatorBuilder(SignJobData.class).get();
                    SignJobData signJobData = builder.setSignInfo(signJob).create();
                    signTile.offer(signJobData);
                    player.sendMessage(messageStorage.getMessage("sign.success"));
                    return;
                } else {
                    player.sendMessage(messageStorage.getMessage("sign.nojob"));
                    return;
                }
            }
        } catch (IndexOutOfBoundsException | NoSuchElementException e) {
            player.sendMessage(messageStorage.getMessage("sign.invalid"));
            return;
        }
    } else if (signTile.get(LiteKeys.JOB_NAME).isPresent() && !player.hasPermission("jobs.admin.sign.delete")) {
        player.sendMessage(messageStorage.getMessage("sign.nopermission"));
        event.setCancelled(true);
    }
}
 
开发者ID:Flibio,项目名称:JobsLite,代码行数:31,代码来源:SignListeners.java

示例10: onSignChange

import org.spongepowered.api.event.block.tileentity.ChangeSignEvent; //导入依赖的package包/类
@Listener
public void onSignChange(ChangeSignEvent event)
{
    Optional<MarketSignData> data = event.getTargetTile().get(MarketSignData.class);
    if (data.isPresent())
    {
        manager.updateSignText(data.get(), event.getTargetTile().getLocation());
    }
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:10,代码来源:MarketSignListener.java

示例11: onSignChanged

import org.spongepowered.api.event.block.tileentity.ChangeSignEvent; //导入依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onSignChanged(ChangeSignEvent event) {
    final User user = CauseContextHelper.getEventUser(event);
    if (user == null) {
        return;
    }

    if (!GriefPreventionPlugin.instance.claimsEnabledForWorld(event.getTargetTile().getLocation().getExtent().getProperties())) {
        return;
    }

    GPTimings.SIGN_CHANGE_EVENT.startTimingIfSync();
    Location<World> location = event.getTargetTile().getLocation();
    // Prevent users exploiting signs
    GPClaim claim = GriefPreventionPlugin.instance.dataStore.getClaimAt(location);
    if (GPPermissionHandler.getClaimPermission(event, location, claim, GPPermissions.INTERACT_BLOCK_SECONDARY, user, location.getBlock(), user, TrustType.ACCESSOR, true) == Tristate.FALSE) {
        if (user instanceof Player) {
            event.setCancelled(true);
            final Text message = GriefPreventionPlugin.instance.messageData.permissionAccess
                    .apply(ImmutableMap.of(
                    "player", Text.of(claim.getOwnerName()))).build();
            GriefPreventionPlugin.sendClaimDenyMessage(claim, (Player) user, message);
            return;
        }
    }

    // send sign content to online administrators
    if (!GriefPreventionPlugin.getActiveConfig(location.getExtent().getProperties())
            .getConfig().general.generalAdminSignNotifications) {
        GPTimings.SIGN_CHANGE_EVENT.stopTimingIfSync();
        return;
    }

    World world = location.getExtent();
    StringBuilder lines = new StringBuilder(" placed a sign @ " + GriefPreventionPlugin.getfriendlyLocationString(event.getTargetTile().getLocation()));
    boolean notEmpty = false;
    for (int i = 0; i < event.getText().lines().size(); i++) {
        String withoutSpaces = Text.of(event.getText().lines().get(i)).toPlain().replace(" ", "");
        if (!withoutSpaces.isEmpty()) {
            notEmpty = true;
            lines.append("\n  " + event.getText().lines().get(i));
        }
    }

    String signMessage = lines.toString();
    // prevent signs with blocked IP addresses
    if (!user.hasPermission(GPPermissions.SPAM) && GriefPreventionPlugin.instance.containsBlockedIP(signMessage)) {
        event.setCancelled(true);
        GPTimings.SIGN_CHANGE_EVENT.stopTimingIfSync();
        return;
    }

    // if not empty and wasn't the same as the last sign, log it and remember it for later
    GPPlayerData playerData = this.dataStore.getOrCreatePlayerData(world, user.getUniqueId());
    if (notEmpty && playerData.lastMessage != null && !playerData.lastMessage.equals(signMessage)) {
        GriefPreventionPlugin.addLogEntry(user.getName() + lines.toString().replace("\n  ", ";"), null);
        //PlayerEventHandler.makeSocialLogEntry(player.get().getName(), signMessage);
        playerData.lastMessage = signMessage;

        if (!user.hasPermission(GPPermissions.EAVES_DROP_SIGNS)) {
            Collection<Player> players = (Collection<Player>) Sponge.getGame().getServer().getOnlinePlayers();
            for (Player otherPlayer : players) {
                if (otherPlayer.hasPermission(GPPermissions.EAVES_DROP_SIGNS)) {
                    otherPlayer.sendMessage(Text.of(TextColors.GRAY, user.getName(), signMessage));
                }
            }
        }
    }
    GPTimings.SIGN_CHANGE_EVENT.stopTimingIfSync();
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:71,代码来源:BlockEventHandler.java

示例12: setErrorSign

import org.spongepowered.api.event.block.tileentity.ChangeSignEvent; //导入依赖的package包/类
protected void setErrorSign(ChangeSignEvent e, String error) {
	SignData sign = e.getText();
	sign = sign.set(sign.getValue(Keys.SIGN_LINES).get().set(0, RPUtil.toText(RPLang.get("regionbuilder.signerror"))));
    this.setError(e.getCause().first(Player.class).get(), error);
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:6,代码来源:RegionBuilder.java

示例13: setErrorSign

import org.spongepowered.api.event.block.tileentity.ChangeSignEvent; //导入依赖的package包/类
void setErrorSign(ChangeSignEvent e, Player p, String error) {
    List<Text> lines = e.getTargetTile().get(Keys.SIGN_LINES).get();
    lines.set(0, RPUtil.toText(RPLang.get("regionbuilder.signerror")));
    e.getTargetTile().offer(Keys.SIGN_LINES, lines);
    RPLang.sendMessage(p, RPLang.get("regionbuilder.signerror") + ": " + error);
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:7,代码来源:RPBlockListener.java

示例14: onCreate

import org.spongepowered.api.event.block.tileentity.ChangeSignEvent; //导入依赖的package包/类
@Override
public boolean onCreate(Player p, ChangeSignEvent event) {
    return true;
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:5,代码来源:WarpSign.java

示例15: onCreate

import org.spongepowered.api.event.block.tileentity.ChangeSignEvent; //导入依赖的package包/类
/**
 * Called when a player creates a new sign, normally by clicking the confirm button after typing a sign.
 * Permission checks and messages will be done by the implementation.
 *
 * @param p     The player who created the sign
 * @param event The event which was thrown after creating the sign
 */
boolean onCreate(Player p, ChangeSignEvent event);
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:9,代码来源:UCSign.java


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