-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86ce242
commit 5ab2395
Showing
2 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
plugin/src/main/java/com/denizenscript/denizen/utilities/entity/ColorHelper1_17.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.denizenscript.denizen.utilities.entity; | ||
|
||
import com.denizenscript.denizen.objects.properties.entity.EntityColor; | ||
import com.denizenscript.denizencore.objects.Mechanism; | ||
import com.denizenscript.denizencore.objects.core.ListTag; | ||
import com.denizenscript.denizencore.utilities.CoreUtilities; | ||
import org.bukkit.entity.Axolotl; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.entity.EntityType; | ||
import org.bukkit.entity.Goat; | ||
|
||
public class ColorHelper1_17 { | ||
|
||
public static boolean colorIsApplicable(EntityType type) { | ||
return type == EntityType.GOAT || type == EntityType.AXOLOTL; | ||
} | ||
|
||
public static String getColor(Entity entity) { | ||
if (entity instanceof Goat) { | ||
return ((Goat) entity).isScreaming() ? "screaming" : "normal"; | ||
} | ||
else if (entity instanceof Axolotl) { | ||
return ((Axolotl) entity).getVariant().name(); | ||
} | ||
return null; | ||
} | ||
|
||
public static ListTag getAllowedColors(EntityType type) { | ||
if (type == EntityType.GOAT) { | ||
ListTag result = new ListTag(); | ||
result.add("screaming"); | ||
result.add("normal"); | ||
return result; | ||
} | ||
else if (type == EntityType.AXOLOTL) { | ||
return EntityColor.listForEnum(Axolotl.Variant.values()); | ||
} | ||
return null; | ||
} | ||
|
||
public static void setColor(Entity entity, Mechanism mech) { | ||
if (entity instanceof Goat) { | ||
((Goat) entity).setScreaming(CoreUtilities.toLowerCase(mech.getValue().asString()).equals("screaming")); | ||
} | ||
else if (entity instanceof Axolotl && mech.requireEnum(false, Axolotl.Variant.values())) { | ||
((Axolotl) entity).setVariant(Axolotl.Variant.valueOf(mech.getValue().asString().toUpperCase())); | ||
} | ||
} | ||
} |