-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e463c36
commit 1546528
Showing
22 changed files
with
578 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
bukkit/src/main/java/net/leaderos/plugin/modules/verify/VerifyModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package net.leaderos.plugin.modules.verify; | ||
|
||
import net.leaderos.plugin.Bukkit; | ||
import net.leaderos.plugin.modules.verify.commands.VerifyCommand; | ||
import net.leaderos.shared.modules.LeaderOSModule; | ||
|
||
/** | ||
* Verify module of leaderos-plugin | ||
* | ||
* @author leaderos | ||
* @since 1.0 | ||
*/ | ||
public class VerifyModule extends LeaderOSModule { | ||
|
||
/** | ||
* onEnable method of module | ||
*/ | ||
public void onEnable() { | ||
Bukkit.getCommandManager().registerCommand(new VerifyCommand()); | ||
} | ||
|
||
/** | ||
* onDisable method of module | ||
*/ | ||
public void onDisable() { | ||
Bukkit.getCommandManager().unregisterCommand(new VerifyCommand()); | ||
} | ||
|
||
/** | ||
* Constructor of VerifyModule | ||
*/ | ||
public VerifyModule() {} | ||
} |
58 changes: 58 additions & 0 deletions
58
bukkit/src/main/java/net/leaderos/plugin/modules/verify/commands/VerifyCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package net.leaderos.plugin.modules.verify.commands; | ||
|
||
import dev.triumphteam.cmd.bukkit.annotation.Permission; | ||
import dev.triumphteam.cmd.core.BaseCommand; | ||
import dev.triumphteam.cmd.core.annotation.Command; | ||
import dev.triumphteam.cmd.core.annotation.Default; | ||
import lombok.RequiredArgsConstructor; | ||
import net.leaderos.plugin.Bukkit; | ||
import net.leaderos.plugin.helpers.ChatUtil; | ||
import net.leaderos.shared.helpers.RequestUtil; | ||
import net.leaderos.shared.model.Response; | ||
import net.leaderos.shared.model.request.impl.verify.VerifyRequest; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.net.HttpURLConnection; | ||
|
||
/** | ||
* Verify command | ||
* @author leaderos | ||
* @since 1.0 | ||
*/ | ||
@RequiredArgsConstructor | ||
@Command(value = "verify", alias = {"dogrula"}) | ||
public class VerifyCommand extends BaseCommand { | ||
|
||
/** | ||
* Verify command | ||
* @param player executor | ||
* @param code code | ||
*/ | ||
@Default | ||
@Permission("leaderos.verify") | ||
public void verifyCommand(Player player, String code) { | ||
if (!RequestUtil.canRequest(player.getUniqueId())) { | ||
ChatUtil.sendMessage(player, Bukkit.getInstance().getLangFile().getMessages().getHaveRequestOngoing()); | ||
return; | ||
} | ||
|
||
RequestUtil.addRequest(player.getUniqueId()); | ||
|
||
org.bukkit.Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getInstance(), () -> { | ||
try { | ||
String username = player.getName(); | ||
String uuid = player.getUniqueId().toString(); | ||
Response verifyRequest = new VerifyRequest(code, username, uuid).getResponse(); | ||
if (verifyRequest.getResponseCode() == HttpURLConnection.HTTP_OK && verifyRequest.getResponseMessage().getBoolean("status")) { | ||
ChatUtil.sendMessage(player, Bukkit.getInstance().getLangFile().getMessages().getVerify().getSuccessMessage()); | ||
} else { | ||
ChatUtil.sendMessage(player, Bukkit.getInstance().getLangFile().getMessages().getVerify().getFailMessage()); | ||
} | ||
} catch (Exception e) { | ||
ChatUtil.sendMessage(player, Bukkit.getInstance().getLangFile().getMessages().getVerify().getFailMessage()); | ||
} | ||
|
||
RequestUtil.invalidate(player.getUniqueId()); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.