Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation Code Cleanup #1932

Merged
merged 7 commits into from
Jun 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions src/main/java/org/spongepowered/common/SpongeImplHooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ public static SpawnerSpawnType canEntitySpawnHere(EntityLiving entityLiving, boo
public static Object onUtilRunTask(FutureTask<?> task, Logger logger) {
final PhaseTracker phaseTracker = PhaseTracker.getInstance();
try (final BasicPluginContext context = PluginPhase.State.SCHEDULED_TASK.createPhaseContext()
.source(task)
.buildAndSwitch()) {
.source(task)) {
context.buildAndSwitch();
final Object o = Util.runTask(task, logger);
return o;
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,19 @@
public abstract class AbstractCriterionBuilder<T extends AdvancementCriterion, B extends AdvancementCriterion.BaseBuilder<T, B>>
implements ScoreAdvancementCriterion.BaseBuilder<T, B> {

@Nullable protected FilteredTrigger trigger;
protected String name;
@Nullable protected FilteredTrigger<?> trigger;
@Nullable protected String name;

@Override
@SuppressWarnings("unchecked")
public B trigger(FilteredTrigger<?> trigger) {
checkNotNull(trigger, "trigger");
this.trigger = trigger;
return (B) this;
}

@Override
@SuppressWarnings("unchecked")
public B name(String name) {
checkNotNull(name, "name");
this.name = name;
Expand All @@ -62,13 +64,15 @@ public T build() {
abstract T build0();

@Override
@SuppressWarnings("unchecked")
public B from(T value) {
this.trigger = value.getTrigger().orElse(null);
this.name = value.getName();
return (B) this;
}

@Override
@SuppressWarnings("unchecked")
public B reset() {
this.trigger = null;
this.name = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.spongepowered.api.advancement.criteria.trigger.FilteredTriggerConfiguration;
import org.spongepowered.api.advancement.criteria.trigger.Trigger;

@SuppressWarnings("rawtypes")
public class SpongeFilteredTrigger implements ICriterionInstance, FilteredTrigger {

private final SpongeTrigger triggerType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@

import javax.annotation.Nullable;

@SuppressWarnings("rawtypes")
public class SpongeTrigger implements ICriterionTrigger<SpongeFilteredTrigger>, ITrigger {

private final Class<FilteredTriggerConfiguration> triggerConfigurationClass;
Expand Down Expand Up @@ -109,7 +110,7 @@ public Class<FilteredTriggerConfiguration> getConfigurationType() {
public void trigger(Player player) {
final PlayerAdvancements playerAdvancements = ((EntityPlayerMP) player).getAdvancements();
final Cause cause = Sponge.getCauseStackManager().getCurrentCause();
final TypeToken typeToken = TypeToken.of(this.triggerConfigurationClass);
final TypeToken<FilteredTriggerConfiguration> typeToken = TypeToken.of(this.triggerConfigurationClass);
for (Listener listener : new ArrayList<>(this.listeners.get(playerAdvancements))) {
final IMixinICriterionTriggerListener mixinListener = (IMixinICriterionTriggerListener) listener;
final Advancement advancement = (Advancement) mixinListener.getAdvancement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ public class SpongeTriggerBuilder<C extends FilteredTriggerConfiguration> implem
private final static Function<JsonObject, FilteredTriggerConfiguration.Empty> EMPTY_TRIGGER_CONFIGURATION_CONSTRUCTOR =
jsonObject -> EMPTY_TRIGGER_CONFIGURATION;

private Class<C> configType;
private Function<JsonObject, C> constructor;
@Nullable private Class<C> configType;
@Nullable private Function<JsonObject, C> constructor;
@Nullable private Consumer<CriterionEvent.Trigger<C>> eventHandler;
private String id;
@Nullable private String id;
@Nullable private String name;

@Override
@SuppressWarnings("rawtypes")
public <T extends FilteredTriggerConfiguration & DataSerializable> Trigger.Builder<T> dataSerializableConfig(Class<T> dataConfigClass) {
checkNotNull(dataConfigClass, "dataConfigClass");
this.configType = (Class<C>) dataConfigClass;
Expand Down Expand Up @@ -104,6 +105,7 @@ public <T extends FilteredTriggerConfiguration> Trigger.Builder<T> typeSerializa
}

@Override
@SuppressWarnings("rawtypes")
public <T extends FilteredTriggerConfiguration> Trigger.Builder<T> typeSerializableConfig(Class<T> configClass,
TypeSerializerCollection typeSerializerCollection) {
checkNotNull(configClass, "configClass");
Expand Down Expand Up @@ -137,6 +139,7 @@ public C apply(JsonObject jsonObject) {
}
}

@SuppressWarnings("rawtypes")
@Override
public <T extends FilteredTriggerConfiguration> Trigger.Builder<T> jsonSerializableConfig(Class<T> configClass, Gson gson) {
checkNotNull(configClass, "configClass");
Expand Down Expand Up @@ -193,6 +196,7 @@ public Trigger.Builder<C> name(String name) {
return this;
}

@SuppressWarnings("rawtypes")
@Override
public Trigger<C> build() {
checkState(this.id != null, "The id must be set");
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/spongepowered/common/ban/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.ban;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.ban;
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ public boolean restore(boolean force, BlockChangeFlag flag) {
final IMixinWorldServer mixinWorldServer = (IMixinWorldServer) world;
// We need to deterministically define the context as nullable if we don't need to enter.
// this way we guarantee an exit.
try (PhaseContext<?> context = BlockPhase.State.RESTORING_BLOCKS.createPhaseContext().buildAndSwitch()) {

try (PhaseContext<?> context = BlockPhase.State.RESTORING_BLOCKS.createPhaseContext()) {
context.buildAndSwitch();
BlockPos pos = VecHelper.toBlockPos(this.pos);
IBlockState current = world.getBlockState(pos);
IBlockState replaced = (IBlockState) this.blockState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.block;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.block;
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ protected Object parseValue(CommandSource source, CommandArgs args) throws Argum
*
* @return The newly created command
*/
@SuppressWarnings("deprecation")
public static CommandSpec createSpongeCommand() {
final ChildCommandElementExecutor flagChildren = new ChildCommandElementExecutor(null);
final ChildCommandElementExecutor nonFlagChildren = new ChildCommandElementExecutor(flagChildren);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,13 @@ public CommandResult process(CommandSource source, String commandLine) {
CommandPhaseContext context = GeneralPhase.State.COMMAND.createPhaseContext()
.source(source)
.addCaptures()
.addEntityDropCaptures()
.buildAndSwitch()) {
.addEntityDropCaptures()) {
context.buildAndSwitch();
if (source instanceof EntityPlayer) {
// Enable player inventory capture
((IMixinInventoryPlayer) ((EntityPlayer) source).inventory).setCapture(true);
}
Sponge.getCauseStackManager().pushCause(source);
frame.pushCause(source);
final CommandResult result = this.dispatcher.process(source, commandLine);
return result;
} catch (InvocationCommandException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.command;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.command;
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public boolean flush(SpongeConfig<?> config) {
public void flush() {
if (!this.stagedConfigs.isEmpty()) {
synchronized (this) {
for (SpongeConfig spongeConfig : this.stagedConfigs) {
for (SpongeConfig<?> spongeConfig : this.stagedConfigs) {
spongeConfig.saveNow();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.config;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.config;
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public boolean supports(Key<?> key) {
}

@Override
@SuppressWarnings("rawtypes")
public Set<Key<?>> getKeys() {
return DataUtil.getNbtValueProcessors(this.getDataType()).stream()
.map(processor -> processor.readFrom(this.data))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.data.builder.authlib;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.data.builder.authlib;
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.data.builder.block.tileentity;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.data.builder.block.tileentity;
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.data.builder.item;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.data.builder.item;
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.data.builder.manipulator.immutable.block;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.data.builder.manipulator.immutable.block;
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.data.builder.manipulator.immutable.item;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.data.builder.manipulator.immutable.item;
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.data.builder.manipulator.immutable;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.data.builder.manipulator.immutable;
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.data.builder.manipulator;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.data.builder.manipulator;
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.data.builder.meta;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.data.builder.meta;
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.data.builder;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.data.builder;
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.data.builder.util.weighted;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.data.builder.util.weighted;
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.data.builder.world;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.data.builder.world;
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.data.manipulator.immutable.block;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.data.manipulator.immutable.block;
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.data.manipulator.immutable.common;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.data.manipulator.immutable.common;
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ public ImmutableSpongeFoodData(int foodLevel, double foodSaturationLevel, double
.asImmutable();

this.exhaustionValue = SpongeValueFactory.boundedBuilder(Keys.EXHAUSTION)
.actualValue((double) this.foodExhaustionLevel)
.actualValue(this.foodExhaustionLevel)
.defaultValue(0D)
.minimum(0D)
.maximum(Double.MAX_VALUE)
.build()
.asImmutable();

this.saturationValue = SpongeValueFactory.boundedBuilder(Keys.SATURATION)
.actualValue((double) this.foodSaturationLevel)
.actualValue(this.foodSaturationLevel)
.defaultValue(20D)
.minimum(0D)
.maximum(Double.MAX_VALUE)
Expand All @@ -86,8 +86,8 @@ public FoodData asMutable() {
public DataContainer toContainer() {
return super.toContainer()
.set(Keys.FOOD_LEVEL, this.foodLevel)
.set(Keys.SATURATION, (double) this.foodSaturationLevel)
.set(Keys.EXHAUSTION, (double) this.foodExhaustionLevel);
.set(Keys.SATURATION, this.foodSaturationLevel)
.set(Keys.EXHAUSTION, this.foodExhaustionLevel);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.data.manipulator.immutable.entity;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.data.manipulator.immutable.entity;
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.data.manipulator.immutable.extra;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.data.manipulator.immutable.extra;
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.data.manipulator.immutable.item;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.data.manipulator.immutable.item;
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.data.manipulator.immutable;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.data.manipulator.immutable;
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.data.manipulator.immutable.tileentity;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.data.manipulator.immutable.tileentity;
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.data.manipulator.mutable.block;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.data.manipulator.mutable.block;
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.data.manipulator.mutable.common;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.data.manipulator.mutable.common;
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public MutableBoundedValue<Double> exhaustion() {
.defaultValue(0D)
.minimum(0D)
.maximum(Double.MAX_VALUE)
.actualValue((double) this.foodExhaustionLevel)
.actualValue(this.foodExhaustionLevel)
.build();
}

Expand All @@ -95,7 +95,7 @@ public MutableBoundedValue<Double> saturation() {
.defaultValue(20D)
.minimum(0D)
.maximum(Double.MAX_VALUE)
.actualValue((double) this.foodSaturationLevel)
.actualValue(this.foodSaturationLevel)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@org.spongepowered.api.util.annotation.NonnullByDefault package org.spongepowered.common.data.manipulator.mutable.entity;
@org.spongepowered.api.util.annotation.NonnullByDefault
package org.spongepowered.common.data.manipulator.mutable.entity;
Loading