Initial commit.
This commit is contained in:
commit
911abcbd15
38
.gitignore
vendored
Normal file
38
.gitignore
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/modules.xml
|
||||||
|
.idea/jarRepositories.xml
|
||||||
|
.idea/compiler.xml
|
||||||
|
.idea/libraries/
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
3
.idea/.gitignore
vendored
Normal file
3
.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
7
.idea/encodings.xml
Normal file
7
.idea/encodings.xml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding">
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
19
.idea/misc.xml
Normal file
19
.idea/misc.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="EntryPointsManager">
|
||||||
|
<list size="1">
|
||||||
|
<item index="0" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
|
||||||
|
</list>
|
||||||
|
</component>
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="MavenProjectsManager">
|
||||||
|
<option name="originalFiles">
|
||||||
|
<list>
|
||||||
|
<option value="$PROJECT_DIR$/pom.xml" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_18" default="true" project-jdk-name="openjdk-18" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
30
pom.xml
Normal file
30
pom.xml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?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/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>io.natfan</groupId>
|
||||||
|
<artifactId>nCoords</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>18</maven.compiler.source>
|
||||||
|
<maven.compiler.target>18</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>1.19.4-R0.1-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains</groupId>
|
||||||
|
<artifactId>annotations</artifactId>
|
||||||
|
<version>RELEASE</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
54
src/main/java/io/natfan/nCoords/commands/CoordsCommand.java
Normal file
54
src/main/java/io/natfan/nCoords/commands/CoordsCommand.java
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package io.natfan.nCoords.commands;
|
||||||
|
|
||||||
|
import io.natfan.nCoords.nCoords;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class CoordsCommand implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
|
||||||
|
if (sender instanceof ConsoleCommandSender && args.length == 0) {
|
||||||
|
sender.sendMessage(nCoords.NewErrorMessage("Console doesn't have any coordinates! Try specifying a user."));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player;
|
||||||
|
boolean isSelf = true;
|
||||||
|
if (args.length == 0) player = (Player) sender;
|
||||||
|
else {
|
||||||
|
isSelf = false;
|
||||||
|
player = Bukkit.getPlayer(args[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player == null) {
|
||||||
|
sender.sendMessage(nCoords.NewErrorMessage("%s does not exist".formatted(args[0])));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
boolean hasPermission = sender.isOp() || sender.hasPermission("ncoords.other");
|
||||||
|
if (!isSelf && !hasPermission) {
|
||||||
|
sender.sendMessage(nCoords.NewErrorMessage("You do not have permission to perform this command."));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Location location = player.getLocation();
|
||||||
|
World world = location.getWorld();
|
||||||
|
if (world == null) return true;
|
||||||
|
boolean isNotMainWorld = !world.isNatural();
|
||||||
|
|
||||||
|
String message = "X: %d, Y: %d, Z: %d".formatted(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||||
|
if (isNotMainWorld) message += " (%s)".formatted(location.getWorld().getName());
|
||||||
|
|
||||||
|
if (isSelf) sender.sendMessage(ChatColor.GREEN + "Sending your coordinates...");
|
||||||
|
else sender.sendMessage(ChatColor.GREEN + "Sending " + ChatColor.DARK_GREEN + player.getName() + ChatColor.GREEN + "'s coordinates...");
|
||||||
|
|
||||||
|
player.chat(message);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
20
src/main/java/io/natfan/nCoords/nCoords.java
Normal file
20
src/main/java/io/natfan/nCoords/nCoords.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package io.natfan.nCoords;
|
||||||
|
|
||||||
|
import io.natfan.nCoords.commands.CoordsCommand;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class nCoords extends JavaPlugin {
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
Objects.requireNonNull(this.getCommand("coords")).setExecutor(new CoordsCommand());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDisable() {}
|
||||||
|
|
||||||
|
public static String NewErrorMessage(String message) {
|
||||||
|
return ChatColor.DARK_RED + "ERROR: " + ChatColor.RED + message;
|
||||||
|
}
|
||||||
|
}
|
8
src/main/resources/plugin.yml
Normal file
8
src/main/resources/plugin.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
name: 'nCoords'
|
||||||
|
version: '1.0.0-SNAPSHOT'
|
||||||
|
main: io.natfan.nCoords.nCoords
|
||||||
|
api-version: '1.18'
|
||||||
|
commands:
|
||||||
|
coords:
|
||||||
|
description: Prints your current coordinates in chat.
|
||||||
|
usage: /<command>
|
Loading…
Reference in New Issue
Block a user