Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
xIdentified committed Dec 12, 2023
2 parents f7d0eb3 + adc7808 commit 98073e0
Show file tree
Hide file tree
Showing 20 changed files with 1,027 additions and 295 deletions.
8 changes: 8 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

339 changes: 339 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

105 changes: 105 additions & 0 deletions dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.xIdentified</groupId>
<artifactId>TavernBard</artifactId>
<name>TavernBard</name>
<version>1.2.1</version>
<build>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>net.kyori.adventure</pattern>
<shadedPattern>me.xidentified.tavernbard.adventure</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>papermc-repo</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>citizens-repo</id>
<url>https://maven.citizensnpcs.co/repo</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>nexus</id>
<name>Lumine Releases</name>
<url>https://mvn.lumine.io/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.20.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens-main</artifactId>
<version>2.0.32-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.lumine</groupId>
<artifactId>Mythic-Dist</artifactId>
<version>5.3.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<java.version>16</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
38 changes: 19 additions & 19 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

<groupId>me.xIdentified</groupId>
<artifactId>TavernBard</artifactId>
<version>1.0</version>
<version>1.2.2</version>
<packaging>jar</packaging>

<name>TavernBard</name>

<properties>
Expand All @@ -27,22 +26,6 @@
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
Expand All @@ -69,13 +52,18 @@
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>nexus</id>
<name>Lumine Releases</name>
<url>https://mvn.lumine.io/repository/maven-public/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.20.1-R0.1-SNAPSHOT</version>
<version>1.20.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -97,5 +85,17 @@
<version>1.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.lumine</groupId>
<artifactId>Mythic-Dist</artifactId>
<version>5.3.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.14.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
27 changes: 4 additions & 23 deletions src/main/java/me/xidentified/tavernbard/BardTrait.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,20 @@
package me.xidentified.tavernbard;

import me.xidentified.tavernbard.managers.SongManager;
import me.xidentified.tavernbard.util.MessageUtil;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
import net.citizensnpcs.api.util.DataKey;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import net.citizensnpcs.api.event.NPCRightClickEvent;

import static org.bukkit.plugin.java.JavaPlugin.getPlugin;


@TraitName("bard")
public class BardTrait extends Trait {
private final TavernBard plugin;
private final SongManager songManager;

@Persist private boolean isBard = true;

public BardTrait() {
super("bard");
this.plugin = getPlugin(TavernBard.class);
this.songManager = plugin.getSongManager();
}

@Persist private boolean isBard = true;

// Keeping load and save methods as they are
@Override
public void load(DataKey key) {
isBard = key.getBoolean("isBard", true);
Expand All @@ -36,13 +25,5 @@ public void save(DataKey key) {
key.setBoolean("isBard", isBard);
}

@EventHandler
public void onRightClick(NPCRightClickEvent event) {
if (event.getNPC() == this.getNPC()) {
Player player = event.getClicker();
SongSelectionGUI gui = new SongSelectionGUI(plugin, songManager, event.getNPC(), this.plugin.getMessageUtil());
player.openInventory(gui.getInventory());
}
}

}

25 changes: 18 additions & 7 deletions src/main/java/me/xidentified/tavernbard/CommandHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.jetbrains.annotations.NotNull;

import java.util.Queue;
import java.util.UUID;

public class CommandHandler implements CommandExecutor {
private final SongManager songManager;
Expand All @@ -20,7 +21,20 @@ public CommandHandler(SongManager songManager, QueueManager queueManager) {
}

@Override
public boolean onCommand(@NotNull CommandSender sender, Command cmd, @NotNull String label, String[] args) {
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) {
if (!(sender instanceof Player player)) {
sender.sendMessage("§cOnly players can use bard commands.");
return true;
}

// Assume a method getNearestBardNpc which returns the closest Bard NPC to a player
UUID npcId = songManager.getNearestBard(player, 8);

if (npcId == null) {
sender.sendMessage("§cNo nearby bard NPCs found!");
return true;
}

if (cmd.getName().equalsIgnoreCase("bard") && args.length > 0) {
if (args[0].equalsIgnoreCase("reload")) {
if (sender.hasPermission("bard.reload")) {
Expand All @@ -32,7 +46,7 @@ public boolean onCommand(@NotNull CommandSender sender, Command cmd, @NotNull St
}
} else if (args[0].equalsIgnoreCase("queue")) {
if (sender.hasPermission("bard.play")) {
Queue<Song> queue = queueManager.getQueueStatus();
Queue<Song> queue = queueManager.getQueueStatus(npcId); // Updated to use NPC ID
if (queue.isEmpty()) {
sender.sendMessage("§cThere are no songs in the queue.");
return true;
Expand All @@ -46,14 +60,11 @@ public boolean onCommand(@NotNull CommandSender sender, Command cmd, @NotNull St
return true;
}
} else if (args[0].equalsIgnoreCase("vote")) {
if (!(sender instanceof Player)) {
sender.sendMessage("§cOnly players can vote to skip songs.");
return true;
} else if (!songManager.isSongPlaying()) {
if (!songManager.isSongPlaying(npcId)) {
sender.sendMessage("§cThere are no songs playing to vote against.");
return true;
}
queueManager.voteToSkip((Player) sender);
queueManager.voteToSkip(player, npcId);
return true;
}
}
Expand Down
Loading

0 comments on commit 98073e0

Please sign in to comment.