mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-09 09:57:40 +01:00
WIP - store data on Display Entities
This commit is contained in:
parent
6673d46dd3
commit
64fd48ead6
7
pom.xml
7
pom.xml
@ -419,6 +419,13 @@
|
|||||||
<version>2.0.0-SNAPSHOT</version>
|
<version>2.0.0-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- FancyHolograms -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.oliver</groupId>
|
||||||
|
<artifactId>FancyHolograms</artifactId>
|
||||||
|
<version>2.4.1</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -22,6 +22,7 @@ import org.bukkit.block.sign.Side;
|
|||||||
import org.bukkit.entity.AbstractHorse;
|
import org.bukkit.entity.AbstractHorse;
|
||||||
import org.bukkit.entity.Ageable;
|
import org.bukkit.entity.Ageable;
|
||||||
import org.bukkit.entity.ChestedHorse;
|
import org.bukkit.entity.ChestedHorse;
|
||||||
|
import org.bukkit.entity.Display;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Horse;
|
import org.bukkit.entity.Horse;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -356,6 +357,11 @@ public class BlueprintClipboard {
|
|||||||
mmh.filter(mm -> mm.isMythicMob(entity)).map(mm -> mm.getMythicMob(entity))
|
mmh.filter(mm -> mm.isMythicMob(entity)).map(mm -> mm.getMythicMob(entity))
|
||||||
.ifPresent(bpe::setMythicMobsRecord);
|
.ifPresent(bpe::setMythicMobsRecord);
|
||||||
|
|
||||||
|
// Display entities
|
||||||
|
if (entity instanceof Display disp) {
|
||||||
|
BentoBox.getInstance().logDebug(disp.getAsString());
|
||||||
|
bpe.storeDisplay(disp);
|
||||||
|
}
|
||||||
bpEnts.add(bpe);
|
bpEnts.add(bpe);
|
||||||
}
|
}
|
||||||
return bpEnts;
|
return bpEnts;
|
||||||
|
@ -2,19 +2,32 @@ package world.bentobox.bentobox.blueprints.dataobjects;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.bukkit.Color;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.entity.AbstractHorse;
|
import org.bukkit.entity.AbstractHorse;
|
||||||
import org.bukkit.entity.Ageable;
|
import org.bukkit.entity.Ageable;
|
||||||
|
import org.bukkit.entity.BlockDisplay;
|
||||||
import org.bukkit.entity.ChestedHorse;
|
import org.bukkit.entity.ChestedHorse;
|
||||||
|
import org.bukkit.entity.Display;
|
||||||
|
import org.bukkit.entity.Display.Billboard;
|
||||||
|
import org.bukkit.entity.Display.Brightness;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Horse;
|
import org.bukkit.entity.Horse;
|
||||||
import org.bukkit.entity.Horse.Style;
|
import org.bukkit.entity.Horse.Style;
|
||||||
|
import org.bukkit.entity.ItemDisplay;
|
||||||
import org.bukkit.entity.Tameable;
|
import org.bukkit.entity.Tameable;
|
||||||
|
import org.bukkit.entity.TextDisplay;
|
||||||
|
import org.bukkit.entity.TextDisplay.TextAlignment;
|
||||||
import org.bukkit.entity.Villager;
|
import org.bukkit.entity.Villager;
|
||||||
import org.bukkit.entity.Villager.Profession;
|
import org.bukkit.entity.Villager.Profession;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.material.Colorable;
|
import org.bukkit.material.Colorable;
|
||||||
|
import org.bukkit.util.Transformation;
|
||||||
|
|
||||||
import com.google.gson.annotations.Expose;
|
import com.google.gson.annotations.Expose;
|
||||||
|
|
||||||
@ -342,4 +355,138 @@ public class BlueprintEntity {
|
|||||||
+ (villagerType != null ? "villagerType=" + villagerType : "") + "]";
|
+ (villagerType != null ? "villagerType=" + villagerType : "") + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Expose
|
||||||
|
public DisplayRec displayRec;
|
||||||
|
@Expose
|
||||||
|
public TextDisplayRec textDisp;
|
||||||
|
@Expose
|
||||||
|
public BlockData blockDisp;
|
||||||
|
@Expose
|
||||||
|
public ItemStack itemDisp;
|
||||||
|
|
||||||
|
public record DisplayRec(@Expose Billboard billboard, @Expose Brightness brightness, @Expose float height,
|
||||||
|
@Expose float width, @Expose Color glowColorOverride, @Expose int interpolationDelay,
|
||||||
|
@Expose int interpolationDuration, @Expose float shadowRadius, @Expose float shadowStrength,
|
||||||
|
@Expose int teleportDuration, @Expose Transformation transformation, @Expose float range) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public record TextDisplayRec(@Expose String text, @Expose TextAlignment alignment, @Expose Color bgColor,
|
||||||
|
@Expose BlockFace face, @Expose int lWidth, @Expose byte opacity, @Expose boolean isShadowed,
|
||||||
|
@Expose boolean isSeeThrough, @Expose boolean isDefaultBg) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BlockDisplay, ItemDisplay, TextDisplay
|
||||||
|
* @param disp display entity
|
||||||
|
*/
|
||||||
|
public void storeDisplay(Display disp) {
|
||||||
|
// Generic items
|
||||||
|
displayRec = new DisplayRec(disp.getBillboard(), disp.getBrightness(), disp.getDisplayHeight(),
|
||||||
|
disp.getDisplayWidth(), disp.getGlowColorOverride(), disp.getInterpolationDelay(),
|
||||||
|
disp.getInterpolationDuration(), disp.getShadowRadius(), disp.getShadowStrength(),
|
||||||
|
disp.getTeleportDuration(), disp.getTransformation(), disp.getViewRange());
|
||||||
|
// Class specific items
|
||||||
|
if (disp instanceof BlockDisplay bd) {
|
||||||
|
this.blockDisp = bd.getBlock();
|
||||||
|
} else if (disp instanceof ItemDisplay id) {
|
||||||
|
itemDisp = id.getItemStack();
|
||||||
|
} else if (disp instanceof TextDisplay td) {
|
||||||
|
textDisp = new TextDisplayRec(td.getText(), td.getAlignment(), td.getBackgroundColor(),
|
||||||
|
td.getFacing(), td.getLineWidth(), td.getTextOpacity(), td.isShadowed(), td.isSeeThrough(),
|
||||||
|
td.isDefaultBackground());
|
||||||
|
}
|
||||||
|
|
||||||
|
// , getBrightness, getDisplayHeight, getDisplayWidth, getGlowColorOverride, getInterpolationDelay, getInterpolationDuration,
|
||||||
|
//getShadowRadius, getShadowStrength, getTeleportDuration, getTransformation, getViewRange, setBillboard, setBrightness,
|
||||||
|
// setDisplayHeight, setDisplayWidth, setGlowColorOverride, setInterpolationDelay, setInterpolationDuration, setShadowRadius, setShadowStrength, setTeleportDuration, setTransformation, setTransformationMatrix, setViewRange
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets any display entity properties to the location, e.g. holograms
|
||||||
|
* @param pos location
|
||||||
|
*/
|
||||||
|
public void setDisplay(Location pos) {
|
||||||
|
World world = pos.getWorld();
|
||||||
|
Display d = null;
|
||||||
|
if (this.blockDisp != null) {
|
||||||
|
// Block Display
|
||||||
|
d = world.spawn(pos, BlockDisplay.class);
|
||||||
|
((BlockDisplay) d).setBlock(this.blockDisp);
|
||||||
|
} else if (this.itemDisp != null) {
|
||||||
|
// Item Display
|
||||||
|
d = world.spawn(pos, ItemDisplay.class);
|
||||||
|
((ItemDisplay) d).setItemStack(itemDisp);
|
||||||
|
} else if (this.textDisp != null) {
|
||||||
|
// Block Display
|
||||||
|
d = world.spawn(pos, TextDisplay.class);
|
||||||
|
((TextDisplay) d).setText(textDisp.text());
|
||||||
|
((TextDisplay) d).setAlignment(textDisp.alignment());
|
||||||
|
((TextDisplay) d).setBackgroundColor(textDisp.bgColor());
|
||||||
|
((TextDisplay) d).setLineWidth(textDisp.lWidth());
|
||||||
|
((TextDisplay) d).setTextOpacity(textDisp.opacity());
|
||||||
|
((TextDisplay) d).setShadowed(textDisp.isShadowed());
|
||||||
|
((TextDisplay) d).setSeeThrough(textDisp.isSeeThrough());
|
||||||
|
((TextDisplay) d).setBackgroundColor(textDisp.bgColor());
|
||||||
|
}
|
||||||
|
if (d != null && this.displayRec != null) {
|
||||||
|
d.setBillboard(displayRec.billboard());
|
||||||
|
d.setBrightness(displayRec.brightness());
|
||||||
|
d.setDisplayHeight(displayRec.height());
|
||||||
|
d.setDisplayWidth(displayRec.width());
|
||||||
|
d.setGlowColorOverride(displayRec.glowColorOverride());
|
||||||
|
d.setInterpolationDelay(displayRec.interpolationDelay());
|
||||||
|
d.setInterpolationDuration(displayRec.interpolationDuration());
|
||||||
|
d.setShadowRadius(displayRec.shadowRadius());
|
||||||
|
d.setShadowStrength(displayRec.shadowStrength());
|
||||||
|
d.setTeleportDuration(displayRec.teleportDuration());
|
||||||
|
d.setTransformation(displayRec.transformation());
|
||||||
|
d.setViewRange(displayRec.range());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the displayRec
|
||||||
|
*/
|
||||||
|
public DisplayRec getDisplayRec() {
|
||||||
|
return displayRec;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param displayRec the displayRec to set
|
||||||
|
*/
|
||||||
|
public void setDisplayRec(DisplayRec displayRec) {
|
||||||
|
this.displayRec = displayRec;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the blockDisp
|
||||||
|
*/
|
||||||
|
public BlockData getBlockDisp() {
|
||||||
|
return blockDisp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param blockDisp the blockDisp to set
|
||||||
|
*/
|
||||||
|
public void setBlockDisp(BlockData blockDisp) {
|
||||||
|
this.blockDisp = blockDisp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the itemDisp
|
||||||
|
*/
|
||||||
|
public ItemStack getItemDisp() {
|
||||||
|
return itemDisp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param itemDisp the itemDisp to set
|
||||||
|
*/
|
||||||
|
public void setItemDisp(ItemStack itemDisp) {
|
||||||
|
this.itemDisp = itemDisp;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ import com.google.gson.stream.JsonWriter;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Minecraft 1.20 changed GRASS to SHORT_GRASS. This class provides and backwards compatibility when loading
|
* Minecraft 1.20 changed GRASS to SHORT_GRASS. This class provides and backwards compatibility when loading
|
||||||
* databased files stored with previous versions. It can be extended in the future if further enum changes are made.
|
* database files stored with previous versions. It can be extended in the future if further enum changes are made.
|
||||||
* @author tastybento
|
* @author tastybento
|
||||||
* @since 2.0.0
|
* @since 2.0.0
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package world.bentobox.bentobox.hooks;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
import world.bentobox.bentobox.BentoBox;
|
||||||
|
import world.bentobox.bentobox.api.hooks.Hook;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides copy and pasting of FancyHolograms in blueprints
|
||||||
|
*
|
||||||
|
* @author tastybento
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public class FancyHologramsHook extends Hook {
|
||||||
|
|
||||||
|
public FancyHologramsHook() {
|
||||||
|
super("FancyHolograms", Material.END_PORTAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hook() {
|
||||||
|
boolean hooked = this.isPluginAvailable();
|
||||||
|
if (!hooked) {
|
||||||
|
BentoBox.getInstance().logError("Could not hook into FancyHolograms");
|
||||||
|
}
|
||||||
|
return hooked; // The hook process shouldn't fail
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFailureCause() {
|
||||||
|
return null; // The hook process shouldn't fail
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -189,6 +189,8 @@ public class DefaultPasteUtil {
|
|||||||
* @return true if Bukkit entity spawned, false another plugin entity spawned
|
* @return true if Bukkit entity spawned, false another plugin entity spawned
|
||||||
*/
|
*/
|
||||||
static boolean spawnBlueprintEntity(BlueprintEntity k, Location location, Island island) {
|
static boolean spawnBlueprintEntity(BlueprintEntity k, Location location, Island island) {
|
||||||
|
// Display Entity (holograms, etc.)
|
||||||
|
k.setDisplay(location);
|
||||||
// FancyNpc entity
|
// FancyNpc entity
|
||||||
if (k.getNpc() != null
|
if (k.getNpc() != null
|
||||||
&& plugin.getHooks().getHook("FancyNpcs").filter(mmh -> mmh instanceof FancyNpcsHook).map(mmh -> {
|
&& plugin.getHooks().getHook("FancyNpcs").filter(mmh -> mmh instanceof FancyNpcsHook).map(mmh -> {
|
||||||
|
@ -25,6 +25,8 @@ softdepend:
|
|||||||
- EconomyPlus
|
- EconomyPlus
|
||||||
- MythicMobs
|
- MythicMobs
|
||||||
- ZNPCsPlus
|
- ZNPCsPlus
|
||||||
|
- FancyNpcs
|
||||||
|
- FancyHolograms
|
||||||
|
|
||||||
libraries:
|
libraries:
|
||||||
- mysql:mysql-connector-java:${mysql.version}
|
- mysql:mysql-connector-java:${mysql.version}
|
||||||
|
Loading…
Reference in New Issue
Block a user