Skip to content

Commit

Permalink
Abstract Chargeable to a separate interface (#2558)
Browse files Browse the repository at this point in the history
  • Loading branch information
ImMorpheus authored Jul 7, 2024
1 parent f8faf0d commit 6dbea4e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 17 deletions.
40 changes: 40 additions & 0 deletions src/main/java/org/spongepowered/api/entity/Chargeable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
*
* Copyright (c) SpongePowered <https://www.spongepowered.org>
* Copyright (c) contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.spongepowered.api.entity;

import org.spongepowered.api.data.Keys;
import org.spongepowered.api.data.value.Value;

public interface Chargeable extends Entity {

/**
* {@link Keys#IS_CHARGED}
*
* @return Whether this entity is charged or not
*/
default Value.Mutable<Boolean> charged() {
return this.requireValue(Keys.IS_CHARGED).asMutable();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,12 @@
*/
package org.spongepowered.api.entity.living.monster;

import org.spongepowered.api.data.Keys;
import org.spongepowered.api.data.value.Value;
import org.spongepowered.api.entity.Chargeable;
import org.spongepowered.api.entity.explosive.fused.FusedExplosive;
import org.spongepowered.api.entity.living.Monster;

/**
* Represents a Creeper.
*/
public interface Creeper extends Monster, FusedExplosive {

/**
* {@link Keys#IS_CHARGED}
*
* <p>Note that "charged" creepers will likely
* cause larger than normal explosions.</p>
*
* @return Whether this creeper is charged or not
*/
default Value.Mutable<Boolean> charged() {
return this.requireValue(Keys.IS_CHARGED).asMutable();
}

public interface Creeper extends Monster, FusedExplosive, Chargeable {
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.spongepowered.api.data.Keys;
import org.spongepowered.api.data.value.ListValue;
import org.spongepowered.api.entity.Aerial;
import org.spongepowered.api.entity.Chargeable;
import org.spongepowered.api.entity.Entity;
import org.spongepowered.api.entity.explosive.fused.FusedExplosive;
import org.spongepowered.api.entity.living.Monster;
Expand All @@ -35,7 +36,7 @@
/**
* Represents the Wither.
*/
public interface Wither extends Monster, RangedAgent, Boss, Aerial, FusedExplosive {
public interface Wither extends Monster, RangedAgent, Boss, Aerial, FusedExplosive, Chargeable {

/**
* {@link Keys#WITHER_TARGETS}
Expand Down

0 comments on commit 6dbea4e

Please sign in to comment.