I tried to create my own plugin for privates, just to learn how to create plugins, but the plugin doesn’t work, and in the console it is mentioned only once as “non-mod”.
Console log:
[18:34:35] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLServerTweaker
[18:34:35] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLServerTweaker
[18:34:35] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLServerTweaker
[18:34:35] [main/INFO] [FML]: Forge Mod Loader version 14.23.5.2860 for Minecraft 1.12.2 loading
[18:34:35] [main/INFO] [FML]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_341, running on Windows 11:amd64:10.0, installed at C:\Program Files\Java\jre1.8.0_341
[18:34:35] [main/INFO] [FML]: Searching E:\server huini\.\mods for mods
[18:34:35] [main/INFO] [FML]: Loading tweaker org.spongepowered.asm.launch.MixinTweaker from spongeforge-1.12.2-2838-7.4.7.jar
[18:34:35] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[18:34:35] [main/INFO] [LaunchWrapper]: Loading tweak class name org.spongepowered.asm.launch.MixinTweaker
[18:34:35] [main/INFO] [mixin]: SpongePowered MIXIN Subsystem Version=0.8 Source=file:/E:/server%20huini/./mods/spongeforge-1.12.2-2838-7.4.7.jar Service=LaunchWrapper Env=SERVER
[18:34:36] [main/WARN] [FML]: The coremod SpongeCoremod (org.spongepowered.mod.SpongeCoremod) is not signed!
[18:34:36] [main/INFO] [mixin]: Compatibility level set to JAVA_8
[18:34:36] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[18:34:36] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[18:34:36] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[18:34:36] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
[18:34:40] [main/INFO] [FML]: Found valid fingerprint for Minecraft Forge. Certificate fingerprint e3c3d50c7c986df74c645c0ac54639741c90a557
[18:34:40] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
[18:34:40] [main/INFO] [LaunchWrapper]: Calling tweak class org.spongepowered.asm.launch.MixinTweaker
[18:34:40] [main/INFO] [mixin]: Initialised Mixin FML Remapper Adapter with net.minecraftforge.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper@27e32fe4
[18:34:40] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[18:34:42] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker
[18:34:42] [main/INFO] [LaunchWrapper]: Loading tweak class name org.spongepowered.asm.mixin.EnvironmentStateTweaker
[18:34:42] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker
[18:34:42] [main/INFO] [LaunchWrapper]: Calling tweak class org.spongepowered.asm.mixin.EnvironmentStateTweaker
[18:34:52] [main/WARN] [mixin]: @Mixin target net/minecraft/block/state/BlockStateContainer$StateImplementation is public in mixins.common.api.json:mcp.block.state.StateImplementationMixin_API and should be specified in value
[18:35:41] [main/WARN] [mixin]: Static binding violation: PRIVATE @Overwrite method func_189509_E in mixins.common.core.json:world.WorldMixin cannot reduce visibiliy of PUBLIC target method, visibility will be upgraded.
[18:35:57] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.server.MinecraftServer}
[18:36:25] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Starting minecraft server version 1.12.2
[18:36:26] [Server thread/INFO] [FML]: MinecraftForge v14.23.5.2860 Initialized
[18:36:26] [Server thread/INFO] [FML]: Starts to replace vanilla recipe ingredients with ore ingredients.
[18:36:26] [Server thread/INFO] [FML]: Invalid recipe found with multiple oredict ingredients in the same ingredient...
[18:36:26] [Server thread/INFO] [FML]: Replaced 1227 ore ingredients
[18:36:29] [Server thread/INFO] [Sponge]: Found mcmod.info at jar:file:/E:/server%20huini/./mods/spongeforge-1.12.2-2838-7.4.7.jar!/mcmod.info
[18:36:29] [Server thread/INFO] [Sponge]: Creating injector in stage 'PRODUCTION'
[18:36:40] [Server thread/INFO] [FML]: Searching E:\server huini\.\mods for mods
[18:36:40] [Server thread/INFO] [FML]: Searching %s for plugins
[18:36:41] [Server thread/INFO] [FML]: Forge Mod Loader has identified 7 mods to load
[18:36:41] [Server thread/WARN] [FML]: Missing English translation for FML: assets/fml/lang/en_us.lang
[18:36:41] [Server thread/WARN] [FML]: Missing English translation for spongeapi: assets/spongeapi/lang/en_us.lang
[18:36:41] [Server thread/WARN] [FML]: Missing English translation for spongeforge: assets/spongeforge/lang/en_us.lang
[18:36:41] [Server thread/INFO] [FML]: FML has found a non-mod file plugin-for-no-name.jar in your mods directory. It will now be injected into your classpath. This could severe stability issues, it should be removed if possible.
[18:36:41] [Server thread/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, spongeapi, sponge, spongeforge] at CLIENT
[18:36:41] [Server thread/INFO] [FML]: Attempting connection with missing mods [minecraft, mcp, FML, forge, spongeapi, sponge, spongeforge] at SERVER
[18:36:42] [Server thread/WARN] [Sponge]: There's no certificate fingerprint available
[18:36:42] [Server thread/INFO] [FML]: Processing ObjectHolder annotations
[18:36:42] [Server thread/INFO] [FML]: Found 1168 ObjectHolder annotations
[18:36:42] [Server thread/INFO] [FML]: Identifying ItemStackHolder annotations
[18:36:42] [Server thread/INFO] [FML]: Found 0 ItemStackHolder annotations
[18:36:42] [Server thread/INFO] [FML]: Configured a dormant chunk cache size of 0
[18:36:42] [Forge Version Check/INFO] [forge.VersionCheck]: [forge] Starting version check at http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json
[18:36:42] [Server thread/INFO] [org.spongepowered.mod.SpongeMod]: Log test
[18:36:44] [Server thread/INFO] [FML]: Applying holder lookups
[18:36:44] [Server thread/INFO] [FML]: Holder lookups applied
[18:36:44] [Server thread/INFO] [FML]: Applying holder lookups
[18:36:44] [Server thread/INFO] [FML]: Holder lookups applied
[18:36:44] [Server thread/WARN] [FML]: Potentially Dangerous alternative prefix `sponge` for name `human`, expected `spongeforge`. This could be a intended override, but in most cases indicates a broken mod.
[18:36:44] [Server thread/INFO] [FML]: Applying holder lookups
[18:36:44] [Server thread/INFO] [FML]: Holder lookups applied
[18:36:44] [Server thread/INFO] [FML]: Applying holder lookups
[18:36:44] [Server thread/INFO] [FML]: Holder lookups applied
[18:36:44] [Server thread/INFO] [FML]: Injecting itemstacks
[18:36:44] [Server thread/INFO] [FML]: Itemstack injection complete
[18:36:44] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Loading properties
[18:36:44] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Default game type: SURVIVAL
[18:36:44] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Generating keypair
[18:36:44] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Starting Minecraft server on *:25565
[18:36:44] [Server thread/INFO] [net.minecraft.network.NetworkSystem]: Using default channel type
[18:36:45] [Forge Version Check/INFO] [forge.VersionCheck]: [forge] Found status: AHEAD Target: null
[18:36:45] [Forge Version Check/INFO] [forge.VersionCheck]: [spongeforge] Starting version check at https://files.minecraftforge.net/maven/org/spongepowered/spongeforge/promotions_slim.json
[18:36:45] [Server thread/WARN] [net.minecraft.server.dedicated.DedicatedServer]: **** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!
[18:36:45] [Server thread/WARN] [net.minecraft.server.dedicated.DedicatedServer]: The server will make no attempt to authenticate usernames. Beware.
[18:36:45] [Server thread/WARN] [net.minecraft.server.dedicated.DedicatedServer]: While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.
[18:36:45] [Server thread/WARN] [net.minecraft.server.dedicated.DedicatedServer]: To change this, set "online-mode" to "true" in the server.properties file.
[18:36:46] [Server thread/INFO] [FML]: Applying holder lookups
[18:36:46] [Server thread/INFO] [FML]: Holder lookups applied
[18:36:46] [Server thread/INFO] [FML]: Injecting itemstacks
[18:36:46] [Server thread/INFO] [FML]: Itemstack injection complete
[18:36:46] [Forge Version Check/INFO] [forge.VersionCheck]: [spongeforge] Found status: OUTDATED Target: 7.1.2
[18:36:46] [Server thread/INFO] [FML]: Forge Mod Loader has successfully loaded 7 mods
[18:36:47] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Preparing level "world"
[18:36:47] [Server thread/INFO] [Sponge]: Checking for worlds that need to be migrated...
[18:36:47] [Server thread/INFO] [Sponge]: No worlds were found in need of migration.
[18:36:47] [Server thread/INFO] [FML]: Injecting existing registry data into this server instance
[18:36:48] [Server thread/INFO] [FML]: Applying holder lookups
[18:36:48] [Server thread/INFO] [FML]: Holder lookups applied
[18:36:49] [Server thread/INFO] [net.minecraft.advancements.AdvancementList]: Loaded 488 advancements
[18:36:50] [Server thread/INFO] [net.minecraft.advancements.AdvancementList]: Loaded 6 advancement trees
[18:36:50] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Preparing start region for world world (minecraft:overworld/0)
[18:36:51] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Preparing spawn area: 0%
[18:36:52] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Preparing spawn area: 9%
[18:36:53] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Preparing spawn area: 48%
[18:36:54] [Server thread/INFO] [Sponge]: Loading world [world] (minecraft:overworld/0)
[18:36:55] [Server thread/INFO] [net.minecraft.advancements.AdvancementList]: Loaded 488 advancements
[18:36:55] [Server thread/INFO] [net.minecraft.advancements.AdvancementList]: Loaded 6 advancement trees
[18:36:55] [Server thread/INFO] [Sponge]: Loading world [DIM-1] (minecraft:nether/-1)
[18:36:55] [Server thread/INFO] [net.minecraft.advancements.AdvancementList]: Loaded 488 advancements
[18:36:55] [Server thread/INFO] [net.minecraft.advancements.AdvancementList]: Loaded 6 advancement trees
[18:36:55] [Server thread/INFO] [Sponge]: Loading world [DIM1] (minecraft:the_end/1)
[18:36:55] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Done (8,876s)! For help, type "help" or "?"
[18:37:55] [Netty Server IO #2/INFO] [FML]: Client protocol version 2
[18:37:55] [Netty Server IO #2/INFO] [FML]: Client attempting to join with 5 mods : [email protected],[email protected],[email protected],[email protected],[email protected]
[18:37:55] [Netty Server IO #2/INFO] [FML]: Attempting connection with missing mods [spongeapi, sponge, spongeforge] at CLIENT
[18:37:55] [Server thread/INFO] [FML]: [Server thread] Server side modded connection established
[18:37:55] [Server thread/INFO] [net.minecraft.server.management.PlayerList]: VPStarPlatinum [/127.0.0.1:61831] logged in with entity id [344] in world (minecraft:overworld/0) at (-199.78587354425133, 75.0, 364.59704758848665).
[18:37:55] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: VPStarPlatinum joined the game
[18:41:23] [Server thread/INFO] [net.minecraft.network.NetHandlerPlayServer]: VPStarPlatinum lost connection: Disconnected
[18:41:29] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: VPStarPlatinum left the game
[18:41:29] [Server thread/WARN] [net.minecraft.server.MinecraftServer]: Can't keep up! Did the system time change, or is the server overloaded? Running 5779ms behind, skipping 115 tick(s)
[18:41:31] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Unknown command. Try /help for a list of commands
[18:41:33] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Unknown command. Try /help for a list of commands
[18:41:35] [Server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Stopping the server
[18:41:35] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Stopping server
[18:41:35] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Saving players
[18:41:35] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Saving worlds
[18:41:35] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Saving chunks for level 'world'/0
[18:41:35] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Saving chunks for level 'DIM-1'/-1
[18:41:35] [Server thread/INFO] [net.minecraft.server.MinecraftServer]: Saving chunks for level 'DIM1'/1
[18:41:35] [Server thread/INFO] [Sponge]: Unloading world [world] (minecraft:overworld/0)
[18:41:35] [Server thread/INFO] [Sponge]: Unloading world [DIM-1] (minecraft:nether/-1)
[18:41:35] [Server thread/INFO] [Sponge]: Unloading world [DIM1] (minecraft:the_end/1)
Plugin code:
package idi.nahui.pluginfornoname;
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.jetbrains.annotations.NotNull;
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.entity.living.player.Player;
import org.spongepowered.api.event.Cancellable;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.block.InteractBlockEvent;
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.server.ServerWorld;
import org.spongepowered.math.vector.Vector3i;
import org.spongepowered.plugin.PluginContainer;
import org.spongepowered.plugin.builtin.jvm.Plugin;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
/**
* The main class of your Sponge plugin.
*
* <p>All methods are optional -- some common event registrations are included as a jumping-off point.</p>
*/
@Plugin("plugin-for-no-name")
public class Plugin_for_no_name {
private final PluginContainer container;
private final Logger logger;
private Map<UUID, Territory> privateTerritories;
@Inject
Plugin_for_no_name(final PluginContainer container, final Logger logger) {
this.container = container;
this.logger = logger;
}
@Listener
public void onConstructPlugin(final ConstructPluginEvent event) {
// Perform any one-time setup
this.logger.info("test");
}
@Listener
public void onServerStarting(final StartingEngineEvent<Server> event) {
// Any setup per-game instance. This can run multiple times when
// using the integrated (singleplayer) server.
privateTerritories = new HashMap<>();
loadTerritories();
}
@Listener
public void onServerStopping(final StoppingEngineEvent<Server> event) {
// Any tear down per-game instance. This can run multiple times when
// using the integrated (singleplayer) server.
saveTerritories();
}
@Listener
public void onRegisterCommands(final RegisterCommandEvent<Command.Parameterized> event) {
// Register a simple command
// When possible, all commands should be registered within a command register event
final Parameter.Value<String> nameParam = Parameter.string().key("name").build();
event.register(this.container, Command.builder()
.addParameter(nameParam)
.permission("plugin-for-no-name.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");
event.register(this.container, Command.builder()
.shortDescription(Component.text("set pos 1"))
.executor(src -> {
if (src instanceof Player) {
Player player = (Player) src;
privateTerritories.putIfAbsent(player.uniqueId(), new Territory());
Territory territory = privateTerritories.get(player.uniqueId());
territory.SetPos1(player.blockPosition());
player.sendMessage(Component.text("done"));
}
return CommandResult.success();
})
.build(), "setPos1");
event.register(this.container, Command.builder()
.shortDescription(Component.text("set pos 2"))
.executor(src -> {
if (src instanceof Player) {
Player player = (Player) src;
privateTerritories.putIfAbsent(player.uniqueId(), new Territory());
Territory territory = privateTerritories.get(player.uniqueId());
territory.SetPos2(player.blockPosition());
player.sendMessage(Component.text("done"));
}
return CommandResult.success();
})
.build(), "setPos2");
event.register(this.container, Command.builder()
.shortDescription(Component.text("Заприватить территорию"))
.executor(src -> {
if (src instanceof Player) {
Player player = (Player) src;
Territory territory = privateTerritories.get(player.uniqueId());
if (territory != null && territory.isComplete()) {
territory.SetOwner(player.uniqueId());
player.sendMessage(Component.text("the territory is locked"));
saveTerritories();
} else {
player.sendMessage(Component.text("for private you need to put 2 positions"));
}
}
return CommandResult.success();
})
.build(), "privateTerritory");
}
@Listener
public void onInteractBlock(InteractBlockEvent event) {
if (event.cause().first(Player.class).isPresent()) {
Player player = event.cause().first(Player.class).get();
privateTerritories.forEach((uuid, territory) -> {
if (territory.isInside(event.block().position()) && event instanceof Cancellable) {
((Cancellable) event).setCancelled(true);
player.sendMessage(Component.text("You cannot interact with blocks in this area!"));
}
});
}
}
private void saveTerritories() {
try (FileOutputStream fileOut = new FileOutputStream("territories.ser");
ObjectOutputStream out = new ObjectOutputStream(fileOut)) {
out.writeObject(privateTerritories);
out.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
private void loadTerritories() {
try (FileInputStream fileIn = new FileInputStream("territories.ser");
ObjectInputStream in = new ObjectInputStream(fileIn)) {
Object obj = in.readObject();
if (obj instanceof Map) {
privateTerritories = (Map<UUID, Territory>) obj;
}
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
}
}
private class Territory
{
private UUID ownerID;
public Vector3i pos1;
public Vector3i pos2;
public void SetOwner(UUID playerID)
{
this.ownerID = playerID;
}
public void SetPos1(Vector3i pos1)
{
this.pos1 = pos1;
}
public void SetPos2(Vector3i pos2)
{
this.pos2 = pos2;
}
public boolean isComplete() {
return pos1 != null && pos2 != null;
}
public boolean isInside(Vector3i position) {
if (pos1 != null && pos2 != null) {
int minX = Math.min(pos1.x(), pos2.x());
int minY = Math.min(pos1.y(), pos2.y());
int minZ = Math.min(pos1.z(), pos2.z());
int maxX = Math.max(pos1.x(), pos2.x());
int maxY = Math.max(pos1.y(), pos2.y());
int maxZ = Math.max(pos1.z(), pos2.z());
return position.x() >= minX && position.x() <= maxX &&
position.y() >= minY && position.y() <= maxY &&
position.z() >= minZ && position.z() <= maxZ;
}
return false;
}
}
}