Update itembuilder with custom model data support

This commit is contained in:
Ryder Belserion 2024-03-20 12:26:42 -04:00
parent 35768c9e34
commit 1fa748215c
No known key found for this signature in database
21 changed files with 1809 additions and 453 deletions

View File

@ -1,7 +1,7 @@
import org.gradle.kotlin.dsl.support.uppercaseFirstChar
plugins {
id("root-plugin")
`root-plugin`
}
tasks {

View File

@ -2,14 +2,13 @@ plugins {
`kotlin-dsl`
}
dependencies {
implementation(libs.paperweight)
implementation(libs.shadowjar)
implementation(libs.runpaper)
implementation(libs.modrinth)
implementation(libs.hangar)
repositories {
gradlePluginPortal()
mavenCentral()
}
dependencies {
implementation(libs.paperweight.userdev)
implementation(libs.publishing.modrinth)
implementation(libs.publishing.hangar)
}

View File

@ -1,14 +1,9 @@
dependencyResolutionManagement {
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
gradlePluginPortal()
mavenCentral()
}
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
rootProject.name = "buildSrc"

View File

@ -2,10 +2,6 @@ plugins {
id("root-plugin")
}
base {
archivesName.set(rootProject.name)
}
val mcVersion = providers.gradleProperty("mcVersion").get()
val fabricVersion = providers.gradleProperty("version").get()

View File

@ -1,15 +1,7 @@
plugins {
id("io.papermc.paperweight.userdev")
id("xyz.jpenilla.run-paper")
id("root-plugin")
}
base {
archivesName.set(rootProject.name)
}
repositories {
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
@ -19,7 +11,7 @@ repositories {
maven("https://repo.triumphteam.dev/snapshots/")
maven("https://repo.oraxen.com/releases/")
maven("https://repo.fancyplugins.de/releases/")
flatDir { dirs("libs") }
}
@ -28,33 +20,7 @@ val mcVersion = providers.gradleProperty("mcVersion").get()
project.version = if (System.getenv("BUILD_NUMBER") != null) "${rootProject.version}-${System.getenv("BUILD_NUMBER")}" else rootProject.version
dependencies {
paperweight.paperDevBundle("$mcVersion-R0.1-SNAPSHOT")
}
tasks {
assemble {
dependsOn(reobfJar)
}
runServer {
jvmArgs("-Dnet.kyori.ansi.colorLevel=truecolor")
defaultCharacterEncoding = Charsets.UTF_8.name()
plugins {
downloadPlugins {
url("https://ci.ender.zone/job/EssentialsX/lastSuccessfulBuild/artifact/jars/EssentialsX-2.21.0-dev+70-c19b20e.jar")
url("https://ci.lucko.me/job/TinyVault/lastSuccessfulBuild/artifact/build/libs/Vault.jar")
url("https://download.luckperms.net/1532/bukkit/loader/LuckPerms-Bukkit-5.4.119.jar")
}
}
minecraftVersion(mcVersion)
}
modrinth {
loaders.addAll("paper", "purpur")
}

View File

@ -1,27 +1,17 @@
import gradle.kotlin.dsl.accessors._8291d1211fdf2e346e0abe66afb65704.idea
import io.papermc.hangarpublishplugin.model.Platforms
import org.gradle.kotlin.dsl.support.uppercaseFirstChar
import java.io.ByteArrayOutputStream
plugins {
id("io.papermc.hangar-publish-plugin")
id("com.github.johnrengelman.shadow")
id("com.modrinth.minotaur")
`java-library`
`maven-publish`
idea
}
idea {
module {
isDownloadJavadoc = true
isDownloadSources = true
}
base {
archivesName.set(rootProject.name)
}
repositories {
@ -34,44 +24,10 @@ repositories {
mavenCentral()
}
// The commit id for the "main" branch prior to merging a pull request.
/*val start = "e888a19"
// The commit id BEFORE merging the pull request so before "Merge pull request #30"
val end = "f78f454"
val commitLog = getGitHistory().joinToString(separator = "") { formatGitLog(it) }
fun getGitHistory(): List<String> {
val output: String = ByteArrayOutputStream().use { outputStream ->
project.exec {
executable("git")
args("log", "$start..$end", "--format=format:%h %s")
standardOutput = outputStream
java {
toolchain.languageVersion.set(JavaLanguageVersion.of("17"))
}
outputStream.toString()
}
return output.split("\n")
}
fun formatGitLog(commitLog: String): String {
val hash = commitLog.take(7)
val message = commitLog.substring(8) // Get message after commit hash + space between
return "[$hash](https://github.com/Crazy-Crew/${rootProject.name}/commit/$hash) $message<br>"
}*/
val changes = """
${rootProject.file("CHANGELOG.md").readText(Charsets.UTF_8)}
## Commits
<details>
<summary>Other</summary>
commitLog
</details>
""".trimIndent()
tasks {
compileJava {
options.encoding = Charsets.UTF_8.name()
@ -86,12 +42,6 @@ tasks {
filteringCharset = Charsets.UTF_8.name()
}
shadowJar {
archiveClassifier.set("")
exclude("META-INF/**")
}
val directory = File("$rootDir/jars/${project.name.lowercase()}")
val mcVersion = providers.gradleProperty("mcVersion").get()
@ -107,7 +57,7 @@ tasks {
channel.set(type)
changelog.set(changes)
changelog.set(rootProject.file("CHANGELOG.md").readText(Charsets.UTF_8))
apiKey.set(System.getenv("hangar_key"))
@ -130,7 +80,7 @@ tasks {
projectId.set(rootProject.name.lowercase())
changelog.set(changes)
changelog.set(rootProject.file("CHANGELOG.md").readText(Charsets.UTF_8))
versionName.set("${rootProject.name} ${project.version}")
@ -141,7 +91,3 @@ tasks {
gameVersions.add(mcVersion)
}
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of("17"))
}

View File

@ -8,9 +8,9 @@ website = https://modrinth.com/plugin/crazyauctions
sources = https://github.com/Crazy-Crew/CrazyAuctions
issues = https://github.com/Crazy-Crew/CrazyAuctions/issues
group = com.ryderbelserion.crazyauctions
group = com.badbones69.crazyauctions
description = Auction off items in style.
version = 1.3.3
version = 1.4
apiVersion = 1.20
mcVersion = 1.20.4

View File

@ -1,28 +1,41 @@
[versions]
kyori_version = "4.14.0"
shadow_version = "8.1.1"
paperweight_version = "1.5.9"
runpaper_version = "2.2.3"
modrinth_version = "2.8.7"
hangar_version = "0.1.2"
[plugins]
hangar = { id = "io.papermc.hangar-publish-plugin", version.ref = "hangar_version" }
modrinth = { id = "com.modrinth.minotaur", version.ref = "modrinth_version" }
run-paper = { id = "xyz.jpenilla.run-paper", version = "2.2.3" }
shadow = { id = "com.github.johnrengelman.shadow", version = "8.1.1" }
paperweight = { id = "io.papermc.paperweight.userdev", version.ref = "paperweight_version" }
runpaper = { id = "xyz.jpenilla.run-paper", version.ref = "runpaper_version" }
shadowjar = { id = "com.github.johnrengelman.shadow", version.ref = "shadow_version" }
[versions]
kyori = "4.16.0"
bundle = "1.20.4-R0.1-SNAPSHOT"
cluster = "1.0-SNAPSHOT"
[libraries]
adventure = { module = "net.kyori:adventure-api", version.ref = "kyori_version" }
minimessage = { module = "net.kyori:adventure-text-minimessage", version.ref = "kyori_version" }
simple-yaml = { group = "com.github.Carleslc.Simple-YAML", name = "Simple-Yaml", version = "1.8.4" }
paperweight = { module = "io.papermc.paperweight:paperweight-userdev", version.ref = "paperweight_version" }
shadowjar = { module = "com.github.johnrengelman:shadow", version.ref = "shadow_version" }
runpaper = { module = "xyz.jpenilla:run-task", version.ref = "runpaper_version" }
minimessage-api = { group = "net.kyori", name = "adventure-text-minimessage", version.ref = "kyori" }
adventure-api = { group = "net.kyori", name = "adventure-api", version.ref = "kyori" }
hangar = { module = "io.papermc:hangar-publish-plugin", version.ref = "hangar_version" }
modrinth = { module = "com.modrinth.minotaur:Minotaur", version.ref = "modrinth_version" }
itemsadder-api = { group = "com.github.LoneDev6", name = "api-itemsadder", version = "3.6.1" }
oraxen-api = { group = "io.th0rgal", name = "oraxen", version = "1.171.0" }
placeholder-api = { group = "me.clip", name = "placeholderapi", version = "2.11.5" }
head-database-api = { group = "com.arcaniax", name = "HeadDatabase-API", version = "1.3.1" }
paperweight-userdev = { group = "io.papermc.paperweight.userdev", name = "io.papermc.paperweight.userdev.gradle.plugin", version = "1.5.11" }
publishing-modrinth = { group = "com.modrinth.minotaur", name = "Minotaur", version = "2.8.7" }
publishing-hangar = { group = "io.papermc", name = "hangar-publish-plugin", version = "0.1.2" }
cluster-api = { group = "com.ryderbelserion.cluster", name = "api", version.ref = "cluster" }
cluster-paper = { group = "com.ryderbelserion.cluster", name = "paper", version.ref = "cluster" }
fancy-holograms = { group = "de.oliver", name = "FancyHolograms", version = "2.0.6" }
decent-holograms = { group = "com.github.decentsoftware-eu", name = "decentholograms", version = "2.8.6" }
triumph-cmds = { group = "dev.triumphteam", name = "triumph-cmd-bukkit", version = "2.0.0-ALPHA-9" }
triumph-gui = { group = "dev.triumphteam", name = "triumph-gui", version = "3.1.7" }
vault = { group = "com.github.MilkBowl", name = "VaultAPI", version = "1.7.1" }
metrics = { group = "org.bstats", name = "bstats-bukkit", version = "3.0.2" }
config-me = { group = "ch.jalu", name = "configme", version = "1.4.1" }
[bundles]
adventure = ["minimessage-api", "adventure-api"]
holograms = ["fancy-holograms", "decent-holograms"]
triumph = ["triumph-cmds", "triumph-gui"]

View File

@ -1,22 +1,56 @@
plugins {
id("paper-plugin")
`paper-plugin`
id("io.papermc.paperweight.userdev")
alias(libs.plugins.run.paper)
alias(libs.plugins.shadow)
}
repositories {
maven("https://repo.oraxen.com/releases/")
}
dependencies {
implementation(project(":common"))
paperweight.paperDevBundle(libs.versions.bundle)
implementation(libs.metrics)
compileOnly(libs.vault) {
exclude("org.bukkit", "bukkit")
}
compileOnly(libs.placeholder.api)
compileOnly(libs.oraxen.api)
compileOnly(libs.vault)
compileOnly(fileTree("libs").include("*.jar"))
}
tasks {
assemble {
dependsOn(reobfJar)
}
runServer {
jvmArgs("-Dnet.kyori.ansi.colorLevel=truecolor")
defaultCharacterEncoding = Charsets.UTF_8.name()
downloadPlugins {
url("https://github.com/EssentialsX/Essentials/releases/download/2.20.1/EssentialsX-2.20.1.jar")
url("https://ci.lucko.me/job/TinyVault/lastSuccessfulBuild/artifact/build/libs/Vault.jar")
url("https://download.luckperms.net/1532/bukkit/loader/LuckPerms-Bukkit-5.4.119.jar")
}
minecraftVersion("1.20.4")
}
shadowJar {
listOf(
//"com.ryderbelserion.cluster",
//"dev.triumphteam.cmd",
//"dev.triumphteam.gui",
"org.bstats"
).forEach {
relocate(it, "libs.$it")

View File

@ -1,5 +1,5 @@
#Minecraft server properties
#Tue Mar 05 18:52:30 EST 2024
#Wed Mar 20 12:17:37 EDT 2024
enable-jmx-monitoring=false
rcon.port=25575
level-seed=

View File

@ -44,145 +44,6 @@ public class Methods {
return ChatColor.stripColor(msg);
}
public static ItemStack makeItem(String type, int amount) {
int ty = 0;
if (type.contains(":")) {
String[] b = type.split(":");
type = b[0];
ty = Integer.parseInt(b[1]);
}
Material m = Material.matchMaterial(type);
ItemStack item;
try {
item = new ItemStack(m, amount, (short) ty);
} catch (Exception e) {
item = new ItemStack(Material.RED_TERRACOTTA);
}
return item;
}
public static ItemStack makeItem(String type, int amount, String name) {
int ty = 0;
if (type.contains(":")) {
String[] b = type.split(":");
type = b[0];
ty = Integer.parseInt(b[1]);
}
Material m = Material.matchMaterial(type);
ItemStack item;
try {
item = new ItemStack(m, amount, (short) ty);
} catch (Exception e) {
item = new ItemStack(Material.RED_TERRACOTTA);
}
ItemMeta me = item.getItemMeta();
me.setDisplayName(color(name));
item.setItemMeta(me);
return item;
}
public static ItemStack makeItem(String type, int amount, String name, List<String> lore) {
ArrayList<String> l = new ArrayList<>();
int ty = 0;
if (type.contains(":")) {
String[] b = type.split(":");
type = b[0];
ty = Integer.parseInt(b[1]);
}
Material m = Material.matchMaterial(type);
ItemStack item;
try {
item = new ItemStack(m, amount, (short) ty);
} catch (Exception e) {
item = new ItemStack(Material.RED_TERRACOTTA);
}
ItemMeta me = item.getItemMeta();
me.setDisplayName(color(name));
for (String L : lore) l.add(color(L));
me.setLore(l);
item.setItemMeta(me);
return item;
}
public static ItemStack makeItem(Material material, int amount, int type, String name) {
ItemStack item = new ItemStack(material, amount, (short) type);
ItemMeta m = item.getItemMeta();
m.setDisplayName(color(name));
item.setItemMeta(m);
return item;
}
public static ItemStack makeItem(Material material, int amount, int type, String name, List<String> lore) {
ArrayList<String> l = new ArrayList<>();
ItemStack item = new ItemStack(material, amount, (short) type);
ItemMeta m = item.getItemMeta();
m.setDisplayName(color(name));
for (String L : lore) l.add(color(L));
m.setLore(l);
item.setItemMeta(m);
return item;
}
public static ItemStack makeItem(Material material, int amount, int type, String name, List<String> lore, Map<Enchantment, Integer> enchants) {
ItemStack item = new ItemStack(material, amount, (short) type);
ItemMeta m = item.getItemMeta();
m.setDisplayName(name);
m.setLore(lore);
item.setItemMeta(m);
item.addUnsafeEnchantments(enchants);
return item;
}
public static ItemStack addLore(ItemStack item, String i) {
ArrayList<String> lore = new ArrayList<>();
ItemMeta m = item.getItemMeta();
if (item.getItemMeta().hasLore()) {
lore.addAll(item.getItemMeta().getLore());
}
lore.add(i);
m.setLore(lore);
item.setItemMeta(m);
return item;
}
public static ItemStack addLore(ItemStack item, List<String> list) {
if (item != null && item.getType() != Material.AIR) {
ArrayList<String> lore = new ArrayList<>();
ItemMeta m = item.getItemMeta();
if (item.hasItemMeta() && item.getItemMeta().hasLore()) {
lore.addAll(item.getItemMeta().getLore());
}
for (String i : list) lore.add(color(i));
m.setLore(lore);
item.setItemMeta(m);
}
return item;
}
public static ItemStack getItemInHand(Player player) {
return player.getInventory().getItemInMainHand();
}

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,7 @@ public enum ShopType {
/**
* @param name name of the Shop Type.
*/
private ShopType(String name) {
ShopType(String name) {
this.name = name;
}
@ -23,6 +23,7 @@ public enum ShopType {
return type;
}
}
return null;
}

View File

@ -1,6 +1,7 @@
package com.badbones69.crazyauctions.api.support;
import com.badbones69.crazyauctions.CrazyAuctions;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
public enum PluginSupport {
@ -15,8 +16,7 @@ public enum PluginSupport {
private final String name;
@NotNull
private final CrazyAuctions plugin = CrazyAuctions.get();
private final @NotNull CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
PluginSupport(String name) {
this.name = name;

View File

@ -0,0 +1,189 @@
package com.badbones69.crazyauctions.api.support;
import com.badbones69.crazyauctions.CrazyAuctions;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Skull;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Base64;
import java.util.UUID;
/**
* A library for the Bukkit API to create player skulls
* from names, base64 strings, and texture URLs.
* Does not use any NMS code, and should work across all versions.
*
* @author Dean B on 12/28/2016.
*/
public class SkullCreator {
private static final @NotNull CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class);
/**
* Creates a player skull with a UUID. 1.13 only.
*
* @param id The Player's UUID
* @return The head of the Player
*/
public static ItemStack itemFromUuid(UUID id) {
ItemStack item = getPlayerSkullItem();
return itemWithUuid(item, id);
}
/**
* Creates a player skull based on a UUID. 1.13 only.
*
* @param item The item to apply the name to
* @param id The Player's UUID
* @return The head of the Player
*/
public static ItemStack itemWithUuid(ItemStack item, UUID id) {
notNull(item, "item");
notNull(id, "id");
SkullMeta meta = (SkullMeta) item.getItemMeta();
meta.setOwningPlayer(plugin.getServer().getOfflinePlayer(id));
item.setItemMeta(meta);
return item;
}
/**
* Creates a player skull based on a Mojang server URL.
*
* @param url The URL of the Mojang skin
* @return The head associated with the URL
*/
public static ItemStack itemFromUrl(String url) {
ItemStack item = getPlayerSkullItem();
return itemWithUrl(item, url);
}
/**
* Creates a player skull based on a Mojang server URL.
*
* @param item The item to apply the skin to
* @param url The URL of the Mojang skin
* @return The head associated with the URL
*/
public static ItemStack itemWithUrl(ItemStack item, String url) {
notNull(item, "item");
notNull(url, "url");
return itemWithBase64(item, urlToBase64(url));
}
/**
* Creates a player skull based on a base64 string containing the link to the skin.
*
* @param base64 The base64 string containing the texture
* @return The head with a custom texture
*/
public static ItemStack itemFromBase64(String base64) {
ItemStack item = getPlayerSkullItem();
return itemWithBase64(item, base64);
}
/**
* Applies the base64 string to the ItemStack.
*
* @param item The ItemStack to put the base64 onto
* @param base64 The base64 string containing the texture
* @return The head with a custom texture
*/
public static ItemStack itemWithBase64(ItemStack item, String base64) {
notNull(item, "item");
notNull(base64, "base64");
UUID hashAsId = new UUID(base64.hashCode(), base64.hashCode());
return plugin.getServer().getUnsafe().modifyItemStack(item,
"{SkullOwner:{Id:\"" + hashAsId + "\",Properties:{textures:[{Value:\"" + base64 + "\"}]}}}"
);
}
/**
* Sets the block to a skull with the given UUID.
*
* @param block The block to set
* @param id The player to set it to
*/
public static void blockWithUuid(Block block, UUID id) {
notNull(block, "block");
notNull(id, "id");
setBlockType(block);
((Skull) block.getState()).setOwningPlayer(Bukkit.getOfflinePlayer(id));
}
/**
* Sets the block to a skull with the given UUID.
*
* @param block The block to set
* @param url The mojang URL to set it to use
*/
public static void blockWithUrl(Block block, String url) {
notNull(block, "block");
notNull(url, "url");
blockWithBase64(block, urlToBase64(url));
}
/**
* Sets the block to a skull with the given UUID.
*
* @param block The block to set
* @param base64 The base64 to set it to use
*/
public static void blockWithBase64(Block block, String base64) {
notNull(block, "block");
notNull(base64, "base64");
UUID hashAsId = new UUID(base64.hashCode(), base64.hashCode());
String args = String.format(
"%d %d %d %s",
block.getX(),
block.getY(),
block.getZ(),
"{Owner:{Id:\"" + hashAsId + "\",Properties:{textures:[{Value:\"" + base64 + "\"}]}}}"
);
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "data merge block " + args);
}
private static ItemStack getPlayerSkullItem() {
return new ItemStack(Material.PLAYER_HEAD);
}
private static void setBlockType(Block block) {
block.setType(Material.PLAYER_HEAD, false);
}
private static void notNull(Object instance, String name) {
if (instance == null) {
throw new NullPointerException(name + " should not be null!");
}
}
private static String urlToBase64(String url) {
URI actualUrl;
try {
actualUrl = new URI(url);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
String toEncode = "{\"textures\":{\"SKIN\":{\"url\":\"" + actualUrl + "\"}}}";
return Base64.getEncoder().encodeToString(toEncode.getBytes());
}
}

View File

@ -346,12 +346,10 @@ public class AuctionCommand implements CommandExecutor {
}
}
for (String id : config.getStringList("Settings.BlackList")) {
if (item.getType() == Methods.makeItem(id, 1).getType()) {
if (config.getStringList("Settings.BlackList").contains(item.getType().getKey().getKey())) {
player.sendMessage(Messages.ITEM_BLACKLISTED.getMessage());
return true;
}
}
if (!config.getBoolean("Settings.Allow-Damaged-Items")) {
for (Material i : getDamageableItems()) {

View File

@ -4,6 +4,7 @@ import com.badbones69.crazyauctions.CrazyAuctions;
import com.badbones69.crazyauctions.Methods;
import com.badbones69.crazyauctions.api.*;
import com.badbones69.crazyauctions.api.FileManager.Files;
import com.badbones69.crazyauctions.api.builders.ItemBuilder;
import com.badbones69.crazyauctions.api.enums.Category;
import com.badbones69.crazyauctions.api.enums.Reaons;
import com.badbones69.crazyauctions.api.enums.Messages;
@ -12,6 +13,7 @@ import com.badbones69.crazyauctions.api.events.AuctionBuyEvent;
import com.badbones69.crazyauctions.api.events.AuctionCancelledEvent;
import com.badbones69.crazyauctions.api.events.AuctionNewBidEvent;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.configuration.file.FileConfiguration;
@ -24,7 +26,6 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -72,15 +73,23 @@ public class GuiListener implements Listener {
for (String l : config.getStringList("Settings.GUISettings.Bidding")) {
lore.add(l.replace("%TopBid%", Methods.getPrice(i, false)).replace("%topbid%", Methods.getPrice(i, false)).replace("%Seller%", seller).replace("%seller%", seller).replace("%TopBidder%", topbidder).replace("%topbidder%", topbidder).replace("%Time%", Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire"))).replace("%time%", Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire"))));
}
items.add(Methods.addLore(data.getItemStack("Items." + i + ".Item").clone(), lore));
ID.add(data.getInt("Items." + i + ".StoreID"));
ItemBuilder itemBuilder = ItemBuilder.convertItemStack(data.getItemStack("Items." + i + ".Item"));
lore.forEach(itemBuilder::addLore);
ID.add(data.getInt("Items." + i + ".StoreID"));;
}
} else {
if (sell == ShopType.SELL) {
for (String l : config.getStringList("Settings.GUISettings.SellingItemLore")) {
lore.add(l.replace("%Price%", String.format(Locale.ENGLISH, "%,d", Long.parseLong(Methods.getPrice(i, false)))).replace("%price%", String.format(Locale.ENGLISH, "%,d", Long.parseLong(Methods.getPrice(i, false)))).replace("%Seller%", data.getString("Items." + i + ".Seller")).replace("%seller%", data.getString("Items." + i + ".Seller")).replace("%Time%", Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire"))).replace("%time%", Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire"))));
}
items.add(Methods.addLore(data.getItemStack("Items." + i + ".Item").clone(), lore));
ItemBuilder itemBuilder = ItemBuilder.convertItemStack(data.getItemStack("Items." + i + ".Item"));
lore.forEach(itemBuilder::addLore);
ID.add(data.getInt("Items." + i + ".StoreID"));
}
}
@ -135,13 +144,16 @@ public class GuiListener implements Listener {
int slot = config.getInt("Settings.GUISettings.OtherSettings." + o + ".Slot");
String cName = Methods.color(config.getString("Settings.GUISettings.Category-Settings." + shopCategory.get(player.getUniqueId()).getName() + ".Name"));
ItemBuilder itemBuilder = new ItemBuilder().setMaterial(id).setName(name).setAmount(1);
if (config.contains("Settings.GUISettings.OtherSettings." + o + ".Lore")) {
for (String l : config.getStringList("Settings.GUISettings.OtherSettings." + o + ".Lore")) {
lore.add(l.replace("%Category%", cName).replace("%category%", cName));
}
inv.setItem(slot - 1, Methods.makeItem(id, 1, name, lore));
inv.setItem(slot - 1, itemBuilder.setLore(lore).build());
} else {
inv.setItem(slot - 1, Methods.makeItem(id, 1, name));
inv.setItem(slot - 1, itemBuilder.setLore(lore).build());
}
}
@ -183,11 +195,14 @@ public class GuiListener implements Listener {
String id = config.getString("Settings.GUISettings." + o + ".Item");
String name = config.getString("Settings.GUISettings." + o + ".Name");
int slot = config.getInt("Settings.GUISettings." + o + ".Slot");
ItemBuilder itemBuilder = new ItemBuilder().setMaterial(id).setName(name).setAmount(1);
if (config.contains("Settings.GUISettings." + o + ".Lore")) {
inv.setItem(slot - 1, Methods.makeItem(id, 1, name, config.getStringList("Settings.GUISettings." + o + ".Lore")));
} else {
inv.setItem(slot - 1, Methods.makeItem(id, 1, name));
itemBuilder.setLore(config.getStringList("Settings.GUISettings." + o + ".Lore"));
}
inv.setItem(slot - 1, itemBuilder.build());
}
shopType.put(player.getUniqueId(), shop);
@ -217,11 +232,14 @@ public class GuiListener implements Listener {
String id = config.getString("Settings.GUISettings.OtherSettings." + o + ".Item");
String name = config.getString("Settings.GUISettings.OtherSettings." + o + ".Name");
int slot = config.getInt("Settings.GUISettings.OtherSettings." + o + ".Slot");
ItemBuilder itemBuilder = new ItemBuilder().setMaterial(id).setName(name).setAmount(1);
if (config.contains("Settings.GUISettings.OtherSettings." + o + ".Lore")) {
inv.setItem(slot - 1, Methods.makeItem(id, 1, name, config.getStringList("Settings.GUISettings.OtherSettings." + o + ".Lore")));
} else {
inv.setItem(slot - 1, Methods.makeItem(id, 1, name));
itemBuilder.setLore(config.getStringList("Settings.GUISettings.OtherSettings." + o + ".Lore"));
}
inv.setItem(slot - 1, itemBuilder.build());
}
if (data.contains("Items")) {
@ -231,7 +249,11 @@ public class GuiListener implements Listener {
for (String l : config.getStringList("Settings.GUISettings.CurrentLore")) {
lore.add(l.replace("%Price%", Methods.getPrice(i, false)).replace("%price%", Methods.getPrice(i, false)).replace("%Time%", Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire"))).replace("%time%", Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire"))));
}
items.add(Methods.addLore(data.getItemStack("Items." + i + ".Item").clone(), lore));
ItemBuilder itemBuilder = ItemBuilder.convertItemStack(data.getItemStack("Items." + i + ".Item"));
lore.forEach(itemBuilder::addLore);
ID.add(data.getInt("Items." + i + ".StoreID"));
}
}
@ -262,7 +284,11 @@ public class GuiListener implements Listener {
for (String l : config.getStringList("Settings.GUISettings.Cancelled/ExpiredLore")) {
lore.add(l.replace("%Price%", Methods.getPrice(i, true)).replace("%price%", Methods.getPrice(i, true)).replace("%Time%", Methods.convertToTime(data.getLong("OutOfTime/Cancelled." + i + ".Full-Time"))).replace("%time%", Methods.convertToTime(data.getLong("OutOfTime/Cancelled." + i + ".Full-Time"))));
}
items.add(Methods.addLore(data.getItemStack("OutOfTime/Cancelled." + i + ".Item").clone(), lore));
ItemBuilder itemBuilder = ItemBuilder.convertItemStack(data.getItemStack("OutOfTime/Cancelled." + i + ".Item"));
lore.forEach(itemBuilder::addLore);
ID.add(data.getInt("OutOfTime/Cancelled." + i + ".StoreID"));
}
}
@ -291,11 +317,14 @@ public class GuiListener implements Listener {
String id = config.getString("Settings.GUISettings.OtherSettings." + o + ".Item");
String name = config.getString("Settings.GUISettings.OtherSettings." + o + ".Name");
int slot = config.getInt("Settings.GUISettings.OtherSettings." + o + ".Slot");
ItemBuilder itemBuilder = new ItemBuilder().setMaterial(id).setName(name).setAmount(1);
if (config.contains("Settings.GUISettings.OtherSettings." + o + ".Lore")) {
inv.setItem(slot - 1, Methods.makeItem(id, 1, name, config.getStringList("Settings.GUISettings.OtherSettings." + o + ".Lore")));
} else {
inv.setItem(slot - 1, Methods.makeItem(id, 1, name));
itemBuilder.setLore(config.getStringList("Settings.GUISettings.OtherSettings." + o + ".Lore"));
}
inv.setItem(slot - 1, itemBuilder.build());
}
for (ItemStack item : Methods.getPage(items, page)) {
@ -331,12 +360,14 @@ public class GuiListener implements Listener {
String name = config.getString("Settings.GUISettings.OtherSettings." + o + ".Name");
ItemStack item;
ItemBuilder itemBuilder = new ItemBuilder().setMaterial(id).setName(name).setAmount(1);
if (config.contains("Settings.GUISettings.OtherSettings." + o + ".Lore")) {
item = Methods.makeItem(id, 1, name, config.getStringList("Settings.GUISettings.OtherSettings." + o + ".Lore"));
} else {
item = Methods.makeItem(id, 1, name);
itemBuilder.setLore(config.getStringList("Settings.GUISettings.OtherSettings." + o + ".Lore")).build();
}
item = itemBuilder.build();
if (o.equals("Confirm")) {
inv.setItem(0, item);
inv.setItem(1, item);
@ -358,7 +389,12 @@ public class GuiListener implements Listener {
lore.add(l.replace("%Price%", Methods.getPrice(ID, false)).replace("%price%", Methods.getPrice(ID, false)).replace("%Seller%", data.getString("Items." + ID + ".Seller")).replace("%seller%", data.getString("Items." + ID + ".Seller")).replace("%Time%", Methods.convertToTime(data.getLong("Items." + l + ".Time-Till-Expire"))).replace("%time%", Methods.convertToTime(data.getLong("Items." + l + ".Time-Till-Expire"))));
}
inv.setItem(4, Methods.addLore(item.clone(), lore));
ItemBuilder itemBuilder = ItemBuilder.convertItemStack(item);
lore.forEach(itemBuilder::addLore);
inv.setItem(4, itemBuilder.build());
IDs.put(player.getUniqueId(), ID);
player.openInventory(inv);
}
@ -377,19 +413,21 @@ public class GuiListener implements Listener {
Inventory inv = plugin.getServer().createInventory(null, 27, Methods.color(config.getString("Settings.Bidding-On-Item")));
if (!bidding.containsKey(player.getUniqueId())) bidding.put(player.getUniqueId(), 0);
inv.setItem(9, Methods.makeItem("LIME_STAINED_GLASS_PANE", 1, "&a+1"));
inv.setItem(10, Methods.makeItem("LIME_STAINED_GLASS_PANE", 1, "&a+10"));
inv.setItem(11, Methods.makeItem("LIME_STAINED_GLASS_PANE", 1, "&a+100"));
inv.setItem(12, Methods.makeItem("LIME_STAINED_GLASS_PANE", 1, "&a+1000"));
inv.setItem(14, Methods.makeItem("RED_STAINED_GLASS_PANE", 1, "&c-1000"));
inv.setItem(15, Methods.makeItem("RED_STAINED_GLASS_PANE", 1, "&c-100"));
inv.setItem(16, Methods.makeItem("RED_STAINED_GLASS_PANE", 1, "&c-10"));
inv.setItem(17, Methods.makeItem("RED_STAINED_GLASS_PANE", 1, "&c-1"));
inv.setItem(9, new ItemBuilder().setMaterial(Material.LIME_STAINED_GLASS_PANE).setName("&a+1").setAmount(1).build());
inv.setItem(10, new ItemBuilder().setMaterial(Material.LIME_STAINED_GLASS_PANE).setName("&a+10").setAmount(1).build());
inv.setItem(11, new ItemBuilder().setMaterial(Material.LIME_STAINED_GLASS_PANE).setName("&a+100").setAmount(1).build());
inv.setItem(12, new ItemBuilder().setMaterial(Material.LIME_STAINED_GLASS_PANE).setName("&a+1000").setAmount(1).build());
inv.setItem(14, new ItemBuilder().setMaterial(Material.LIME_STAINED_GLASS_PANE).setName("&c-1000").setAmount(1).build());
inv.setItem(15, new ItemBuilder().setMaterial(Material.LIME_STAINED_GLASS_PANE).setName("&c-100").setAmount(1).build());
inv.setItem(16, new ItemBuilder().setMaterial(Material.LIME_STAINED_GLASS_PANE).setName("&c-10").setAmount(1).build());
inv.setItem(17, new ItemBuilder().setMaterial(Material.LIME_STAINED_GLASS_PANE).setName("&c-1").setAmount(1).build());
inv.setItem(13, getBiddingGlass(player, ID));
inv.setItem(22, Methods.makeItem(config.getString("Settings.GUISettings.OtherSettings.Bid.Item"), 1, config.getString("Settings.GUISettings.OtherSettings.Bid.Name"), config.getStringList("Settings.GUISettings.OtherSettings.Bid.Lore")));
inv.setItem(22, new ItemBuilder().setMaterial(config.getString("Settings.GUISettings.OtherSettings.Bid.Item")).setAmount(1)
.setName("Settings.GUISettings.OtherSettings.Bid.Name").setLore(config.getStringList("Settings.GUISettings.OtherSettings.Bid.Lore")).build());
inv.setItem(4, getBiddingItem(ID));
player.openInventory(inv);
}
@ -421,7 +459,11 @@ public class GuiListener implements Listener {
lore.add(l.replace("%Price%", Methods.getPrice(i, false)).replace("%price%", Methods.getPrice(i, false)).replace("%Seller%", data.getString("Items." + i + ".Seller")).replace("%seller%", data.getString("Items." + i + ".Seller")).replace("%Time%", Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire"))).replace("%time%", Methods.convertToTime(data.getLong("Items." + i + ".Time-Till-Expire"))));
}
}
items.add(Methods.addLore(data.getItemStack("Items." + i + ".Item").clone(), lore));
ItemBuilder itemBuilder = ItemBuilder.convertItemStack(data.getItemStack("Items." + i + ".Item"));
lore.forEach(itemBuilder::addLore);
ID.add(data.getInt("Items." + i + ".StoreID"));
}
}
@ -446,11 +488,13 @@ public class GuiListener implements Listener {
String name = config.getString("Settings.GUISettings.OtherSettings." + o + ".Name");
int slot = config.getInt("Settings.GUISettings.OtherSettings." + o + ".Slot");
ItemBuilder itemBuilder = new ItemBuilder().setMaterial(id).setName(name).setAmount(1);
if (config.contains("Settings.GUISettings.OtherSettings." + o + ".Lore")) {
inv.setItem(slot - 1, Methods.makeItem(id, 1, name, config.getStringList("Settings.GUISettings.OtherSettings." + o + ".Lore")));
} else {
inv.setItem(slot - 1, Methods.makeItem(id, 1, name));
itemBuilder.setLore(config.getStringList("Settings.GUISettings.OtherSettings." + o + ".Lore"));
}
inv.setItem(slot - 1, itemBuilder.build());
}
for (ItemStack item : Methods.getPage(items, page)) {
@ -467,7 +511,8 @@ public class GuiListener implements Listener {
String id = config.getString("Settings.GUISettings.OtherSettings.Bidding.Item");
String name = config.getString("Settings.GUISettings.OtherSettings.Bidding.Name");
ItemStack item;
ItemBuilder itemBuilder = new ItemBuilder().setMaterial(id).setName(name).setAmount(1);
int bid = bidding.get(player.getUniqueId());
@ -476,12 +521,11 @@ public class GuiListener implements Listener {
for (String l : config.getStringList("Settings.GUISettings.OtherSettings.Bidding.Lore")) {
lore.add(l.replace("%Bid%", bid + "").replace("%bid%", bid + "").replace("%TopBid%", Methods.getPrice(ID, false)).replace("%topbid%", Methods.getPrice(ID, false)));
}
item = Methods.makeItem(id, 1, name, lore);
} else {
item = Methods.makeItem(id, 1, name);
itemBuilder.setLore(lore);
}
return item;
return itemBuilder.build();
}
private static ItemStack getBiddingItem(String ID) {
@ -496,7 +540,11 @@ public class GuiListener implements Listener {
lore.add(l.replace("%TopBid%", Methods.getPrice(ID, false)).replace("%topbid%", Methods.getPrice(ID, false)).replace("%Seller%", seller).replace("%seller%", seller).replace("%TopBidder%", topbidder).replace("%topbidder%", topbidder).replace("%Time%", Methods.convertToTime(data.getLong("Items." + ID + ".Time-Till-Expire"))).replace("%time%", Methods.convertToTime(data.getLong("Items." + ID + ".Time-Till-Expire"))));
}
return Methods.addLore(item.clone(), lore);
ItemBuilder itemBuilder = ItemBuilder.convertItemStack(item);
lore.forEach(itemBuilder::addLore);
return itemBuilder.build();
}
private static void playClick(Player player) {
@ -769,17 +817,16 @@ public class GuiListener implements Listener {
final Runnable runnable = () -> inv.setItem(slot, item);
if (data.getString("Items." + i + ".Seller").equalsIgnoreCase(player.getName())) {
String it = config.getString("Settings.GUISettings.OtherSettings.Your-Item.Item");
String itemName = config.getString("Settings.GUISettings.OtherSettings.Your-Item.Item");
String name = config.getString("Settings.GUISettings.OtherSettings.Your-Item.Name");
ItemStack I;
ItemBuilder itemBuilder = new ItemBuilder().setMaterial(itemName).setName(name).setAmount(1);
if (config.contains("Settings.GUISettings.OtherSettings.Your-Item.Lore")) {
I = Methods.makeItem(it, 1, name, config.getStringList("Settings.GUISettings.OtherSettings.Your-Item.Lore"));
} else {
I = Methods.makeItem(it, 1, name);
itemBuilder.setLore(config.getStringList("Settings.GUISettings.OtherSettings.Your-Item.Lore"));
}
inv.setItem(slot, I);
inv.setItem(slot, itemBuilder.build());
playClick(player);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, runnable, 3 * 20);
return;
@ -788,17 +835,16 @@ public class GuiListener implements Listener {
long cost = data.getLong("Items." + i + ".Price");
if (plugin.getSupport().getMoney(player) < cost) {
String it = config.getString("Settings.GUISettings.OtherSettings.Cant-Afford.Item");
String itemName = config.getString("Settings.GUISettings.OtherSettings.Cant-Afford.Item");
String name = config.getString("Settings.GUISettings.OtherSettings.Cant-Afford.Name");
ItemStack I;
ItemBuilder itemBuilder = new ItemBuilder().setMaterial(itemName).setName(name).setAmount(1);
if (config.contains("Settings.GUISettings.OtherSettings.Cant-Afford.Lore")) {
I = Methods.makeItem(it, 1, name, config.getStringList("Settings.GUISettings.OtherSettings.Cant-Afford.Lore"));
} else {
I = Methods.makeItem(it, 1, name);
itemBuilder.setLore(config.getStringList("Settings.GUISettings.OtherSettings.Cant-Afford.Lore"));
}
inv.setItem(slot, I);
inv.setItem(slot, itemBuilder.build());
playClick(player);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, runnable, 3 * 20);
return;
@ -806,17 +852,16 @@ public class GuiListener implements Listener {
if (data.getBoolean("Items." + i + ".Biddable")) {
if (player.getName().equalsIgnoreCase(data.getString("Items." + i + ".TopBidder"))) {
String it = config.getString("Settings.GUISettings.OtherSettings.Top-Bidder.Item");
String itemName = config.getString("Settings.GUISettings.OtherSettings.Top-Bidder.Item");
String name = config.getString("Settings.GUISettings.OtherSettings.Top-Bidder.Name");
ItemStack I;
ItemBuilder itemBuilder = new ItemBuilder().setMaterial(itemName).setName(name).setAmount(1);
if (config.contains("Settings.GUISettings.OtherSettings.Top-Bidder.Lore")) {
I = Methods.makeItem(it, 1, name, config.getStringList("Settings.GUISettings.OtherSettings.Top-Bidder.Lore"));
} else {
I = Methods.makeItem(it, 1, name);
itemBuilder.setLore( config.getStringList("Settings.GUISettings.OtherSettings.Top-Bidder.Lore"));
}
inv.setItem(slot, I);
inv.setItem(slot, itemBuilder.build());
playClick(player);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, runnable, 3 * 20);
return;

View File

@ -1,28 +0,0 @@
package com.ryderbelserion.crazyauctions;
import com.ryderbelserion.cluster.ClusterPackage;
import com.ryderbelserion.crazyauctions.platform.PaperServer;
import org.bukkit.plugin.java.JavaPlugin;
public class CrazyAuctionsPaper extends JavaPlugin {
private CrazyAuctions crazyAuctions;
@Override
public void onEnable() {
this.crazyAuctions = new CrazyAuctions(new PaperServer());
new ClusterPackage(this, true);
}
@Override
public void onDisable() {
if (this.crazyAuctions != null) {
this.crazyAuctions.disable();
}
}
public CrazyAuctions getCrazyAuctions() {
return this.crazyAuctions;
}
}

View File

@ -1,17 +0,0 @@
package com.ryderbelserion.crazyauctions.platform;
import com.ryderbelserion.crazyauctions.CrazyAuctionsPaper;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
import java.io.File;
public class PaperServer implements Server {
@NotNull
private final CrazyAuctionsPaper plugin = JavaPlugin.getPlugin(CrazyAuctionsPaper.class);
@Override
public File getFolder() {
return this.plugin.getDataFolder();
}
}

View File

@ -1,5 +1,5 @@
name: '${name}'
main: '${group}.CrazyAuctionsPaper'
main: '${group}.CrazyAuctions'
authors: ${authors}
@ -9,3 +9,7 @@ description: '${description}'
website: '${website}'
softdepend: [Vault]
commands:
crazyauctions:
description: The base command for CrazyAuctions.

View File

@ -1,3 +1,5 @@
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
pluginManagement {
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
@ -7,51 +9,6 @@ pluginManagement {
}
}
dependencyResolutionManagement {
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
gradlePluginPortal()
mavenCentral()
}
versionCatalogs {
create("libs") {
version("adventure4", "4.16.0")
version("cluster", "6.3")
version("cloud", "1.8.4")
library("holographicdisplays", "me.filoghost.holographicdisplays", "holographicdisplays-api").version("3.0.0")
library("decentholograms", "com.github.decentsoftware-eu", "decentholograms").version("2.8.6")
library("triumphcmds", "dev.triumphteam", "triumph-cmd-bukkit").version("2.0.0-SNAPSHOT")
library("triumphgui", "dev.triumphteam", "triumph-gui").version("3.1.7")
library("cluster_paper", "com.ryderbelserion.cluster", "paper").versionRef("cluster")
library("cluster_api", "com.ryderbelserion.cluster", "paper").versionRef("cluster")
library("cloud_core", "cloud.commandframework", "cloud-core").versionRef("cloud")
library("cloud_brig", "cloud.commandframework", "cloud-brigadier").versionRef("cloud")
library("cloud_paper", "cloud.commandframework", "cloud-paper").versionRef("cloud")
library("cloud_extras", "cloud.commandframework", "cloud-minecraft-extras").versionRef("cloud")
library("adventure4", "net.kyori", "adventure-text-minimessage").versionRef("adventure4")
library("minimessage4", "net.kyori", "adventure-api").versionRef("adventure4")
library("itemsadder", "com.github.LoneDev6", "api-itemsadder").version("3.6.1")
library("placeholderapi", "me.clip", "placeholderapi").version("2.11.5")
library("vault", "com.github.MilkBowl", "VaultAPI").version("1.7.1")
library("metrics", "org.bstats", "bstats-bukkit").version("3.0.2")
library("oraxen", "io.th0rgal", "oraxen").version("1.164.0")
library("configme", "ch.jalu", "configme").version("1.4.1")
bundle("adventure", listOf("adventure4", "minimessage4"))
}
}
}
rootProject.name = "CrazyAuctions"
include("paper")
include("common")
include(":paper")