Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"java.compile.nullAnalysis.mode": "automatic",
"java.configuration.updateBuildConfiguration": "interactive"
}
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>**/*.ogg</exclude>
<exclude>**/*.png</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>**/*.ogg</include>
<include>**/*.png</include>
</includes>
</resource>
</resources>
</build>
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/me/zenox/evocraft/EvoCraft.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import me.zenox.evocraft.enchant.EnchantRegistry;
import me.zenox.evocraft.events.*;
import me.zenox.evocraft.item.ItemRegistry;
import me.zenox.evocraft.item.PackGenerator;
import me.zenox.evocraft.item.VanillaItem;
import me.zenox.evocraft.network.GlowFilter;
import me.zenox.evocraft.recipe.RecipeRegistry;
Expand All @@ -42,6 +43,7 @@ public final class EvoCraft extends JavaPlugin {
private static ProtocolManager protocolManager;
private static ChapterManager chapterManager;
private static ActionBar actionBar;
private static PackGenerator packGenerator;

public static EvoCraft getPlugin() {
return plugin;
Expand Down Expand Up @@ -102,6 +104,8 @@ public void onEnable() {

registerListeners();

packGenerator = new PackGenerator("pack");

}

private void registerListeners() {
Expand Down Expand Up @@ -170,9 +174,14 @@ public static ChapterManager getChapterManager() {
public static ActionBar getActionBar() {
return actionBar;
}

public static PackGenerator getPackGenerator() {
return packGenerator;
}

public void reload() {
this.reloadConfig();
this.languageLoader = new LanguageLoader(this);
languageLoader = new LanguageLoader(this);
}

@Override
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/me/zenox/evocraft/abilities/ItemAbility.java
Original file line number Diff line number Diff line change
Expand Up @@ -1069,9 +1069,14 @@ public void run() {
// Remove the metadata
player.removeMetadata("thunderstrike_projectile", EvoCraft.getPlugin());
}
// Create particles at the projectile's location
player.getWorld().spawnParticle(Particle.CRIT_MAGIC, projectile.getLocation(), 10, 0.3, 0.3, 0.3, 0.1);
player.getWorld().spawnParticle(Particle.REDSTONE, projectile.getLocation(), 10, 0.3, 0.3, 0.3, 0.1, new Particle.DustOptions(Color.fromRGB(244, 252, 3), 1));
//loop through blocks until you find the highest block that is not air
Location loc = projectile.getLocation();
while (loc.getBlock().getType() == Material.AIR) {
loc.add(0, 1, 0);
}
//create lighting at the block
player.getWorld().spawnParticle(Particle.CRIT_MAGIC, loc, 10, 0.3, 0.3, 0.3, 0.1);
player.getWorld().spawnParticle(Particle.REDSTONE, loc, 10, 0.3, 0.3, 0.3, 0.1, new Particle.DustOptions(Color.fromRGB(244, 252, 3), 1));
}
}.runTaskTimer(EvoCraft.getPlugin(), 0, 3);
}
Expand Down
79 changes: 79 additions & 0 deletions src/main/java/me/zenox/evocraft/command/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
import me.zenox.evocraft.story.Chapter;
import me.zenox.evocraft.story.ChapterManager;
import me.zenox.evocraft.util.Util;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextDecoration;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.CommandExecutor;
Expand Down Expand Up @@ -225,6 +231,76 @@ public boolean onCommand(CommandSender sender, org.bukkit.command.Command comman
EvoCraft.getChapterManager().setChapter(player, chapter);
return true;
}
case "pack" -> {
if (args.length < 3) {
Util.sendMessage(sender, "Please specify a valid resource pack URL and SHA-1 hash.");
return true;
}

// verify that the URL is valid
if (!Util.urlIsValid(args[1])) {
Util.sendMessage(sender, "Please specify a valid resource pack URL.");
return true;
}

// set the URL of the resource pack
EvoCraft.getPackGenerator().setUrl(args[1]);
// set in config
plugin.getConfig().set("resource-pack-url", args[1]);

// verify and set the SHA-1 hash
String sha1HashString = args[2];

try {
// Convert the hex string to a byte array
byte[] sha1Hash = Util.hexStringToByteArray(sha1HashString);
EvoCraft.getPackGenerator().setHash(sha1Hash);
plugin.getConfig().set("resource-pack-sha1", sha1HashString);
} catch (IllegalArgumentException e) {
Util.sendMessage(sender, "The SHA-1 hash provided is not a valid hexadecimal string.");
return true;
}

// send confirmation message
Util.sendMessage(sender, "&aResource pack URL set to " + args[1]);
Util.sendMessage(sender, "&aSHA-1 hash set to " + sha1HashString);

// send funny message with clickable text
Util.sendMessage(sender,
Component.text().content("CLICK HERE TO APPLY THE RESOURCE PACK FOR ALL PLAYERS")
.color(NamedTextColor.YELLOW)
.decorate(TextDecoration.BOLD)
.decorate(TextDecoration.UNDERLINED)
.hoverEvent(HoverEvent.showText(Component.text("Run /evocraft applypack ").color(NamedTextColor.GRAY)))
.clickEvent(ClickEvent.suggestCommand("/evocraft applypack"))
.build());
plugin.saveConfig();
return true;
}
case "applypack" -> {
// apply the resource pack to all players
for (Player player : Bukkit.getOnlinePlayers()) {
EvoCraft.getPackGenerator().applyPack(player);
}
Util.sendMessage(sender, "&aResource pack applied to all players.");
return true;
}
case "modeldata" -> {
// get custommodeldata of item in hand
if (sender instanceof Player) {
Player player = (Player) sender;
ItemStack item = player.getInventory().getItemInMainHand();
if (item.getType() == Material.AIR) {
Util.sendMessage(sender, ChatColor.WHITE + "This item has no CustomModelData (that is created by EvoCraft)");
return true;
}
Util.sendMessage(sender, "The CustomModelData of " + item.getItemMeta().getDisplayName() + "&f is " + ComplexItemStack.of(item).getComplexItem().getCustomModelData());
Util.sendMessage(sender, "Actual model data: " + item.getItemMeta().getCustomModelData());
return true;
} else {
Util.sendMessage(sender, "You must be a player to use this command!");
}
}
default -> Util.sendMessage(sender, "EvoCraft Help Page.");
}
return true;
Expand All @@ -243,6 +319,9 @@ public List<String> onTabComplete(CommandSender sender, org.bukkit.command.Comma
arguments.add("enchant");
arguments.add("reload");
arguments.add("removechapterdata");
arguments.add("pack");
arguments.add("applypack");
arguments.add("modeldata");
}

if (items.isEmpty()) {
Expand Down
Loading