Skip to content

Commit

Permalink
Partially compatible with BlobLib 1.697.6
Browse files Browse the repository at this point in the history
Missing updating deprecated BlobLib API method calls
  • Loading branch information
anjoismysign committed Oct 10, 2023
1 parent 233b51c commit 321da1b
Show file tree
Hide file tree
Showing 48 changed files with 1,521 additions and 280 deletions.
4 changes: 2 additions & 2 deletions buildNumber.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#maven.buildNumber.plugin properties file
#Fri Jun 16 10:07:46 CST 2023
buildNumber0=132
#Mon Oct 09 19:01:32 CST 2023
buildNumber0=6
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>us.mytheria</groupId>
<artifactId>BlobDesign</artifactId>
<version>1.0</version>
<version>1.2.1</version>
<packaging>jar</packaging>

<name>BlobDesign</name>
Expand Down Expand Up @@ -93,7 +93,7 @@
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${testServer}/plugins/</outputDirectory>
<destFileName>BlobDesign-${project.version}.jar</destFileName>
<destFileName>${project.name}-${project.version}.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
Expand Down Expand Up @@ -128,7 +128,7 @@
<dependency>
<groupId>us.mytheria</groupId>
<artifactId>bloblib</artifactId>
<version>1.690.1bs</version>
<version>1.697.6</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
27 changes: 16 additions & 11 deletions src/main/java/us/mytheria/blobdesign/BlobDesign.java
Original file line number Diff line number Diff line change
@@ -1,36 +1,41 @@
package us.mytheria.blobdesign;

import org.jetbrains.annotations.NotNull;
import us.mytheria.blobdesign.director.DesignManagerDirector;
import us.mytheria.blobdesign.director.command.DisplayEditor;
import us.mytheria.blobdesign.director.command.DisplayElementAssetCmd;
import us.mytheria.blobdesign.director.command.DisplaySpawner;
import us.mytheria.bloblib.entities.proxy.BlobProxifier;
import us.mytheria.blobdesign.director.command.HeadPresetBlock;
import us.mytheria.bloblib.entities.PluginUpdater;
import us.mytheria.bloblib.managers.BlobPlugin;
import us.mytheria.bloblib.managers.IManagerDirector;

public class BlobDesign extends BlobPlugin {
protected DesignManagerDirector director;
private IManagerDirector proxy;
private PluginUpdater updater;

protected static BlobDesign instance;

@Override
public void onEnable() {
instance = this;
director = new DesignManagerDirector(this);
proxy = BlobProxifier.PROXY(director);
new DisplaySpawner(this, director);
new DisplayEditor(this, director);
new DisplayElementAssetCmd(this, director);
}

@Override
public void onDisable() {
unregisterFromBlobLib();
director.unload();
proxy = director.proxy();
updater = generateGitHubUpdater("anjoismysign", "BlobDesign");
new DisplaySpawner(director);
new DisplayEditor(director);
new DisplayElementAssetCmd(director);
new HeadPresetBlock(director);
}

public IManagerDirector getManagerDirector() {
return proxy;
}

@Override
@NotNull
public PluginUpdater getPluginUpdater() {
return updater;
}
}
53 changes: 51 additions & 2 deletions src/main/java/us/mytheria/blobdesign/BlobDesignAPI.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package us.mytheria.blobdesign;

import org.bukkit.persistence.PersistentDataContainer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import us.mytheria.blobdesign.director.DesignManagerDirector;
import us.mytheria.blobdesign.entities.BlockDisplayPreset;
import us.mytheria.blobdesign.entities.ItemDisplayPreset;
import us.mytheria.blobdesign.entities.*;
import us.mytheria.blobdesign.entities.element.DisplayElementType;
import us.mytheria.blobdesign.entities.inventory.InventoryType;
import us.mytheria.bloblib.entities.inventory.BlobInventory;

Expand Down Expand Up @@ -54,4 +55,52 @@ public static ItemDisplayPreset getItemDisplayPreset(String key) {
return director().getItemDisplayAssetDirector()
.getObjectManager().getObject(key);
}

/**
* Will get a DisplayPreset for the given type and preset key.
*
* @param type the type of preset
* @param presetKey the key of the preset
* @return the DisplayPreset for the given type and preset key
*/
@Nullable
public static DisplayPreset<?> getPreset(DisplayElementType type,
String presetKey) {
switch (type) {
case BLOCK_DISPLAY -> {
return getBlockDisplayPreset(presetKey);
}
case ITEM_DISPLAY -> {
return getItemDisplayPreset(presetKey);
}
default -> {
return null;
}
}
}

/**
* Will get a DisplayPreset for the given PresetData.
*
* @param presetData the PresetData to get the PresetPlacer for
* @return the DisplayPreset for the given PresetData
*/
@Nullable
public static DisplayPreset<?> getPreset(PresetData presetData) {
return getPreset(presetData.type(), presetData.key());
}

/**
* Will deserialize a DisplayPreset from the given PersistentDataContainer.
*
* @param container the container to deserialize from
* @return the DisplayPreset deserialized from the given container
*/
@Nullable
public static DisplayPreset<?> deserializePreset(PersistentDataContainer container) {
PresetPlacer placer = PresetPlacer.deserialize(container, director().getPluginOperator());
if (placer == null)
return null;
return getPreset(placer.getPresetData());
}
}
Original file line number Diff line number Diff line change
@@ -1,55 +1,40 @@
package us.mytheria.blobdesign.director;

import us.mytheria.blobdesign.BlobDesign;
import us.mytheria.blobdesign.director.manager.ConfigManager;
import us.mytheria.blobdesign.director.manager.DisplayElementAssetDirector;
import us.mytheria.blobdesign.director.manager.InventoryManager;
import us.mytheria.blobdesign.director.manager.ListenerManager;
import us.mytheria.blobdesign.entities.BlockDisplayPresetAsset;
import us.mytheria.blobdesign.entities.ItemDisplayPresetAsset;
import us.mytheria.blobdesign.entities.element.DisplayElementAsset;
import us.mytheria.blobdesign.entities.inventory.BlockDisplayBuilder;
import us.mytheria.blobdesign.entities.inventory.ItemDisplayBuilder;
import us.mytheria.blobdesign.entities.proxy.BlockDisplayPresetAssetProxy;
import us.mytheria.blobdesign.entities.proxy.DesignProxier;
import us.mytheria.blobdesign.entities.proxy.ItemDisplayPresetAssetProxy;
import us.mytheria.blobdesign.director.manager.*;
import us.mytheria.bloblib.entities.GenericManagerDirector;
import us.mytheria.bloblib.entities.ObjectDirector;
import us.mytheria.bloblib.entities.ObjectDirectorData;

public class DesignManagerDirector extends GenericManagerDirector<BlobDesign> {
private final BlockDisplayPresetAssetDirector blockDisplayAssetDirector;
private ItemDisplayPresetAssetDirector itemDisplayAssetDirector;
private DisplayElementAssetDirector displayElementAssetDirector;
private PresetBlockAssetDirector presetBlockAssetDirector;

public DesignManagerDirector(BlobDesign plugin) {
super(plugin);
registerAndUpdateBlobInventory("BlockDisplayEditor");
registerAndUpdateBlobInventory("BlockDisplayNavigator");
registerAndUpdateBlobInventory("ItemDisplayEditor");
registerAndUpdateBlobInventory("ItemDisplayNavigator");
registerBlobInventory("BlockDisplayEditor",
"BlockDisplayNavigator",
"ItemDisplayEditor",
"ItemDisplayNavigator");
addManager("ConfigManager", new ConfigManager(this));
addManager("InventoryManager", new InventoryManager(this));
addManager("ListenerManager", new ListenerManager(this));
addDirector("BlockDisplay", file ->
DesignProxier.PROXY(BlockDisplayPresetAsset.fromFile(file, this)));
getBlockDisplayAssetDirector().getBuilderManager()
.setBuilderBiFunction((uuid, objectDirector) ->
BlockDisplayBuilder.build(uuid, objectDirector,
this));
this.blockDisplayAssetDirector = new BlockDisplayPresetAssetDirector(this);
this.addManager("BlockDisplayDirector",
blockDisplayAssetDirector);
getBlockDisplayAssetDirector().whenObjectManagerFilesLoad(blockDisplayAssetObjectManager -> {
addDirector("ItemDisplay", file -> DesignProxier
.PROXY(ItemDisplayPresetAsset.fromFile(file, this)));
getItemDisplayAssetDirector().getBuilderManager()
.setBuilderBiFunction((uuid, objectDirector) ->
ItemDisplayBuilder.build(uuid, objectDirector,
this));
getItemDisplayAssetDirector().whenObjectManagerFilesLoad(itemDisplayAssetObjectManager -> {
String objectName = "DisplayElement";
ObjectDirectorData quickWarpData = ObjectDirectorData.simple(this.getRealFileManager(), objectName);
DesignManagerDirector.this.displayElementAssetDirector = new DisplayElementAssetDirector(this,
quickWarpData, file ->
DisplayElementAsset.fromFile(file, this));
this.addManager(objectName + "Director",
itemDisplayAssetDirector = new ItemDisplayPresetAssetDirector(this);
this.addManager("ItemDisplayDirector",
itemDisplayAssetDirector);
getItemDisplayAssetDirector().whenObjectManagerFilesLoad(displayAssetProxy -> {
displayElementAssetDirector = new DisplayElementAssetDirector(this);
this.addManager("DisplayElementDirector",
displayElementAssetDirector);
getDisplayElementAssetDirector().whenObjectManagerFilesLoad(displayElement -> {
presetBlockAssetDirector = new PresetBlockAssetDirector(this);
this.addManager("PresetBlockDirector",
presetBlockAssetDirector);
});
});
});
}
Expand All @@ -60,9 +45,14 @@ public DesignManagerDirector(BlobDesign plugin) {
@Override
public void reload() {
getBlockDisplayAssetDirector().reload();
getBlockDisplayAssetDirector().whenObjectManagerFilesLoad(blockDisplayAssetObjectManager -> {
getBlockDisplayAssetDirector().whenObjectManagerFilesLoad(blockDisplay -> {
getItemDisplayAssetDirector().reload();
getItemDisplayAssetDirector().whenObjectManagerFilesLoad(itemDisplayAssetObjectManager -> getDisplayElementAssetDirector().reload());
getItemDisplayAssetDirector().whenObjectManagerFilesLoad(itemDisplay -> {
getDisplayElementAssetDirector().reload();
getDisplayElementAssetDirector().whenObjectManagerFilesLoad(displayElement -> {
getPresetBlockAssetDirector().reload();
});
});
});
}

Expand All @@ -71,18 +61,22 @@ public void unload() {
getDisplayElementAssetDirector().unload();
}

public final ObjectDirector<BlockDisplayPresetAssetProxy> getBlockDisplayAssetDirector() {
return getDirector("BlockDisplay", BlockDisplayPresetAssetProxy.class);
public final BlockDisplayPresetAssetDirector getBlockDisplayAssetDirector() {
return blockDisplayAssetDirector;
}

public final ObjectDirector<ItemDisplayPresetAssetProxy> getItemDisplayAssetDirector() {
return getDirector("ItemDisplay", ItemDisplayPresetAssetProxy.class);
public final ItemDisplayPresetAssetDirector getItemDisplayAssetDirector() {
return itemDisplayAssetDirector;
}

public final DisplayElementAssetDirector getDisplayElementAssetDirector() {
return displayElementAssetDirector;
}

public final PresetBlockAssetDirector getPresetBlockAssetDirector() {
return presetBlockAssetDirector;
}

public final ConfigManager getConfigManager() {
return getManager("ConfigManager", ConfigManager.class);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.bukkit.entity.BlockDisplay;
import org.bukkit.entity.ItemDisplay;
import org.bukkit.entity.Player;
import us.mytheria.blobdesign.BlobDesign;
import us.mytheria.blobdesign.director.DesignManagerDirector;
import us.mytheria.blobdesign.director.manager.InventoryManager;
import us.mytheria.bloblib.BlobLibAssetAPI;
Expand All @@ -13,8 +12,8 @@
import java.util.List;

public class DisplayEditor extends BlobExecutor {
public DisplayEditor(BlobDesign plugin, DesignManagerDirector director) {
super(plugin, "displayeditor");
public DisplayEditor(DesignManagerDirector director) {
super(director.getPlugin(), "displayeditor");
setCommand((sender, args) -> {
if (!hasAdminPermission(sender))
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package us.mytheria.blobdesign.director.command;

import us.mytheria.blobdesign.BlobDesign;
import us.mytheria.blobdesign.director.DesignManagerDirector;
import us.mytheria.bloblib.BlobLibAssetAPI;
import us.mytheria.bloblib.entities.BlobExecutor;

import java.util.List;

public class DisplayElementAssetCmd extends BlobExecutor {
public DisplayElementAssetCmd(BlobDesign plugin, DesignManagerDirector director) {
super(plugin, "dilement");
public DisplayElementAssetCmd(DesignManagerDirector director) {
super(director.getPlugin(), "dilement");
setCommand((sender, args) -> {
if (!hasAdminPermission(sender))
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package us.mytheria.blobdesign.director.command;

import org.bukkit.entity.Player;
import us.mytheria.blobdesign.BlobDesign;
import us.mytheria.blobdesign.director.DesignManagerDirector;
import us.mytheria.blobdesign.entities.BlockDisplayPreset;
import us.mytheria.blobdesign.entities.ItemDisplayPreset;
Expand All @@ -13,8 +12,8 @@
import java.util.stream.Collectors;

public class DisplaySpawner extends BlobExecutor {
public DisplaySpawner(BlobDesign plugin, DesignManagerDirector director) {
super(plugin, "displayspawner");
public DisplaySpawner(DesignManagerDirector director) {
super(director.getPlugin(), "displayspawner");
setCommand((sender, args) -> {
if (!hasAdminPermission(sender))
return true;
Expand Down
Loading

0 comments on commit 321da1b

Please sign in to comment.