Created
October 24, 2015 15:23
-
-
Save connorlurring/9a8b978a0867348c6f5f to your computer and use it in GitHub Desktop.
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
// | |
// Decompiled by Procyon v0.5.29 | |
// | |
package me.InfernoSpirit.LoginVerification; | |
import org.bukkit.command.Command; | |
import org.bukkit.command.CommandSender; | |
import org.bukkit.potion.PotionEffect; | |
import org.bukkit.potion.PotionEffectType; | |
import org.bukkit.Sound; | |
import java.util.Iterator; | |
import org.bukkit.plugin.PluginManager; | |
import org.bukkit.Bukkit; | |
import org.bukkit.plugin.Plugin; | |
import org.bukkit.entity.Player; | |
import java.util.ArrayList; | |
import org.bukkit.event.Listener; | |
import org.bukkit.plugin.java.JavaPlugin; | |
public class LoginMain extends JavaPlugin implements Listener | |
{ | |
public ArrayList<String> users; | |
public String pre; | |
public LoginMain() { | |
this.users = new ArrayList<String>(); | |
this.pre = "§8[§6Login Verification§8] §3"; | |
} | |
public void noPerm(final Player p) { | |
p.sendMessage(String.valueOf(this.pre) + "§cYou do not have permission to use this."); | |
} | |
public void onEnable() { | |
this.getLogger().info("<!> Login Verification has been enabled!"); | |
final PluginManager pm = this.getServer().getPluginManager(); | |
pm.registerEvents((Listener)this, (Plugin)this); | |
pm.registerEvents((Listener)new LoginListener(this), (Plugin)this); | |
this.saveConfig(); | |
this.users.clear(); | |
for (final Player p : Bukkit.getOnlinePlayers()) { | |
this.RequestLogin(p); | |
} | |
} | |
public void RequestLogin(final Player p) { | |
if (p.hasPermission("LoginVerification.Bypass")) { | |
p.playSound(p.getLocation(), Sound.LEVEL_UP, 5.0f, 5.0f); | |
p.sendMessage(String.valueOf(this.pre) + "§eYou don't require verification! You're all good."); | |
this.users.add(p.getName()); | |
return; | |
} | |
if (this.getConfig().get("Password." + p.getName()) == null || this.getConfig().get("Username." + p.getName()) == null) { | |
p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 999999999, 1)); | |
p.playSound(p.getLocation(), Sound.NOTE_PLING, 5.0f, 5.0f); | |
p.sendMessage(String.valueOf(this.pre) + "§cYou don't have an account, please create one."); | |
p.sendMessage(String.valueOf(this.pre) + "Please input: '/register <username> <password>'"); | |
return; | |
} | |
p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 999999999, 1)); | |
p.playSound(p.getLocation(), Sound.NOTE_PLING, 5.0f, 5.0f); | |
p.sendMessage(String.valueOf(this.pre) + "§aWelcome back, please login to your account."); | |
p.sendMessage(String.valueOf(this.pre) + "Please input: '/login <username> <password>'"); | |
} | |
public void onDisable() { | |
this.getLogger().info("<!> Login Verification has been disabled!"); | |
this.users.clear(); | |
this.saveConfig(); | |
} | |
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) { | |
final Player player = (Player)sender; | |
if (cmd.getName().equalsIgnoreCase("register")) { | |
if (!(sender instanceof Player)) { | |
return true; | |
} | |
final String u = this.getConfig().getString("Username." + player.getName()); | |
if (!this.users.contains(player.getName()) && u != null && !u.equalsIgnoreCase("")) { | |
player.playSound(player.getLocation(), Sound.NOTE_PLING, 5.0f, 5.0f); | |
player.sendMessage(String.valueOf(this.pre) + "§cYou need to be logged in to register a new account!"); | |
return true; | |
} | |
if (args.length == 0 || args.length == 1) { | |
player.playSound(player.getLocation(), Sound.NOTE_PLING, 5.0f, 5.0f); | |
player.sendMessage(String.valueOf(this.pre) + "§cIncorrect usage, to register an account:"); | |
player.sendMessage(String.valueOf(this.pre) + "Please input: '/register <username> <password>'"); | |
return true; | |
} | |
if (args[0].equalsIgnoreCase(null) && args[1].equalsIgnoreCase(null)) { | |
player.playSound(player.getLocation(), Sound.NOTE_PLING, 5.0f, 5.0f); | |
player.sendMessage(String.valueOf(this.pre) + "§cIncorrect usage, to register an account:"); | |
player.sendMessage(String.valueOf(this.pre) + "Please input: '/register <username> <password>'"); | |
return true; | |
} | |
final String username = args[0]; | |
final String password = args[1]; | |
if (this.users.contains(player.getName())) { | |
player.sendMessage(String.valueOf(this.pre) + "§5You replaced your old account with this new one!"); | |
} | |
player.removePotionEffect(PotionEffectType.BLINDNESS); | |
player.playSound(player.getLocation(), Sound.LEVEL_UP, 5.0f, 5.0f); | |
player.sendMessage(String.valueOf(this.pre) + "§aYou made a new account with the username of " + username); | |
this.getConfig().set("Username." + player.getName(), (Object)username); | |
this.getConfig().set("Password." + player.getName(), (Object)password); | |
this.saveConfig(); | |
this.users.remove(player.getName()); | |
this.RequestLogin(player); | |
return true; | |
} | |
else { | |
if (!cmd.getName().equalsIgnoreCase("login")) { | |
return true; | |
} | |
if (!(sender instanceof Player)) { | |
return true; | |
} | |
if (this.users.contains(player.getName())) { | |
player.playSound(player.getLocation(), Sound.NOTE_PLING, 5.0f, 5.0f); | |
player.sendMessage(String.valueOf(this.pre) + "§cYou are already logged in!"); | |
return true; | |
} | |
if (args.length == 0 || args.length == 1) { | |
player.playSound(player.getLocation(), Sound.NOTE_PLING, 5.0f, 5.0f); | |
player.sendMessage(String.valueOf(this.pre) + "§cIncorrect login details, please try again!"); | |
player.sendMessage(String.valueOf(this.pre) + "Please input: '/login <username> <password>'"); | |
return true; | |
} | |
final String username2 = this.getConfig().getString("Username." + player.getName()); | |
final String password2 = this.getConfig().getString("Password." + player.getName()); | |
if (args[0].equalsIgnoreCase(username2) && args[1].equalsIgnoreCase(password2)) { | |
player.removePotionEffect(PotionEffectType.BLINDNESS); | |
player.playSound(player.getLocation(), Sound.LEVEL_UP, 5.0f, 5.0f); | |
player.sendMessage(String.valueOf(this.pre) + "§aWelcome back " + username2 + ", have fun!"); | |
this.users.add(player.getName()); | |
return true; | |
} | |
player.playSound(player.getLocation(), Sound.NOTE_PLING, 5.0f, 5.0f); | |
player.sendMessage(String.valueOf(this.pre) + "§cIncorrect login details, please try again!"); | |
player.sendMessage(String.valueOf(this.pre) + "Please input: '/login <username> <password>'"); | |
return true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment