Skip to content

Commit 8090045

Browse files
ZP4RKERZP4RKER
authored andcommitted
Added Command Listener
1 parent f951289 commit 8090045

4 files changed

Lines changed: 96 additions & 78 deletions

File tree

pom.xml

Lines changed: 60 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,66 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
4-
<groupId>perceivedev</groupId>
5-
<artifactId>clickable-tpa</artifactId>
4+
<groupId>PerceiveDev</groupId>
5+
<artifactId>Clickable-TPA</artifactId>
66
<version>1.0</version>
7-
<name>Clickable-TPA</name>
8-
<description>Some plugin description</description>
7+
98
<repositories>
10-
<repository>
11-
<id>spigot-repo</id>
12-
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
13-
</repository>
14-
</repositories>
15-
<dependencies>
16-
<dependency>
17-
<groupId>org.bukkit</groupId>
18-
<artifactId>bukkit</artifactId>
19-
<version>1.10.2-R0.1-SNAPSHOT</version>
20-
<scope>provided</scope>
21-
</dependency>
22-
</dependencies>
23-
<build>
24-
<defaultGoal>clean compile test package</defaultGoal>
25-
<finalName>${project.name}-${project.version}</finalName>
26-
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
27-
<resources>
28-
<resource>
29-
<directory>${basedir}/src/main/resources</directory>
30-
<includes>
31-
<include>*.yml</include>
32-
</includes>
33-
</resource>
34-
</resources>
35-
<plugins>
36-
<plugin>
37-
<groupId>org.apache.maven.plugins</groupId>
38-
<artifactId>maven-compiler-plugin</artifactId>
39-
<version>3.5.1</version>
40-
<configuration>
41-
<source>1.8</source>
42-
<target>1.8</target>
43-
</configuration>
44-
</plugin>
45-
</plugins>
46-
</build>
9+
<repository>
10+
<id>spigotmc-repo</id>
11+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
12+
</repository>
13+
</repositories>
14+
15+
<dependencies>
16+
<dependency>
17+
<groupId>org.spigotmc</groupId>
18+
<artifactId>spigot-api</artifactId>
19+
<version>1.10.2-R0.1-SNAPSHOT</version>
20+
</dependency>
21+
</dependencies>
22+
23+
<build>
24+
<finalName>${project.name}-${project.version}</finalName>
25+
<sourceDirectory>src/main/java</sourceDirectory>
26+
<defaultGoal>clean package</defaultGoal>
27+
<resources>
28+
<resource>
29+
<targetPath>.</targetPath>
30+
<filtering>true</filtering>
31+
<directory>${basedir}/src/main/resources</directory>
32+
<includes>
33+
<include>*.yml</include>
34+
</includes>
35+
</resource>
36+
</resources>
37+
<plugins>
38+
<plugin>
39+
<groupId>org.apache.maven.plugins</groupId>
40+
<artifactId>maven-compiler-plugin</artifactId>
41+
<version>3.5.1</version>
42+
<configuration>
43+
<source>1.8</source>
44+
<target>1.8</target>
45+
</configuration>
46+
</plugin>
47+
<plugin>
48+
<artifactId>maven-antrun-plugin</artifactId>
49+
<executions>
50+
<execution>
51+
<phase>package</phase>
52+
<configuration>
53+
<tasks>
54+
<copy file="target/${project.name}-${project.version}.jar" todir="/Users/ZP4RKER/Public/Spigot/plugins" />
55+
</tasks>
56+
</configuration>
57+
<goals>
58+
<goal>run</goal>
59+
</goals>
60+
</execution>
61+
</executions>
62+
</plugin>
63+
</plugins>
64+
</build>
65+
4766
</project>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.perceivedev.clicktpa;
2+
3+
import org.bukkit.Bukkit;
4+
import org.bukkit.event.EventHandler;
5+
import org.bukkit.event.Listener;
6+
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
7+
import org.bukkit.plugin.java.JavaPlugin;
8+
9+
public class ClickableTPA extends JavaPlugin implements Listener {
10+
11+
public void onEnable() {
12+
// Register the listener
13+
getServer().getPluginManager().registerEvents(this, this);
14+
}
15+
16+
@EventHandler
17+
public void onCommandRun(PlayerCommandPreprocessEvent event) {
18+
String command = event.getMessage().substring(1);
19+
if (command.split(" ")[0].equalsIgnoreCase("tpa")) {
20+
// Command run is "/tpa"
21+
if (event.getPlayer().hasPermission(getConfig().getString("tpa-command-permission"))) {
22+
// Sender has permission
23+
if (command.split(" ").length == 2) {
24+
// Has player as argument
25+
if (Bukkit.getPlayer(command.split(" ")[1]) != null) {
26+
// Valid player argument
27+
}
28+
}
29+
}
30+
}
31+
}
32+
33+
}

src/main/java/perceivedev/Clickable-TPA.java

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/main/resources/plugin.yml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
main: com.perceivedev.clickable-tpa.Clickable-TPA
2-
name: Clickable-TPA
1+
name: ClickableTPA
32
version: 1.0
4-
description: A bukkit plugin
5-
author: [Rayzr]
6-
#commands:
7-
# clickable-tpa:
8-
# description: Clickable-TPA main command
9-
# aliases: [alias1,alias2]
10-
# usage: "/clickable-tpa [command]"
11-
# permission: Clickable-TPA.main
3+
description: Adds clickable chat text functionality for the /tpa command
4+
main: com.perceivedev.clicktpa.ClickableTPA

0 commit comments

Comments
 (0)