[API 7.4+] Plugin to stop infinite water source creation

This whole thing started in another thread:

User @MoseMister suggested to go by the following lead:

  • on world block change
  • if change turns into watersource due to a watersource connected on blockface (this sounds complex, but thanks to sponge cause system, its not)
  • if true then cancel

If anyone has the time to spare to create such a plugin for API 7.4 and maybe also for 8.0 as it is in stable now and might help others as well, that would be very much appriciated, as I myself do not have the knowledge nor the time to create such a thing.

Kind regards,
Pax

Push

Would still be much appricitated.
I tried to use mmcs Option for specific restricted blocks, but tust sadly didnt so the trick either.

package pl.brawlsmons.siwsc;

import com.google.inject.Inject;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.LinearComponents;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.Style;
import net.kyori.adventure.text.format.TextDecoration;
import org.apache.logging.log4j.Logger;
import org.spongepowered.api.Server;
import org.spongepowered.api.command.Command;
import org.spongepowered.api.command.CommandResult;
import org.spongepowered.api.command.parameter.Parameter;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.block.ChangeBlockEvent;
import org.spongepowered.api.event.lifecycle.ConstructPluginEvent;
import org.spongepowered.api.event.lifecycle.RegisterCommandEvent;
import org.spongepowered.api.event.lifecycle.StartingEngineEvent;
import org.spongepowered.api.event.lifecycle.StoppingEngineEvent;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;
import org.spongepowered.plugin.PluginContainer;
import org.spongepowered.plugin.builtin.jvm.Plugin;

@Plugin(“SIWSC”)
public class SIWSC {

private final PluginContainer container;
private final Logger logger;

@Inject
SIWSC(final PluginContainer container, final Logger logger) {
    this.container = container;
    this.logger = logger;
}

@Listener
public void onConstructPlugin(final ConstructPluginEvent event) {
    this.logger.info("Constructing SIWSC");
}

@Listener
public void onServerStarting(final StartingEngineEvent<Server> event) {
}

@Listener
public void onServerStopping(final StoppingEngineEvent<Server> event) {
}

@Listener
public void onBlockChange(ChangeBlockEvent.Place event) {
    for (Location<World> location : event.getLocations()) {
        if (location.getBlock().getType() == BlockTypes.WATER) {
            event.setCancelled(true);
        }
    }
}

@Listener
public void onRegisterCommands(final RegisterCommandEvent<Command.Parameterized> event) {
    final Parameter.Value<String> nameParam = Parameter.string().key("name").build();
    event.register(this.container, Command.builder()
        .addParameter(nameParam)
        .permission("SIWSC.command.greet")
        .executor(ctx -> {
            final String name = ctx.requireOne(nameParam);
            ctx.sendMessage(Identity.nil(), LinearComponents.linear(
                NamedTextColor.AQUA,
                Component.text("Hello "),
                Component.text(name, Style.style(TextDecoration.BOLD)),
                Component.text("!")
            ));

            return CommandResult.success();
        })
        .build(), "greet", "wave");
}

}
try using this :relieved: