This commit is contained in:
femsci 2023-04-21 22:56:48 +02:00
commit 56d69abdc0
Signed by: femsci
GPG key ID: 08F7911F0E650C67
203 changed files with 15543 additions and 0 deletions

83
AuthentiCat/src/config.yml Executable file
View file

@ -0,0 +1,83 @@
#Force all players to log in after server reload (not restart)
reset-on-reload: true
#If set to true, prevents players from chat usage before authentication
disallow-speech: false
#Time (in seconds) until player is kicked due to authentication fail (set to -1 to disable)
#It is recommended to set the time as greater than 15s
kick-timeout: 20
#The "reason" message of kicking after timeout (set to 'null' in order to disable)
kick-timeout-message: "&cAuthentication timeout!"
#The delay (in seconds) after which prompt messages will be sent to the player (set to -1 in order to disable)
prompt-initial-delay: 3
#The delay (in seconds) between prompt messages (set to -1 in order to disable)
prompt-repeat-delay: 5
#The prompt messages (set to 'null' in order to disable):
#
#The register prompt message
prompt-message-register: "&aType &6/register <password> &ato register yourself"
#
#The login prompt message
prompt-message-login: "&aType &6/login <password> &ato log in yourself"
#Command messages (message is shown *when [...]*)
#Successes
#When successfully changed the password
cmd-success-changepass: "&aYour password has been successfully changed!"
#When successfully logged out
cmd-success-logout: "&aLogged out!"
#When successfully logged in
cmd-success-login: "&aLogged in!"
#When successfully registered
cmd-success-register: "&aRegistered! From now on, every time you join this server, use &6/login <password>&a!"
#Fails
#When player uses too many arguments
cmd-fail-general-overargs: "&cToo many arguments!"
#When the passwords do not match
cmd-fail-passwords-mismatch: "&cYour old password argument does not match the actual password!"
#When the new password is not specified
cmd-fail-nonewpassword: "&cYou need to specify the new password!"
#When neither the old nor the new password is specified
cmd-fail-nobothpasswords: "&cYou need to specify the passwords!"
#When player does not have any password set and tries to change their password
cmd-fail-nopassset: "&cYou don't have any password set!"
#When player passes arguments to a command that does not accept any
cmd-fail-noargsallowed: "&cThis command does not allow any arguments!"
#When player needs to login instead of registering
cmd-fail-just-login: "&cYou need to login!"
#When player uses an incorrect password
cmd-fail-badpassword: "&cIncorrect password!"
#When player uses more than one argument for a
cmd-fail-nopassword-overargs: "&cYou need to specify the password as a single argument!"
#When the password is not specified
cmd-fail-nopassword: "&cYou need to specify the password!"
#When player tries to authenticate while being already authenticated
cmd-fail-already-authenticated: "&cYou are already authenticated!"
#When player uses /login without being registered
cmd-fail-register-first: "&cYou need to register first!"
#When the player is not authenticated and tries to use commands other than /login or /register
cmd-prompt-badcommand: "§cAuthenticate before you can speak!"

View file

@ -0,0 +1,115 @@
package me.yuri.authcat;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.player.*;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList;
import java.util.List;
public class CatGirls implements Listener {
protected static List<Player> catgirls = new ArrayList<>();
@EventHandler
public void ohayou(PlayerJoinEvent e) {
catgirls.add(e.getPlayer());
brian(e.getPlayer());
}
static void brian(Player p) {
new BukkitRunnable() {
final int delay = Neko.prmdelay;
final int repeat = Neko.prmrepeat;
final int kick = Neko.timeout;
final String km = Neko.timeoutmsg;
int cnt = 0;
final String msg = (Neko.getCatEars().oof(p.getName()) == null) ? Neko.promptreg : Neko.promptlog;
@Override
public void run() {
if (!catgirls.contains(p)) {
cancel();
return;
}
if (cnt == delay) {
p.sendMessage(msg);
}
if ((cnt + delay) % repeat == 0 && cnt > delay) {
p.sendMessage(msg);
}
if (cnt >= kick) {
p.kickPlayer(km.equalsIgnoreCase("null") ? null : km);
}
cnt++;
}
}.runTaskTimer(Neko.getCatEars(), 0L, 20L);
}
@EventHandler
public void matanedesune(PlayerQuitEvent e) {
catgirls.remove(e.getPlayer());
}
@EventHandler
public void iiiiiiiiiiine(PlayerInteractEvent e) {
if (catgirls.contains(e.getPlayer())) e.setCancelled(true);
}
@EventHandler
public void yoidesune(PlayerDropItemEvent e) {
if (catgirls.contains(e.getPlayer())) e.setCancelled(true);
}
@EventHandler
public void desudesu(InventoryOpenEvent e) {
if (catgirls.contains(((Player) e.getPlayer()))) e.setCancelled(true);
}
@EventHandler
public void plsstop(PlayerItemConsumeEvent e) {
if (catgirls.contains(e.getPlayer())) e.setCancelled(true);
}
@EventHandler
public void socute(PlayerItemHeldEvent e) {
if (catgirls.contains(e.getPlayer())) e.setCancelled(true);
}
@EventHandler
public void highsocks(EntityDamageEvent e) {
if (e.getEntity() instanceof Player)
if (catgirls.contains(((Player) e.getEntity()))) e.setCancelled(true);
}
@EventHandler
public void thisisirritatingsrsly(PlayerMoveEvent e) {
if (catgirls.contains(e.getPlayer())) e.setCancelled(true);
}
@EventHandler
public void nekoooooo(AsyncPlayerChatEvent e) {
if (Neko.disallowspeech)
if (catgirls.contains(e.getPlayer())) {
e.getPlayer().sendMessage(Neko.cmdpromptbadcmd);
e.setCancelled(true);
}
}
@EventHandler
public void korewoomoitegahoshiiinai(PlayerCommandPreprocessEvent e) {
if (!catgirls.contains(e.getPlayer())) return;
if ((!e.getMessage().startsWith("/login") && !e.getMessage().startsWith("/log")
&& !e.getMessage().startsWith("/register") && !e.getMessage().startsWith("/reg")) || e.getMessage().startsWith("/logout")) {
e.getPlayer().sendMessage(Neko.cmdpromptbadcmd);
e.setCancelled(true);
}
}
}

View file

@ -0,0 +1,130 @@
package me.yuri.authcat;
import me.yuri.yuriapi.api.command.CommandManager;
import me.yuri.yuriapi.api.utils.configuration.ConfigVar;
import me.yuri.yuriapi.api.utils.configuration.ConfigVarExceptionListener;
import me.yuri.yuriapi.api.utils.configuration.ConfigVarManager;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Base64;
import java.util.Properties;
public class Neko extends JavaPlugin {
@ConfigVar("reset-on-reload")
protected static boolean resetonreload = false;
@ConfigVar("disallow-speech")
protected static boolean disallowspeech = false;
@ConfigVar("kick-timeout")
protected static int timeout = -1;
@ConfigVar(value = "kick-timeout-message", color = '&')
protected static String timeoutmsg = "null";
@ConfigVar(value = "prompt-message-login", color = '&')
protected static String promptlog = "null";
@ConfigVar(value = "prompt-message-register", color = '&')
protected static String promptreg = "null";
@ConfigVar("prompt-initial-delay")
protected static int prmdelay = 4;
@ConfigVar("prompt-repeat-delay")
protected static int prmrepeat = 5;
@ConfigVar(value = "cmd-prompt-badcommand", color = '&')
protected static String cmdpromptbadcmd = "null";
protected static Neko getCatEars() {
return animeGrill;
}
private static final Otokonomusume otoko = new Otokonomusume();
private static Neko animeGrill;
@ConfigVarExceptionListener
public void onCfgException(me.yuri.yuriapi.api.utils.configuration.ConfigVarException e){
e.printStackTrace();
saveDefaultConfig();
}
@Override
public void onLoad() {
animeGrill = this;
saveDefaultConfig();
ConfigVarManager.register(this, this, otoko);
ConfigVarManager.update(this);
}
@Override
public void onDisable() {
super.onDisable();
}
@Override
public void onEnable() {
CommandManager c = new CommandManager(this);
c.registerCommand(otoko);
this.getServer().getPluginManager().registerEvents(new CatGirls(), this);
log("§aA§bu§ct§dh§ee§fn§1t§2i§3C§4a§5t §aenabled!");
if(resetonreload){
Bukkit.getOnlinePlayers().forEach(p -> {
CatGirls.catgirls.add(p);
CatGirls.brian(p);
});
}
}
private static void log(String... msg) {
Bukkit.getConsoleSender().sendMessage(msg);
}
public void dontspawnkill(String user, String pass){
Properties p = new Properties();
File file = new File(this.getDataFolder().getAbsolutePath() + "/passes.properties");
try {
if(file.exists()) {
FileInputStream fis = new FileInputStream(file);
p.load(fis);
fis.close();
}
//Don't do this unless you are NSA :3
pass = Base64.getEncoder().encodeToString(pass.getBytes());
p.setProperty(user, pass);
FileOutputStream fos = new FileOutputStream(file);
p.store(fos, "KEKS");
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public String oof(String user) {
String pass = null;
Properties p = new Properties();
File file = new File(this.getDataFolder().getAbsolutePath() + "/passes.properties");
if(!file.exists()) return null;
try {
FileInputStream fis = new FileInputStream(file);
p.load(fis);
fis.close();
String tmp = p.getProperty(user);
if(tmp == null) return null;
pass = new String(Base64.getDecoder().decode(tmp));
} catch (IOException ignored) {
}
return pass;
}
}

View file

@ -0,0 +1,192 @@
package me.yuri.authcat;
import me.yuri.yuriapi.api.command.Cmd;
import me.yuri.yuriapi.api.command.CommandEvent;
import me.yuri.yuriapi.api.utils.configuration.ConfigVar;
import org.bukkit.entity.Player;
public class Otokonomusume {
//FAILS
@ConfigVar(value = "cmd-fail-register-first", color = '&')
private static String cmdregfirst = "null";
@ConfigVar(value = "cmd-fail-already-authenticated", color = '&')
private static String cmdalreadyauth = "null";
@ConfigVar(value = "cmd-fail-nopassword", color = '&')
private static String cmdnopass = "null";
@ConfigVar(value = "cmd-fail-badpassword", color = '&')
private static String cmdbadpass= "null";
@ConfigVar(value = "cmd-fail-nopassword-overargs", color = '&')
private static String cmdnopass1 = "null";
@ConfigVar(value = "cmd-fail-just-login", color = '&')
private static String cmdloginprompt = "null";
@ConfigVar(value = "cmd-fail-noargsallowed", color = '&')
private static String cmdnoargsallowed = "null";
@ConfigVar(value = "cmd-fail-nobothpasswords", color = '&')
private static String cmdnoboth = "null";
@ConfigVar(value = "cmd-fail-nonewpassword", color = '&')
private static String cmdnonew = "null";
@ConfigVar(value = "cmd-fail-passwords-mismatch", color = '&')
private static String cmdnomatch = "null";
@ConfigVar(value = "cmd-fail-general-overargs", color = '&')
private static String cmdtoomanyargs = "null";
@ConfigVar(value = "cmd-fail-nopassset", color = '&')
private static String cmdnopasset = "null";
//SUCCESSES
@ConfigVar(value = "cmd-success-register", color = '&')
private static String cmdfirstreg = "null";
@ConfigVar(value = "cmd-success-login", color = '&')
private static String cmdloggedin = "null";
@ConfigVar(value = "cmd-success-logout", color = '&')
private static String cmdloggedout = "null";
@ConfigVar(value = "cmd-success-changepass", color = '&')
private static String cmdchangedpass = "null";
@Cmd(command = "login", aliases = {"log"}, consoleSide = false)
public void rogin(CommandEvent c){
Player s = (Player) c.getSender();
String pass = Neko.getCatEars().oof(s.getName());
if(!CatGirls.catgirls.contains(s)){
s.sendMessage(cmdalreadyauth);
return;
}
if(pass == null){
s.sendMessage(cmdregfirst);
return;
}
if(c.getArgs().length == 0){
s.sendMessage(cmdnopass);
return;
}
if(c.getArgs().length > 1){
s.sendMessage(cmdnopass1);
return;
}
if(pass.equals(c.getArgsString())){
CatGirls.catgirls.remove(s);
s.sendMessage(cmdloggedin);
} else {
s.sendMessage(cmdbadpass);
}
}
@Cmd(command = "register", aliases = {"reg"}, consoleSide = false)
public void hajimemashite(CommandEvent c){
Player s = (Player) c.getSender();
String pass = Neko.getCatEars().oof(s.getName());
if(!CatGirls.catgirls.contains(s)){
s.sendMessage(cmdalreadyauth);
return;
}
if(pass != null){
s.sendMessage(cmdloginprompt);
return;
}
if(c.getArgs().length == 0){
s.sendMessage(cmdnopass);
return;
}
if(c.getArgs().length > 1){
s.sendMessage(cmdnopass1);
return;
}
pass = c.getArgsString();
Neko.getCatEars().dontspawnkill(s.getName(), pass);
s.sendMessage(cmdfirstreg);
CatGirls.catgirls.remove(s);
}
@Cmd(command = "logout", consoleSide = false)
public void iiteyone(CommandEvent c){
Player s = (Player) c.getSender();
if(c.getArgs().length != 0){
s.sendMessage(cmdnoargsallowed);
return;
}
s.sendMessage(cmdloggedout);
deanimenize(s);
}
private void deanimenize(Player p){
CatGirls.catgirls.add(p);
CatGirls.brian(p);
}
@Cmd(command = "changepassword", aliases = {"changepass"}, consoleSide = false)
public void aaaaaaaaaaaaaaaaaaaaaa(CommandEvent c){
Player s = (Player) c.getSender();
String playerpass = Neko.getCatEars().oof(s.getName());
if(playerpass == null){
s.sendMessage(cmdnopasset);
deanimenize(s);
return;
}
switch (c.getArgs().length){
case 0:
s.sendMessage(cmdnopass);
return;
case 1:
s.sendMessage(cmdnonew);
return;
case 2:
String oldpass, newpass;
oldpass = c.getArgs()[0];
newpass = c.getArgs()[1];
if(!oldpass.equals(playerpass)){
s.sendMessage(cmdnomatch);
return;
}
Neko.getCatEars().dontspawnkill(s.getName(), newpass);
s.sendMessage(cmdchangedpass);
return;
default:
s.sendMessage(cmdtoomanyargs);
return;
}
}
}

18
AuthentiCat/src/plugin.yml Executable file
View file

@ -0,0 +1,18 @@
name: AuthentiCat
author: Yuri (Blin)
version: 1.0E
main: me.yuri.authcat.Neko
load: STARTUP
depend:
- YuriAPI
description: A decent auth plugin with terrible variable naming...
commands:
login:
aliases: log
register:
aliases: reg
# authmanager:
# aliases: am
logout:
changepassword:
aliases: changepass