Skip to content

[Forge] SideOnly: Disable checking inside methods marked with specific annotation #474

Open
@WeAthFoLD

Description

@WeAthFoLD

First of all awesome plugin! Thank you for the efforts creating this >3

There is one case of valid sideonly usage:

void someFunc() {
    if (getSide() == Side.CLIENT)
        someClientOnlyMethod();
}

@SideOnly(Side.CLIENT)
void someClientOnlyMethod() { ... }

where getSide() effectively returns FMLCommonHandler.INSTANCE.getEffectiveSide().

There are possible variations which are essentially the same:

void someFunc() {
    if (isClient())
        someClientOnlyMethod();
}

// Maybe wrapped in some utility class
boolean isClient() { return getSide() == Side.CLIENT; }

@SideOnly(Side.CLIENT)
void someClientOnlyMethod() { ... }

Since detecting this kind of usage can be difficult, I suggest using certain annotation (e.g. SuppressWarning("sideonly") on methods that have this kind of usage.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions