/*
 * Decompiled with CFR 0.150.
 * 
 * Could not load the following classes:
 *  me.jet315.prisonmines.JetsPrisonMines
 *  me.jet315.prisonmines.JetsPrisonMinesAPI
 *  me.lucko.helper.Commands
 *  me.lucko.helper.Events
 *  me.lucko.helper.plugin.ExtendedJavaPlugin
 *  me.lucko.helper.terminable.TerminableConsumer
 *  me.lucko.helper.text.Text
 *  net.milkbowl.vault.economy.Economy
 *  org.bukkit.Bukkit
 *  org.bukkit.Material
 *  org.bukkit.OfflinePlayer
 *  org.bukkit.entity.Player
 *  org.bukkit.event.EventPriority
 *  org.bukkit.event.player.PlayerJoinEvent
 *  org.bukkit.inventory.ItemStack
 *  org.bukkit.plugin.Plugin
 *  org.bukkit.plugin.RegisteredServiceProvider
 *  org.bukkit.plugin.java.JavaPlugin
 */
package me.drawethree.ultraprisoncore;

import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.stream.Collectors;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESedeKeySpec;
import me.drawethree.ultraprisoncore.UltraPrisonModule;
import me.drawethree.ultraprisoncore.autominer.UltraPrisonAutoMiner;
import me.drawethree.ultraprisoncore.autosell.UltraPrisonAutoSell;
import me.drawethree.ultraprisoncore.config.FileManager;
import me.drawethree.ultraprisoncore.database.Database;
import me.drawethree.ultraprisoncore.database.DatabaseCredentials;
import me.drawethree.ultraprisoncore.database.SQLDatabase;
import me.drawethree.ultraprisoncore.database.implementations.MySQLDatabase;
import me.drawethree.ultraprisoncore.database.implementations.SQLiteDatabase;
import me.drawethree.ultraprisoncore.enchants.UltraPrisonEnchants;
import me.drawethree.ultraprisoncore.gangs.UltraPrisonGangs;
import me.drawethree.ultraprisoncore.gems.UltraPrisonGems;
import me.drawethree.ultraprisoncore.history.UltraPrisonHistory;
import me.drawethree.ultraprisoncore.mainmenu.MainMenu;
import me.drawethree.ultraprisoncore.mainmenu.help.HelpGui;
import me.drawethree.ultraprisoncore.metrics.bukkit.Metrics;
import me.drawethree.ultraprisoncore.mines.UltraPrisonMines;
import me.drawethree.ultraprisoncore.multipliers.UltraPrisonMultipliers;
import me.drawethree.ultraprisoncore.nms.NMSProvider;
import me.drawethree.ultraprisoncore.pickaxelevels.UltraPrisonPickaxeLevels;
import me.drawethree.ultraprisoncore.placeholders.UltraPrisonMVdWPlaceholder;
import me.drawethree.ultraprisoncore.placeholders.UltraPrisonPAPIPlaceholder;
import me.drawethree.ultraprisoncore.prestiges.UltraPrisonPrestiges;
import me.drawethree.ultraprisoncore.ranks.UltraPrisonRanks;
import me.drawethree.ultraprisoncore.tokens.UltraPrisonTokens;
import me.drawethree.ultraprisoncore.utils.SkullUtils;
import me.drawethree.ultraprisoncore.utils.compat.CompMaterial;
import me.jet315.prisonmines.JetsPrisonMines;
import me.jet315.prisonmines.JetsPrisonMinesAPI;
import me.lucko.helper.Commands;
import me.lucko.helper.Events;
import me.lucko.helper.plugin.ExtendedJavaPlugin;
import me.lucko.helper.terminable.TerminableConsumer;
import me.lucko.helper.text.Text;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;

public final class UltraPrisonCore
extends ExtendedJavaPlugin {
    private static final int METRICS_SERVICE_ID = 10520;
    private boolean debugMode;
    private LinkedHashMap<String, UltraPrisonModule> modules;
    private static UltraPrisonCore instance;
    private Database pluginDatabase;
    private Economy economy;
    private FileManager fileManager;
    private UltraPrisonTokens tokens;
    private UltraPrisonGems gems;
    private UltraPrisonRanks ranks;
    private UltraPrisonPrestiges prestiges;
    private UltraPrisonMultipliers multipliers;
    private UltraPrisonEnchants enchants;
    private UltraPrisonAutoSell autoSell;
    private UltraPrisonAutoMiner autoMiner;
    private UltraPrisonPickaxeLevels pickaxeLevels;
    private UltraPrisonGangs gangs;
    private UltraPrisonMines mines;
    private UltraPrisonHistory history;
    private NMSProvider nmsProvider;
    private List<Material> supportedPickaxes;
    private JetsPrisonMinesAPI jetsPrisonMinesAPI;
    private boolean ultraBackpacksEnabled;
    public static final String[] __pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a;

    protected void enable() {
        instance = this;
        this.modules = new LinkedHashMap();
        this.fileManager = new FileManager((JavaPlugin)this);
        this.fileManager.getConfig(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[0]).copyDefaults(true).save();
        this.debugMode = this.getConfig().getBoolean(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[1], false);
        if (!this.loadNMSProvider()) {
            this.getServer().getPluginManager().disablePlugin((Plugin)this);
            return;
        }
        if (!this.initDatabase()) {
            return;
        }
        if (!this.setupEconomy()) {
            this.getLogger().warning(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[2]);
            this.getServer().getPluginManager().disablePlugin((Plugin)this);
            return;
        }
        this.getLogger().info(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[3] + this.getEconomy().getName());
        this.initModules();
        this.pluginDatabase.createTables();
        this.pluginDatabase.createIndexes();
        this.loadModules();
        this.initVariables();
        this.registerPlaceholders();
        this.registerJetsPrisonMines();
        this.registerMainEvents();
        this.registerMainCommand();
        this.startMetrics();
        SkullUtils.init();
    }

    private void initVariables() {
        this.supportedPickaxes = this.getConfig().getStringList(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[4]).stream().map(CompMaterial::fromString).map(CompMaterial::getMaterial).collect(Collectors.toList());
        for (Material material : this.supportedPickaxes) {
            this.getLogger().info(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[5] + (Object)material);
        }
        this.ultraBackpacksEnabled = this.getServer().getPluginManager().isPluginEnabled(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[6]);
    }

    private void loadModules() {
        if (this.getConfig().getBoolean(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[7])) {
            this.loadModule(this.tokens);
        }
        if (this.getConfig().getBoolean(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[8])) {
            this.loadModule(this.gems);
        }
        if (this.getConfig().getBoolean(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[9])) {
            this.loadModule(this.ranks);
        }
        if (this.getConfig().getBoolean(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[10])) {
            this.loadModule(this.prestiges);
        }
        if (this.getConfig().getBoolean(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[11])) {
            this.loadModule(this.multipliers);
        }
        if (this.getConfig().getBoolean(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[12])) {
            if (this.ultraBackpacksEnabled) {
                this.getLogger().info(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[13]);
            } else {
                this.loadModule(this.autoSell);
            }
        }
        if (this.getConfig().getBoolean(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[14])) {
            this.loadModule(this.mines);
        }
        if (this.getConfig().getBoolean(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[15])) {
            this.loadModule(this.enchants);
        }
        if (this.getConfig().getBoolean(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[16])) {
            this.loadModule(this.autoMiner);
        }
        if (this.getConfig().getBoolean(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[17])) {
            this.loadModule(this.gangs);
        }
        if (this.getConfig().getBoolean(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[18])) {
            if (!this.isModuleEnabled(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[19])) {
                this.getLogger().warning(Text.colorize((String)__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[20]));
            } else {
                this.loadModule(this.pickaxeLevels);
            }
        }
        if (this.getConfig().getBoolean(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[21])) {
            this.loadModule(this.history);
        }
    }

    private boolean initDatabase() {
        block4: {
            try {
                String string = this.getConfig().getString(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[22]);
                if (string.equalsIgnoreCase(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[23])) {
                    this.pluginDatabase = new SQLiteDatabase(this);
                    break block4;
                }
                if (string.equalsIgnoreCase(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[24])) {
                    this.pluginDatabase = new MySQLDatabase(this, DatabaseCredentials.fromConfig(this.getConfig()));
                    break block4;
                }
                this.getLogger().warning(String.format(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[25], string));
                this.getServer().getPluginManager().disablePlugin((Plugin)this);
                return false;
            }
            catch (Exception exception) {
                this.getLogger().warning(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[26]);
                exception.printStackTrace();
                this.getServer().getPluginManager().disablePlugin((Plugin)this);
                return false;
            }
        }
        return true;
    }

    private void initModules() {
        this.tokens = new UltraPrisonTokens(this);
        this.gems = new UltraPrisonGems(this);
        this.ranks = new UltraPrisonRanks(this);
        this.prestiges = new UltraPrisonPrestiges(this);
        this.multipliers = new UltraPrisonMultipliers(this);
        this.enchants = new UltraPrisonEnchants(this);
        this.autoSell = new UltraPrisonAutoSell(this);
        this.autoMiner = new UltraPrisonAutoMiner(this);
        this.pickaxeLevels = new UltraPrisonPickaxeLevels(this);
        this.gangs = new UltraPrisonGangs(this);
        this.mines = new UltraPrisonMines(this);
        this.history = new UltraPrisonHistory(this);
        this.modules.put(this.tokens.getName().toLowerCase(), this.tokens);
        this.modules.put(this.gems.getName().toLowerCase(), this.gems);
        this.modules.put(this.ranks.getName().toLowerCase(), this.ranks);
        this.modules.put(this.prestiges.getName().toLowerCase(), this.prestiges);
        this.modules.put(this.multipliers.getName().toLowerCase(), this.multipliers);
        this.modules.put(this.enchants.getName().toLowerCase(), this.enchants);
        this.modules.put(this.autoSell.getName().toLowerCase(), this.autoSell);
        this.modules.put(this.autoMiner.getName().toLowerCase(), this.autoMiner);
        this.modules.put(this.pickaxeLevels.getName().toLowerCase(), this.pickaxeLevels);
        this.modules.put(this.gangs.getName().toLowerCase(), this.gangs);
        this.modules.put(this.mines.getName().toLowerCase(), this.mines);
        this.modules.put(this.history.getName().toLowerCase(), this.history);
    }

    private void registerMainEvents() {
        Events.subscribe(PlayerJoinEvent.class, (EventPriority)EventPriority.LOW).handler(playerJoinEvent -> this.pluginDatabase.updatePlayerNickname((OfflinePlayer)playerJoinEvent.getPlayer())).bindWith((TerminableConsumer)this);
    }

    private void startMetrics() {
        new Metrics((JavaPlugin)this, 10520);
    }

    private void loadModule(UltraPrisonModule ultraPrisonModule) {
        if (ultraPrisonModule.isEnabled()) {
            return;
        }
        ultraPrisonModule.enable();
        this.getLogger().info(Text.colorize((String)String.format(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[27], ultraPrisonModule.getName())));
    }

    private void unloadModule(UltraPrisonModule ultraPrisonModule) {
        if (!ultraPrisonModule.isEnabled()) {
            return;
        }
        ultraPrisonModule.disable();
        this.getLogger().info(Text.colorize((String)String.format(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[28], ultraPrisonModule.getName())));
    }

    public void debug(String string, UltraPrisonModule ultraPrisonModule) {
        if (!this.debugMode) {
            return;
        }
        if (ultraPrisonModule != null) {
            this.getLogger().info(String.format(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[29], ultraPrisonModule.getName(), Text.colorize((String)string)));
        } else {
            this.getLogger().info(Text.colorize((String)string));
        }
    }

    public void reloadModule(UltraPrisonModule ultraPrisonModule) {
        if (!ultraPrisonModule.isEnabled()) {
            return;
        }
        ultraPrisonModule.reload();
        this.getLogger().info(Text.colorize((String)String.format(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[30], ultraPrisonModule.getName())));
    }

    private void registerMainCommand() {
        List list = this.getConfig().getStringList(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[31]);
        String[] arrstring = list.toArray(new String[list.size()]);
        Commands.create().assertPermission(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[32]).assertPlayer().handler(commandContext -> {
            if (commandContext.args().size() == 0) {
                new MainMenu(this, (Player)commandContext.sender()).open();
            } else if (commandContext.args().size() == 1 && __pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[40].equalsIgnoreCase(commandContext.rawArg(0)) || __pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[41].equalsIgnoreCase(commandContext.rawArg(0))) {
                new HelpGui((Player)commandContext.sender()).open();
            }
        }).registerAndBind((TerminableConsumer)this, arrstring);
    }

    protected void disable() {
        Iterator<UltraPrisonModule> iterator = this.modules.values().iterator();
        while (iterator.hasNext()) {
            this.unloadModule(iterator.next());
            iterator.remove();
        }
        if (this.pluginDatabase != null && this.pluginDatabase instanceof SQLDatabase) {
            SQLDatabase sQLDatabase = (SQLDatabase)this.pluginDatabase;
            sQLDatabase.close();
        }
    }

    public boolean isModuleEnabled(String string) {
        UltraPrisonModule ultraPrisonModule = this.modules.get(string.toLowerCase());
        return ultraPrisonModule != null && ultraPrisonModule.isEnabled();
    }

    private void registerPlaceholders() {
        if (Bukkit.getPluginManager().getPlugin(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[33]) != null) {
            new UltraPrisonPAPIPlaceholder(this).register();
        }
        new UltraPrisonMVdWPlaceholder(this);
    }

    private void registerJetsPrisonMines() {
        if (Bukkit.getPluginManager().getPlugin(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[34]) != null) {
            this.jetsPrisonMinesAPI = ((JetsPrisonMines)this.getServer().getPluginManager().getPlugin(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[34])).getAPI();
        }
    }

    private boolean setupEconomy() {
        if (this.getServer().getPluginManager().getPlugin(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[35]) == null) {
            return false;
        }
        RegisteredServiceProvider registeredServiceProvider = this.getServer().getServicesManager().getRegistration(Economy.class);
        if (registeredServiceProvider == null) {
            return false;
        }
        this.economy = (Economy)registeredServiceProvider.getProvider();
        return this.economy != null;
    }

    public boolean isPickaxeSupported(Material material) {
        return this.supportedPickaxes.contains((Object)material);
    }

    public boolean isPickaxeSupported(ItemStack itemStack) {
        if (itemStack == null) {
            return false;
        }
        return this.isPickaxeSupported(itemStack.getType());
    }

    private boolean loadNMSProvider() {
        try {
            String string = NMSProvider.class.getPackage().getName();
            String string2 = Bukkit.getServer().getClass().getPackage().getName().split(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[36])[3];
            this.nmsProvider = (NMSProvider)Class.forName(string + __pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[37] + string2).newInstance();
            this.getLogger().info(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[38] + string2);
            return true;
        }
        catch (ClassCastException | ClassNotFoundException | IllegalAccessException | InstantiationException exception) {
            this.getLogger().warning(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[39]);
            return false;
        }
    }

    public Collection<UltraPrisonModule> getModules() {
        return this.modules.values();
    }

    public boolean isDebugMode() {
        return this.debugMode;
    }

    public void setDebugMode(boolean bl) {
        this.debugMode = bl;
        this.getConfig().set(__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a[1], (Object)this.debugMode);
        this.saveConfig();
    }

    public Database getPluginDatabase() {
        return this.pluginDatabase;
    }

    public Economy getEconomy() {
        return this.economy;
    }

    public FileManager getFileManager() {
        return this.fileManager;
    }

    public UltraPrisonTokens getTokens() {
        return this.tokens;
    }

    public UltraPrisonGems getGems() {
        return this.gems;
    }

    public UltraPrisonRanks getRanks() {
        return this.ranks;
    }

    public UltraPrisonPrestiges getPrestiges() {
        return this.prestiges;
    }

    public UltraPrisonMultipliers getMultipliers() {
        return this.multipliers;
    }

    public UltraPrisonEnchants getEnchants() {
        return this.enchants;
    }

    public UltraPrisonAutoSell getAutoSell() {
        return this.autoSell;
    }

    public UltraPrisonAutoMiner getAutoMiner() {
        return this.autoMiner;
    }

    public UltraPrisonPickaxeLevels getPickaxeLevels() {
        return this.pickaxeLevels;
    }

    public UltraPrisonGangs getGangs() {
        return this.gangs;
    }

    public UltraPrisonMines getMines() {
        return this.mines;
    }

    public UltraPrisonHistory getHistory() {
        return this.history;
    }

    public NMSProvider getNmsProvider() {
        return this.nmsProvider;
    }

    public List<Material> getSupportedPickaxes() {
        return this.supportedPickaxes;
    }

    public JetsPrisonMinesAPI getJetsPrisonMinesAPI() {
        return this.jetsPrisonMinesAPI;
    }

    public static UltraPrisonCore getInstance() {
        return instance;
    }

    public boolean isUltraBackpacksEnabled() {
        return this.ultraBackpacksEnabled;
    }

    static {
        __pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_a = UltraPrisonCore.__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_d(new String[]{"/ms1.\u00c7g5\u0002\u00b6\u00a9\u0002\u00ee%\u0095I", "7\u00eb\u00f3\u00c0\u00c2C\u0082\u00ad7\u0007\u009e\u00afa\u0095\nG", "\u00fa(j\u0001+}\u0019^_+\u008dx4\u0016\u00e9-\u00d4F\u0082\nsX7P*\u00d1\u00e4j2\u0019\u008f\u00e9D\u000e\u00e2G\u0004\u0001c]\u001b\u00a0D*\u0016`\u009e\u00f2\u00dd\u00a6YO\u0018\u0081y\u00a4 [\u00ae\nZ-\u00c8\u0093k?\u00cf\u0005\u00dd\u00b989\u00afK\u00c9b\u00fe\u00bf&!veb\u001f}~N\u00d4\u00e3\u00e6\u00b8\u00f2G\u00dd\u008b\u00c4W \u0001\u009a\u00b7\u00f1\u00b6\u0095", "\u00fa(j\u0001+}\u0019^_+\u008dx4\u0016\u00e9-\u00d4F\u0082\nsX7P\u00f3\u00b1\u00f2\u00d69A\u008fY\u00ca\u00c3B\u00e1\u008b_S\u00bb", "\u00b5\u00849\f\u0090\u00dd\u0007'\u00bc\u00b8Z\u00ea\u008fy\u00d6\u00ce\u00c9\u00c5U\u0092\u0002\u00e0\u00d5\u00c5", "\u00181n\u0094_'5\u00bf\u00c6\u00ee\u001b\u00eeWQe\u00f0\u00ea\u001e\u00a0B\u00e2\u00c4\u00bd4", "4\u00ab4\u009b*\u009d\u00a6\u008ew\u00b9\u0091\u00ae\u008fF\u00cf\u0094", "\u00ff\u00c5\u001e\u0095\u00f2\u00b6$?\u00ce\u0013O\u00fe$\u00ec\u0003M", "\u00ff\u00c5\u001e\u0095\u00f2\u00b6$?G\f\u0013\u0017@f*\u00c1", "\u00ff\u00c5\u001e\u0095\u00f2\u00b6$?\u00911\u00f2<\u00cb\t\u00bf\u00a0", "\u00ff\u00c5\u001e\u0095\u00f2\u00b6$?\t\u00d2\u00b5r\u00fa\u0086\u00de\u00af{.\u00e1V\u0089\u00c4\u00cf\u0014", "\u00ff\u00c5\u001e\u0095\u00f2\u00b6$?T\"Z\u0095\u00cf]@\u009e\u00f3# {\u00d97\u00be.", "\u00ff\u00c5\u001e\u0095\u00f2\u00b6$?\u00a5\u00bd\u0095\u001e\u00cas\u008f\u0006W \u0001\u009a\u00b7\u00f1\u00b6\u0095", "x\u00aa\u00b9\n\u00f9\u00f1\u00f5@\u00df\u00c9\u00e8@bC\u00afz'\u00fa\u00fa\u00b9\u001f\u00c5P\u001d.\nK\u00cd.>\u00a2uM\u00a6\u00953*Zm\u0000\u00f4X`\u0094`\u00dd\u00c3s\u00db\u00ac\u00d1\u00a9[d\u00fd>f\u00ff;\u001a\u009d)\u001c\u0090e-\u00ba\u0012Z\u00df\u009a\u00bd4\u00ab4\u009b*\u009d\u00a6\u008e\u0016\u00bcG\u00ba\u00aaA\u00d7\u001c", "\u00ff\u00c5\u001e\u0095\u00f2\u00b6$?@Z\u00aeSc7\u0080K", "\u00ff\u00c5\u001e\u0095\u00f2\u00b6$?_2\u008f\u0014\u00f8\u00e5\u00bcEW \u0001\u009a\u00b7\u00f1\u00b6\u0095", "\u00ff\u00c5\u001e\u0095\u00f2\u00b6$?\u00c7\u008a\u00c9\u0097\u00e7\u00b7\u0005\u00b9]\u0090w\u0080\u008fK\u00a94", "\u00ff\u00c5\u001e\u0095\u00f2\u00b6$?\u00c4\u00c1\u0013*H!\u00d8V", "\u00ff\u00c5\u001e\u0095\u00f2\u00b6$?\u00d9\u00a4y\u00e7\u0098<I\u0087=\u00fd\u0007D\u000f,Ye", "\u00ddW\u008f\u00cb#\u00c4t\u00aeW \u0001\u009a\u00b7\u00f1\u00b6\u0095", "\u00fd\u00878!\u000equ\u0084\u00a3\u0001\u00a6IYg\u008a\u0091\u00dc%\u00f9/s\u00f1\u0086k\u008f\u0001`\u00fe\u00cb&\u0017\u00e3\u00a5\u00ea\u00a0\u0005\u00d0\u00f3eF\u00fd7\u0014\u00d12\u0093\u0010A'f\u00cc \u0010\u00e0r\u00b3\u00e8&d,\u0013\u00c8\r\u0089\u00abu\u00f0 \u00a8\u00a6\u00dbY\u00dcy\u00f3\u0080]`64\fm\u0011n\u00f6w\u00a6\b", "\u00ff\u00c5\u001e\u0095\u00f2\u00b6$?\u0000\u00f7m\u0010&\u009bGY", "\u0004\u00ee%\\\u00ac\u00bdx#i_n\u00d7R\u00c7\u0086\u00e1", "\u0014\u00bc\u00be{V\u00c2\u00dc-", "\u009c\u00e0\u0082^]\"_\u00a1", "\u00a8L\u00e8\u00fe\u008b\u0081\u00f2,\u00d5\u00d9\u00fdEs\u0080\u00bc\u00d8\u0014\u0017\u008f\u00ad\u00c43\u00aa=\u00aaI\u0081J\u00a2\u00ab\u0090\u00db\u0016\u0088-\u008e\u0082\u000bj\u0087\u00e39\u00b6\u00c0 \u00f5\u00fa\u0081\u00f8\u00e3\u00c8\u00e2@\f\u00c8h", "\u00fd)P\u00fb.X#\u009a\u00e0JL\u0092\u00b5\u0093\u0084Ls\u0004f^W\u00ca\u0093k\u0016,\u008e\u00baH\nf\u0086\u00b8\u00ca/e\u00bf\u0095\u00c7\u009f<\u00f4d\u00d7\u00a6](\\\u0016\u00d2m\u0081\u00df{D\u00b0\u0087%\u00eb\u009e\u0013\u00a7k?", "\u00fd\u00878!\u000equ\u0084\u00a3\u0001\u00a6IYg\u008a\u0091\u00dc%\u00f9/s\u00f1\u0086k}\u00bf\u00aa\u0089\u00ceX_\u008b\fm\u0011n\u00f6w\u00a6\b", "\u00fd\u00878!\u000equ\u0084\u00a3\u0001\u00a6IYg\u008a\u0091\u00dc%\u00f9/s\u00f1\u0086k\u0087t\u00145\u0007x>\u00bdX\u0096\u009d\u00888n\u0013z", "\u0002\u00f1T\u0019\u00efTu\u0083", "\u00fd\u00878!\u000equ\u0084\u00a3\u0001\u00a6IYg\u008a\u0091\u00dc%\u00f9/s\u00f1\u0086kc\u00b5\u0084\u009a\u00c2\u00d2\u00bc\u00faX\u0096\u009d\u00888n\u0013z", "\u00d3\u0091\u0006\u00e7\u00da\u008c\u00a4I\u00a0\u00dd\u00cb\u0098\u00a7\u0003\\\u00ee\u00e9&\u009c\u00de^\u00fe\u00d9{", "\u0086\u00dd\u001c7\u00a0\u00e48(\u0017\u00d0p@\u0091\u000e\u00c0a\u00f5\u0006\u00c3O\u00e6\u00f6\u0090#W \u0001\u009a\u00b7\u00f1\u00b6\u0095", "\u0082\u00a9\u00d3)\u00c3u\u000b\f\u00f3E\u00a1]\u00f7\u00a5\u00e7\u00ac", "\u00e3\u009c\u00f4\u00d9\u0085\u008ab\u001b\u00e9I\u00fd\u00e4qM\u00ce|", "=1\u0084\u0012\u00c9\u00e5\u00e4M", "\u00aaW8\u0002e\u00a9\u00c0^", "A\u00aeg\u009d\u00fb\u00be`\u00e7\u0083\u00e6\u00a3\u00dc\u00fc\u00dd+G", "\u00155X{\u00da\u00e6(\u0088r\u00c3P\u009d\u00daW\u0089\u009c\u00ca|>\u00b6\u00d5\u0086{(\u0085q\u00d2\u00d5\u00dbv\u0096\b", "\u00155X{\u00da\u00e6(\u0088\u00c7\u00e8\\\u00c5L\u00b6tkR\u0001Y#\u008f<\u0013\u009f\u0011(\u00d9_\u00cd\u0084\u0088\u00a6\u008cj\u00ff\u00dd\u0088\u00127\u0090H^\u00deK\u00e6\u00e3x\u00db\u00d5\u001abH\u0017xGm\u0085\u00d0Z\u0086c\u00e4\u001f\u00cf\u00ddq\u001a.\u0086\u00eevW\u001e\u00ba\u0016\u00d9'E\u00f3\u00c6", "\u00ae.\u00e1V\u0011\u00a1*\u00db", "0%\u0088q\u00bf\u00cd\u00d2~"});
    }

    public static String __pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_d_s(String string) {
        String string2 = "\u008dL\"\u00bae\u0099x\u00f6\u00ae\u00ad4X\u00fb\u00b4\u0094\u00d3r\u00b3\u00ddE\u009ag\u00f3\u00c7";
        byte[] arrby = string2.getBytes("ISO-8859-1");
        SecretKeyFactory secretKeyFactory = SecretKeyFactory.getInstance("DESede");
        SecretKey secretKey = secretKeyFactory.generateSecret(new DESedeKeySpec(arrby));
        Cipher cipher = Cipher.getInstance("DESede");
        cipher.init(2, secretKey);
        byte[] arrby2 = cipher.doFinal(string.getBytes("ISO-8859-1"));
        String string3 = new String(arrby2, "UTF8");
        return string3;
    }

    public static String[] __pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_d(String[] arrstring) {
        for (int i = 0; i < arrstring.length; ++i) {
            try {
                arrstring[i] = UltraPrisonCore.__pmob_$QU2WURsh1EHr1eM_FkHnib6yaa7k319w$_d_s(arrstring[i]);
                continue;
            }
            catch (Exception exception) {
                exception.printStackTrace();
            }
        }
        return arrstring;
    }
}
 

Java online compiler

Write, Run & Share Java code online using OneCompiler's Java online compiler for free. It's one of the robust, feature-rich online compilers for Java language, running the Java LTS version 17. Getting started with the OneCompiler's Java editor is easy and fast. The editor shows sample boilerplate code when you choose language as Java and start coding.

Taking inputs (stdin)

OneCompiler's Java online editor supports stdin and users can give inputs to the programs using the STDIN textbox under the I/O tab. Using Scanner class in Java program, you can read the inputs. Following is a sample program that shows reading STDIN ( A string in this case ).

import java.util.Scanner;
class Input {
    public static void main(String[] args) {
    	Scanner input = new Scanner(System.in);
    	System.out.println("Enter your name: ");
    	String inp = input.next();
    	System.out.println("Hello, " + inp);
    }
}

Adding dependencies

OneCompiler supports Gradle for dependency management. Users can add dependencies in the build.gradle file and use them in their programs. When you add the dependencies for the first time, the first run might be a little slow as we download the dependencies, but the subsequent runs will be faster. Following sample Gradle configuration shows how to add dependencies

apply plugin:'application'
mainClassName = 'HelloWorld'

run { standardInput = System.in }
sourceSets { main { java { srcDir './' } } }

repositories {
    jcenter()
}

dependencies {
    // add dependencies here as below
    implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.9'
}

About Java

Java is a very popular general-purpose programming language, it is class-based and object-oriented. Java was developed by James Gosling at Sun Microsystems ( later acquired by Oracle) the initial release of Java was in 1995. Java 17 is the latest long-term supported version (LTS). As of today, Java is the world's number one server programming language with a 12 million developer community, 5 million students studying worldwide and it's #1 choice for the cloud development.

Syntax help

Variables

short x = 999; 			// -32768 to 32767
int   x = 99999; 		// -2147483648 to 2147483647
long  x = 99999999999L; // -9223372036854775808 to 9223372036854775807

float x = 1.2;
double x = 99.99d;

byte x = 99; // -128 to 127
char x = 'A';
boolean x = true;

Loops

1. If Else:

When ever you want to perform a set of operations based on a condition If-Else is used.

if(conditional-expression) {
  // code
} else {
  // code
}

Example:

int i = 10;
if(i % 2 == 0) {
  System.out.println("i is even number");
} else {
  System.out.println("i is odd number");
}

2. Switch:

Switch is an alternative to If-Else-If ladder and to select one among many blocks of code.

switch(<conditional-expression>) {    
case value1:    
 // code    
 break;  // optional  
case value2:    
 // code    
 break;  // optional  
...    
    
default:     
 //code to be executed when all the above cases are not matched;    
} 

3. For:

For loop is used to iterate a set of statements based on a condition. Usually for loop is preferred when number of iterations is known in advance.

for(Initialization; Condition; Increment/decrement){  
    //code  
} 

4. While:

While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.

while(<condition>){  
 // code 
}  

5. Do-While:

Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.

do {
  // code 
} while (<condition>); 

Classes and Objects

Class is the blueprint of an object, which is also referred as user-defined data type with variables and functions. Object is a basic unit in OOP, and is an instance of the class.

How to create a Class:

class keyword is required to create a class.

Example:

class Mobile {
    public:    // access specifier which specifies that accessibility of class members 
    string name; // string variable (attribute)
    int price; // int variable (attribute)
};

How to create a Object:

Mobile m1 = new Mobile();

How to define methods in a class:

public class Greeting {
    static void hello() {
        System.out.println("Hello.. Happy learning!");
    }

    public static void main(String[] args) {
        hello();
    }
}

Collections

Collection is a group of objects which can be represented as a single unit. Collections are introduced to bring a unified common interface to all the objects.

Collection Framework was introduced since JDK 1.2 which is used to represent and manage Collections and it contains:

  1. Interfaces
  2. Classes
  3. Algorithms

This framework also defines map interfaces and several classes in addition to Collections.

Advantages:

  • High performance
  • Reduces developer's effort
  • Unified architecture which has common methods for all objects.
CollectionDescription
SetSet is a collection of elements which can not contain duplicate values. Set is implemented in HashSets, LinkedHashSets, TreeSet etc
ListList is a ordered collection of elements which can have duplicates. Lists are classified into ArrayList, LinkedList, Vectors
QueueFIFO approach, while instantiating Queue interface you can either choose LinkedList or PriorityQueue.
DequeDeque(Double Ended Queue) is used to add or remove elements from both the ends of the Queue(both head and tail)
MapMap contains key-values pairs which don't have any duplicates. Map is implemented in HashMap, TreeMap etc.