Помогите Не могу разобраться с работой Maven

  • Автор темы Автор темы erger
  • Дата начала Дата начала

erger

Активный участник
Пользователь
Баллы
66
Имя в Minecraft
FeatureTeam
хочу добавить приложение гугл (генератор кодов)
Ошибка:
Код:
Could not pass event PlayerJoinEvent to GoogleAuth v1.0
java.lang.NoClassDefFoundError: com/warrenstrange/googleauth/GoogleAuthenticator
        at me.tutorial.google.GoogleMain.onJoin(GoogleMain.java:37) ~[?:?]
        at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor80.execute(Unknown Source) ~[?:?]
        at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:70) ~[paperVaruz.jar:git-Paper-1327]
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[paperVaruz.jar:git-Paper-1327]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[paperVaruz.jar:git-Paper-1327]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:515) [paperVaruz.jar:git-Paper-1327]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:500) [paperVaruz.jar:git-Paper-1327]
        at net.minecraft.server.v1_12_R1.PlayerList.onPlayerJoin(PlayerList.java:370) [paperVaruz.jar:git-Paper-1327]
        at net.minecraft.server.v1_12_R1.PlayerList.a(PlayerList.java:183) [paperVaruz.jar:git-Paper-1327]
        at net.minecraft.server.v1_12_R1.LoginListener.b(LoginListener.java:175) [paperVaruz.jar:git-Paper-1327]
        at net.minecraft.server.v1_12_R1.LoginListener.e(LoginListener.java:65) [paperVaruz.jar:git-Paper-1327]
        at net.minecraft.server.v1_12_R1.NetworkManager.a(NetworkManager.java:254) [paperVaruz.jar:git-Paper-1327]
        at net.minecraft.server.v1_12_R1.ServerConnection.c(ServerConnection.java:150) [paperVaruz.jar:git-Paper-1327]
        at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:941) [paperVaruz.jar:git-Paper-1327]
        at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:426) [paperVaruz.jar:git-Paper-1327]
        at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:767) [paperVaruz.jar:git-Paper-1327]
        at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:665) [paperVaruz.jar:git-Paper-1327]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_241]
Caused by: java.lang.ClassNotFoundException: com.warrenstrange.googleauth.GoogleAuthenticator
        at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_241]
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:156) ~[paperVaruz.jar:git-Paper-1327]
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:104) ~[paperVaruz.jar:git-Paper-1327]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_241]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_241]
        ... 18 more
pom.xml:
Код:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>google_auth</groupId>
    <artifactId>tutorial</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>com.warrenstrange</groupId>
            <artifactId>googleauth</artifactId>
            <version>1.1.2</version>
        </dependency>

    </dependencies>
</project>

код:
Код:
package me.tutorial.google;

import com.warrenstrange.googleauth.GoogleAuthenticator;
import com.warrenstrange.googleauth.GoogleAuthenticatorKey;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.plugin.java.JavaPlugin;

import java.rmi.activation.ActivationSystem;
import java.util.ArrayList;
import java.util.UUID;

public class GoogleMain extends JavaPlugin implements Listener {
    private ArrayList<UUID> authlocked;

    @Override
    public void onEnable() {
        this.getServer().getPluginManager().registerEvents(this, this);
        authlocked = new ArrayList<UUID>();

        this.getConfig().options().copyDefaults(true);
        this.saveConfig();
    }


    @EventHandler
    public void onJoin(PlayerJoinEvent event) {
        Player player = event.getPlayer();

        if (!this.getConfig().contains("authcodes." + player.getUniqueId())) {
            GoogleAuthenticator gAuth = new GoogleAuthenticator();
            GoogleAuthenticatorKey key = gAuth.createCredentials();

            player.sendMessage("§7Your §bGoogle Auth Code §7is §a" + key.getKey());
            player.sendMessage("§7You must enter this code in the Google Authenticator App before leaving the server.");

            this.getConfig().set("authcodes." + player.getUniqueId(), key.getKey());
            this.saveConfig();
        } else {
            authlocked.add(player.getUniqueId());
            player.sendMessage("§cPlease open the Google Authenticator App and provide the six digit code.");
        }
    }

    private boolean playerInputCode(Player player, int code) {
        String secretkey = this.getConfig().getString("authcodes." + player.getUniqueId());

        GoogleAuthenticator gAuth = new GoogleAuthenticator();
        boolean codeisvalid = gAuth.authorize(secretkey, code);


        if (codeisvalid) {
            authlocked.remove(player.getUniqueId());
            return codeisvalid;
        }

        return codeisvalid;
    }


    @EventHandler
    public void chat(AsyncPlayerChatEvent event) {
        Player player = event.getPlayer();
        String message = event.getMessage();

        if (authlocked.contains(player.getUniqueId())) {
            try {
                Integer code = Integer.parseInt(message);
                if (playerInputCode(player, code)) {
                    authlocked.remove(player.getUniqueId());
                    player.sendMessage("§a*Access Granted* §bWelcome to the server!");
                } else {
                    player.sendMessage("§cIncorrect or expired code ** A code will only contain numbers **");

                }
            } catch (Exception e) {
                player.sendMessage("§cIncorrect or expired code ** A code will only contain numbers **");
            }
            event.setCancelled(true);
        }
    }

    @EventHandler
    public void move(PlayerMoveEvent event) {
        Player player = event.getPlayer();
        if (authlocked.contains(player.getUniqueId())) {
            event.setCancelled(true);
        }
    }

    @EventHandler
    public void blockbreak(BlockBreakEvent event) {
        Player player = event.getPlayer();
        if (authlocked.contains(player.getUniqueId())) {
            event.setCancelled(true);
        }
    }

    @EventHandler
    public void blockplace(BlockPlaceEvent event) {
        Player player = event.getPlayer();
        if (authlocked.contains(player.getUniqueId())) {
            event.setCancelled(true);
        }
    }
}
 
Ты должен все это запихать в свой джарник.
Добавь эту штуку в свой pom.xml
Код:
<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <createDependencyReducedPom>false</createDependencyReducedPom>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>
 
Ты должен все это запихать в свой джарник.
Добавь эту штуку в свой pom.xml
Код:
<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <createDependencyReducedPom>false</createDependencyReducedPom>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>
появилась ошибка Error:java: invalid source release: 11
 
вот так запихнуть в джарник ?
 

Вложения

  • 2021-03-02_21-10-19.png
    2021-03-02_21-10-19.png
    11,2 КБ · Просмотры: 11
Можем пойти в дс ? покажешь ка нужно
 
я тебе несколько рубликов накину
 
Назад
Верх