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
Showing
23 changed files
with
252 additions
and
34 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
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
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
13 changes: 13 additions & 0 deletions
13
FurnitureLib-Core/src/main/java/de/Ste3et_C0st/FurnitureLib/Utilitis/ServerFunction.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,13 @@ | ||
package de.Ste3et_C0st.FurnitureLib.Utilitis; | ||
|
||
import java.util.List; | ||
|
||
import org.bukkit.inventory.ItemStack; | ||
|
||
import net.md_5.bungee.api.chat.BaseComponent; | ||
|
||
public interface ServerFunction { | ||
public ItemStack displayName(ItemStack stack, BaseComponent[] baseComponent); | ||
public ItemStack lore(ItemStack stack, List<BaseComponent[]> component); | ||
public void onEnable(); | ||
} |
44 changes: 44 additions & 0 deletions
44
FurnitureLib-Core/src/main/java/de/Ste3et_C0st/FurnitureLib/Utilitis/SpigotFunctions.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,44 @@ | ||
package de.Ste3et_C0st.FurnitureLib.Utilitis; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.inventory.meta.ItemMeta; | ||
|
||
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib; | ||
import net.kyori.adventure.text.Component; | ||
import net.kyori.adventure.text.minimessage.MiniMessage; | ||
import net.kyori.adventure.text.serializer.bungeecord.BungeeComponentSerializer; | ||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; | ||
import net.md_5.bungee.api.chat.BaseComponent; | ||
|
||
public class SpigotFunctions implements ServerFunction{ | ||
|
||
@Override | ||
public ItemStack displayName(ItemStack stack, BaseComponent[] component) { | ||
ItemMeta meta = stack.getItemMeta(); | ||
meta.setDisplayName(convertToLegacy(BungeeComponentSerializer.get().deserialize(component))); | ||
stack.setItemMeta(meta); | ||
return stack; | ||
} | ||
|
||
@Override | ||
public ItemStack lore(ItemStack stack, List<BaseComponent[]> component) { | ||
List<String> legacyLore = component.stream().map(BungeeComponentSerializer.get()::deserialize).map(this::convertToLegacy).collect(Collectors.toList()); | ||
ItemMeta meta = stack.getItemMeta(); | ||
meta.setLore(legacyLore); | ||
stack.setItemMeta(meta); | ||
return stack; | ||
} | ||
|
||
private String convertToLegacy(Component component) { | ||
return LegacyComponentSerializer.legacyAmpersand().serialize(component); | ||
} | ||
|
||
@Override | ||
public void onEnable() { | ||
FurnitureLib.debug("SpigotFunctions created"); | ||
} | ||
|
||
} |
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
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
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
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
29 changes: 29 additions & 0 deletions
29
FurnitureLib-Folia/src/main/java/de/Ste3et_C0st/FurnitureLib/Folia/FoliaFunctions.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,29 @@ | ||
package de.Ste3et_C0st.FurnitureLib.Folia; | ||
|
||
import java.util.List; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
import de.Ste3et_C0st.FurnitureLib.Utilitis.ServerFunction; | ||
import de.Ste3et_C0st.FurnitureLib.main.FurnitureLib; | ||
import net.md_5.bungee.api.chat.BaseComponent; | ||
|
||
public class FoliaFunctions implements ServerFunction{ | ||
|
||
@Override | ||
public ItemStack displayName(ItemStack stack, BaseComponent[] baseComponents) { | ||
stack.editMeta(meta -> meta.setDisplayNameComponent(baseComponents)); | ||
return stack; | ||
} | ||
|
||
@Override | ||
public ItemStack lore(ItemStack stack, List<BaseComponent[]> baseComponents) { | ||
stack.editMeta(meta -> meta.setLoreComponents(baseComponents)); | ||
return stack; | ||
} | ||
|
||
@Override | ||
public void onEnable() { | ||
FurnitureLib.debug("FoliaFunctions created"); | ||
} | ||
|
||
} |
Oops, something went wrong.