找不到定义的方法(反编译类)

时间:2015-10-27 11:23:58

标签: java eclipse

此类已被反编译(使用Luyten)。虽然dbReadOverriddenFeatures()确实有一个定义,但方法调用找不到它,我无法理解为什么(我正在使用Eclipse)。如果我遗漏了一些明显的东西,我会很感激有人为我指出,谢谢。

public final class Features
{
    private static final Logger logger;
    private static int currentProdVersion;

static {
    logger = Logger.getLogger(Features.class.getName());
    Features.currentProdVersion = 126;
}

public static void loadAllFeatures() {
    dbReadOverriddenFeatures();
    logFeatureDetails();
}


public static void logFeatureDetails() {
    Feature[] values;
    for (int length = (values = Feature.values()).length, i = 0; i < length; ++i) {
        final Feature lFeature = values[i];
        Features.logger.info(lFeature.toString());
    }
}

public static int getVerionsNo() {
    return Features.currentProdVersion;
}

public enum Feature
{
    NONE("NONE", 0, 0, "Dummy entry - do not use", 1), 
    MULTI_ITEM_ACTIONS("MULTI_ITEM_ACTIONS", 1, 14, "Multiple item actions", 120), 
    CAVE_FLOOR_REINFORCE("CAVE_FLOOR_REINFORCE", 2, 16, "Reinforce Cave Floors", 120), 
    TOWER_ROTATION("TOWER_ROTATION", 3, 17, "Allows Towers to be rotated", 120), 
    INGAME_VOTING("INGAME_VOTING", 4, 18, "In-Game Voting", 121), 
    FENCE_IN_ARCH("FENCE_IN_ARCH", 5, 19, "Fences in Archs", 121), 
    BRIDGES("BRIDGES", 6, 20, "Bridges", 125), 
    PREMIUMEXPIRY("PREMIUMEXPIRY", 7, 30, "Expiry warnings and bonuses for keeping premium", 112), 
    NAMECHANGE("NAMECHANGE", 8, 31, "Name change", 999), 
    SURFACEWATER("SURFACEWATER", 9, 32, "Surface Water", 130), 
    FENCEWINDOW("FENCEWINDOW", 10, 33, "Fence Creation Window", 120), 
    HOUSE_CRAFTING("HOUSE_CRAFTING", 11, 34, "House Creation window", 120), 
    TUTORIAL_FENCES_AND_WALLS("TUTORIAL_FENCES_AND_WALLS", 12, 35, "New stuff to be released with the new tutorial", 121), 
    MULTIPLE_SPAWNS("MULTIPLE_SPAWNS", 13, 36, "Seeing multiple spawn settlements on portals", 120), 
    TENTS("TENTS", 14, 37, "Newbie tents and tent creation", 121), 
    NEW_SKILL_SYSTEM("NEW_SKILL_SYSTEM", 15, 38, "New skill system", 125), 
    DEED_STAKES("DEED_STAKES", 16, 39, "Deed stakes", 120), 
    DECORATIVE_FURNITURE("DECORATIVE_FURNITURE", 17, 40, "New furniture", 121), 
    BLOCKED_TRADERS("BLOCKED_TRADERS", 18, 41, "Blocked Traders", 121), 
    CAHELP_GROUPS("CAHELP_GROUPS", 19, 42, "CA Help Groups", 121), 
    ADD_REMOTE_FRIEND("ADD_REMOTE_FRIEND", 20, 43, "Add remote friends", 121), 
    CA_SEE_MGMT("CA_SEE_MGMT", 21, 44, "Allow CA to see MGMT", 121), 
    ACKNOWLEDGE_TICKET_UPDATES("ACKNOWLEDGE_TICKET_UPDATES", 22, 45, "Acknowledge ticket updates", 123), 
    TRELLISES("TRELLISES", 23, 46, "Grape & Ivy Trellises", 122), 
    SPLIT_TREES("SPLIT_TREES", 24, 47, "Split trees and bushes", 124), 
    COIN_KICKBACK("COIN_KICKBACK", 25, 48, "Rare Coin Distribution", 123), 
    SIEGE_STUFF("SIEGE_STUFF", 26, 49, "New Siege Stuff", 125), 
    MARBLE_BRIDGES("MARBLE_BRIDGES", 27, 50, "Marble Bridges", 125), 
    CREATURE_COMBAT_CHANGES("CREATURE_COMBAT_CHANGES", 28, 51, "Combat system changes for creatures", 125), 
    STAIRCASES("STAIRCASES", 29, 52, "Staircases", 125), 
    HOUSE_BRIDGES("HOUSE_BRIDGES", 30, 53, "Bridges to/from houses", 125), 
    MANAGE_FRIENDS("MANAGE_FRIENDS", 31, 54, "Manage Friends", 124), 
    BLOCK_HOTA("BLOCK_HOTA", 32, 55, "Blocked HOTA terraforming and building", 201), 
    FREE_ITEMS("FREE_ITEMS", 33, 56, "Free armour and weapons on spawn", 201), 
    TREASURE_CHESTS("TREASURE_CHESTS", 34, 57, "Random treasure chests", 125), 
    BALCONY_JETTY_WALLS("BALCONY_JETTY_WALLS", 35, 68, "New wall types, balcony.", 125), 
    OWNERSHIP_PAPERS("OWNERSHIP_PAPERS", 36, 70, "Ownership Papers", 203), 
    MAIL_TREE("MAIL_TREE", 37, 71, "Mail Tree", 121), 
    VALREI_MAP("VALREI_MAP", 38, 72, "Valrei map", 125), 
    SHOW_DEED_PLAN("SHOW_DEED_PLAN", 39, 74, "Show Deed Plan", 126), 
    CROP_POLLER("CROP_POLLER", 40, 75, "Crop tile poller split", 125), 
    SINGLE_PLAYER_BRIDGES("SINGLE_PLAYER_BRIDGES", 41, 76, "Single Player Bridges", 125), 
    AMPHORA("AMPHORA", 42, 77, "Amphora", 126),
    ENDGAME("ENDGAME", 43, 78, "Holy Altars and Artifacts", 126);

    private static final String GET_ALL_OVERRIDDEN_FEATURES = "SELECT * FROM OVERRIDDENFEATURES";
    private static final String INSERT_OVERRIDDEN_FEATURE = "INSERT INTO OVERRIDDENFEATURES(FEATUREID,ENABLED) VALUES(?,?)";
    private static final String DELETE_OVERRIDDEN_FEATURE = "DELETE FROM OVERRIDDENFEATURES WHERE FEATUREID=?";
    private static final String UPDATE_OVERRIDDEN_FEATURE = "UPDATE OVERRIDDENFEATURES SET ENABLED=? WHERE FEATUREID=?";
    private final int featureId;
    private final String name;
    private final int version;
    private final boolean theDefault;
    private boolean overridden;
    private boolean enabled;
    private static final Feature[] types;

    static {
        types = values();
    }

    private Feature(final String s, final int n, final int aFeatureId, final String aName, final int aVersion) {
        this.featureId = aFeatureId;
        this.name = aName;
        this.version = aVersion;
        this.theDefault = (Servers.isThisATestServer() || aVersion <= Features.currentProdVersion);
        this.enabled = this.theDefault;
        if (Servers.localServer.isChallengeServer() && (this.featureId == 55 || this.featureId == 56 || this.featureId == 57)) {
            this.enabled = true;
        }
        if (Servers.localServer.id == 15 && this.featureId == 41) {
            this.enabled = false;
        }
        this.overridden = false;
    }

    public int getVersion() {
        return this.version;
    }

    public boolean getDefault() {
        return this.theDefault;
    }

    public int getFeatureId() {
        return this.featureId;
    }

    public String getName() {
        return this.name;
    }

    public boolean isEnabled() {
        return this.enabled;
    }

    public boolean isOverridden() {
        return this.overridden;
    }

    private void dbDeleteOverridden() {
        Connection dbcon = null;
        PreparedStatement ps = null;
        try {
            Features.logger.log(Level.INFO, "Removing override for feature: " + this.featureId);
            dbcon = DbConnector.getLoginDbCon();
            ps = dbcon.prepareStatement("DELETE FROM OVERRIDDENFEATURES WHERE FEATUREID=?");
            ps.setInt(1, this.featureId);
            ps.executeUpdate();
        }
        catch (SQLException sqex) {
            Features.logger.log(Level.WARNING, "Failed to delete overridden feature " + this.featureId + " from logindb!" + sqex.getMessage(), sqex);
            return;
        }
        finally {
            DbUtilities.closeDatabaseObjects(ps, null);
            DbConnector.returnConnection(dbcon);
        }
        DbUtilities.closeDatabaseObjects(ps, null);
        DbConnector.returnConnection(dbcon);
    }

    public void dbAddOverridden(final boolean aEnabled) {
        Connection dbcon = null;
        PreparedStatement ps = null;
        try {
            dbcon = DbConnector.getLoginDbCon();
            Features.logger.log(Level.INFO, "Adding new override for feature: " + this.featureId);
            ps = dbcon.prepareStatement("INSERT INTO OVERRIDDENFEATURES(FEATUREID,ENABLED) VALUES(?,?)");
            ps.setInt(1, this.featureId);
            ps.setBoolean(2, aEnabled);
            ps.executeUpdate();
        }
        catch (SQLException sqex) {
            Features.logger.log(Level.WARNING, "Failed to insert overridden feature " + this.featureId + " in logindb!" + sqex.getMessage(), sqex);
            return;
        }
        finally {
            DbUtilities.closeDatabaseObjects(ps, null);
            DbConnector.returnConnection(dbcon);
        }
        DbUtilities.closeDatabaseObjects(ps, null);
        DbConnector.returnConnection(dbcon);
    }

    public void dbUpdateOverridden(final boolean aEnabled) {
        Connection dbcon = null;
        PreparedStatement ps = null;
        try {
            dbcon = DbConnector.getLoginDbCon();
            Features.logger.log(Level.INFO, "Updating override for feature: " + this.featureId);
            ps = dbcon.prepareStatement("UPDATE OVERRIDDENFEATURES SET ENABLED=? WHERE FEATUREID=?");
            ps.setBoolean(1, aEnabled);
            ps.setInt(2, this.featureId);
            ps.executeUpdate();
        }
        catch (SQLException sqex) {
            Features.logger.log(Level.WARNING, "Failed to insert overridden feature " + this.featureId + " in logindb!" + sqex.getMessage(), sqex);
            return;
        }
        finally {
            DbUtilities.closeDatabaseObjects(ps, null);
            DbConnector.returnConnection(dbcon);
        }
        DbUtilities.closeDatabaseObjects(ps, null);
        DbConnector.returnConnection(dbcon);
    }

    private static void dbReadOverriddenFeatures() {
        Connection dbcon = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        int count = 0;
        try {
            Features.logger.log(Level.INFO, "Loading all overridden features for production version: " + Features.currentProdVersion + " and isTestServer: " + Servers.isThisATestServer() + '.');
            dbcon = DbConnector.getLoginDbCon();
            ps = dbcon.prepareStatement("SELECT * FROM OVERRIDDENFEATURES");
            rs = ps.executeQuery();
            while (rs.next()) {
                ++count;
                final int featureid = rs.getInt("FEATUREID");
                final boolean enabled = rs.getBoolean("ENABLED");
                setOverridden(featureid, true, enabled);
                if (Features.logger.isLoggable(Level.FINE)) {
                    Features.logger.fine("Loaded overridden feature " + featureid);
                }
            }
        }
        catch (SQLException sqex) {
            Features.logger.log(Level.WARNING, "Failed to load all overridden features!" + sqex.getMessage(), sqex);
            return;
        }
        finally {
            DbUtilities.closeDatabaseObjects(ps, rs);
            DbConnector.returnConnection(dbcon);
            Features.logger.info("Loaded " + count + " overridden features from the database");
        }
        DbUtilities.closeDatabaseObjects(ps, rs);
        DbConnector.returnConnection(dbcon);
        Features.logger.info("Loaded " + count + " overridden features from the database");

    }

    private static void setOverridden(final int featureId, final boolean aOverridden, final boolean aEnabled) {
        final Feature feature = featureFromInt(featureId);
        feature.overridden = aOverridden;
        feature.enabled = aEnabled;
    }

    public static void setOverridden(final int aServerId, final int featureId, final boolean aOverridden, final boolean aEnabled, final boolean global) {
        if (global) {
            if (Servers.isThisLoginServer()) {
                ServerEntry[] allServers;
                for (int length = (allServers = Servers.getAllServers()).length, i = 0; i < length; ++i) {
                    final ServerEntry server = allServers[i];
                    if (server.id != Servers.loginServer.id && server.id != aServerId) {
                        final LoginServerWebConnection lsw = new LoginServerWebConnection(server.id);
                        lsw.manageFeature(aServerId, featureId, aOverridden, aEnabled, false);
                    }
                }
            }
            else {
                final LoginServerWebConnection lsw2 = new LoginServerWebConnection(Servers.loginServer.id);
                lsw2.manageFeature(aServerId, featureId, aOverridden, aEnabled, true);
            }
        }
        final Feature feature = featureFromInt(featureId);
        if (feature.overridden && !aOverridden) {
            feature.dbDeleteOverridden();
            feature.overridden = aOverridden;
            feature.enabled = feature.theDefault;
        }
        else if (!feature.overridden && aOverridden) {
            feature.dbAddOverridden(aEnabled);
            feature.overridden = aOverridden;
            feature.enabled = aEnabled;
        }
        else if (feature.overridden && feature.enabled != aEnabled) {
            feature.dbUpdateOverridden(aEnabled);
            feature.enabled = aEnabled;
        }
        else if (!global) {
            return;
        }
    }

    private static Feature featureFromInt(final int featureAsInt) {
        for (int i = 0; i < Feature.types.length; ++i) {
            if (featureAsInt == Feature.types[i].getFeatureId()) {
                return Feature.types[i];
            }
        }
        return Feature.NONE;
    }

    @Override
    public String toString() {
        final StringBuilder lBuilder = new StringBuilder();
        lBuilder.append("Feature [");
        lBuilder.append("Name: ").append(this.name);
        lBuilder.append(", Id: ").append(this.featureId);
        lBuilder.append(", Version: ").append(this.version);
        lBuilder.append(", Default: ").append(this.theDefault);
        lBuilder.append(", Overridden: ").append(this.isOverridden());
        lBuilder.append(", Enabled: ").append(this.isEnabled());
        lBuilder.append(']');
        return lBuilder.toString();
    }
}

}

1 个答案:

答案 0 :(得分:0)

解决。反编译器没有离开Feature。作为方法调用的前缀。