9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2025-12-19 15:09:23 +00:00
This commit is contained in:
XiaoMoMi
2024-11-07 17:59:03 +08:00
parent d59ac96f48
commit ca70dfb2b4
15 changed files with 122 additions and 42 deletions

View File

@@ -0,0 +1,21 @@
/*
* Copyright (C) <2024> <XiaoMoMi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.momirealms.customnameplates.api.feature.image;
public record Animation(int speed, int frames) {
}

View File

@@ -18,6 +18,7 @@
package net.momirealms.customnameplates.api.feature.image;
import net.momirealms.customnameplates.api.feature.ConfiguredCharacter;
import org.jetbrains.annotations.Nullable;
public interface Image {
@@ -33,15 +34,15 @@ public interface Image {
*
* @return true if the image has a shadow, false otherwise
*/
boolean hasShadow();
boolean removeShadow();
/**
* Returns the opacity level of the image.
* The value should typically range from 0 (fully transparent) to 255 (fully opaque).
* Get the animation of the image
*
* @return the opacity value of the image
* @return the animated image
*/
int opacity();
@Nullable
Animation animation();
/**
* Returns the configured character associated with this image.
@@ -73,20 +74,20 @@ public interface Image {
Builder id(String id);
/**
* Sets whether the image has a shadow effect.
* Sets whether to remove the shadow of the image
*
* @param has true if the image should have a shadow, false otherwise
* @param remove true if to remove the shadow
* @return the builder instance
*/
Builder hasShadow(boolean has);
Builder removeShadow(boolean remove);
/**
* Sets the opacity level of the image.
* Sets the animation of the image
*
* @param opacity the opacity value, typically from 0 to 255
* @param animation animation
* @return the builder instance
*/
Builder opacity(int opacity);
Builder animation(@Nullable Animation animation);
/**
* Sets the configured character associated with this image.

View File

@@ -18,21 +18,22 @@
package net.momirealms.customnameplates.api.feature.image;
import net.momirealms.customnameplates.api.feature.ConfiguredCharacter;
import org.jetbrains.annotations.Nullable;
import java.util.Objects;
public class ImageImpl implements Image {
private final String id;
private final boolean hasShadow;
private final int opacity;
private final boolean removeShadow;
private final ConfiguredCharacter character;
private final Animation animation;
public ImageImpl(String id, boolean hasShadow, int opacity, ConfiguredCharacter character) {
public ImageImpl(String id, boolean removeShadow, Animation animation, ConfiguredCharacter character) {
this.id = id;
this.hasShadow = hasShadow;
this.opacity = opacity;
this.removeShadow = removeShadow;
this.character = character;
this.animation = animation;
}
@Override
@@ -41,13 +42,13 @@ public class ImageImpl implements Image {
}
@Override
public boolean hasShadow() {
return hasShadow;
public boolean removeShadow() {
return removeShadow;
}
@Override
public int opacity() {
return opacity;
public @Nullable Animation animation() {
return animation;
}
@Override
@@ -71,9 +72,9 @@ public class ImageImpl implements Image {
public static class BuilderImpl implements Builder {
private String id;
private boolean hasShadow;
private int opacity;
private boolean removeShadow;
private ConfiguredCharacter character;
private Animation animation;
@Override
public Builder id(String id) {
@@ -82,14 +83,14 @@ public class ImageImpl implements Image {
}
@Override
public Builder hasShadow(boolean has) {
this.hasShadow = has;
public Builder removeShadow(boolean removeShadow) {
this.removeShadow = removeShadow;
return this;
}
@Override
public Builder opacity(int opacity) {
this.opacity = opacity;
public Builder animation(@Nullable Animation animation) {
this.animation = animation;
return this;
}
@@ -101,7 +102,7 @@ public class ImageImpl implements Image {
@Override
public Image build() {
return new ImageImpl(id, hasShadow, opacity, character);
return new ImageImpl(id, removeShadow, animation, character);
}
}
}