Initialized git repo
This commit is contained in:
commit
3ad5610dbf
113
.gitignore
vendored
Normal file
113
.gitignore
vendored
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
# User-specific stuff
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
|
# Compiled class file
|
||||||
|
*.class
|
||||||
|
|
||||||
|
# Log file
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# BlueJ files
|
||||||
|
*.ctxt
|
||||||
|
|
||||||
|
# Package Files #
|
||||||
|
*.jar
|
||||||
|
*.war
|
||||||
|
*.nar
|
||||||
|
*.ear
|
||||||
|
*.zip
|
||||||
|
*.tar.gz
|
||||||
|
*.rar
|
||||||
|
|
||||||
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
|
hs_err_pid*
|
||||||
|
|
||||||
|
*~
|
||||||
|
|
||||||
|
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||||
|
.fuse_hidden*
|
||||||
|
|
||||||
|
# KDE directory preferences
|
||||||
|
.directory
|
||||||
|
|
||||||
|
# Linux trash folder which might appear on any partition or disk
|
||||||
|
.Trash-*
|
||||||
|
|
||||||
|
# .nfs files are created when an open file is removed but is still being accessed
|
||||||
|
.nfs*
|
||||||
|
|
||||||
|
# General
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Icon must end with two \r
|
||||||
|
Icon
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear in the root of a volume
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
.com.apple.timemachine.donotpresent
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
||||||
|
|
||||||
|
# Windows thumbnail cache files
|
||||||
|
Thumbs.db
|
||||||
|
Thumbs.db:encryptable
|
||||||
|
ehthumbs.db
|
||||||
|
ehthumbs_vista.db
|
||||||
|
|
||||||
|
# Dump file
|
||||||
|
*.stackdump
|
||||||
|
|
||||||
|
# Folder config file
|
||||||
|
[Dd]esktop.ini
|
||||||
|
|
||||||
|
# Recycle Bin used on file shares
|
||||||
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
|
# Windows Installer files
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# Windows shortcuts
|
||||||
|
*.lnk
|
||||||
|
|
||||||
|
target/
|
||||||
|
|
||||||
|
pom.xml.tag
|
||||||
|
pom.xml.releaseBackup
|
||||||
|
pom.xml.versionsBackup
|
||||||
|
pom.xml.next
|
||||||
|
|
||||||
|
release.properties
|
||||||
|
dependency-reduced-pom.xml
|
||||||
|
buildNumber.properties
|
||||||
|
.mvn/timing.properties
|
||||||
|
.mvn/wrapper/maven-wrapper.jar
|
||||||
|
.flattened-pom.xml
|
||||||
|
|
||||||
|
# Common working directory
|
||||||
|
run/
|
71
pom.xml
Normal file
71
pom.xml
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
<?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>de.privacynerd</groupId>
|
||||||
|
<artifactId>Positions</artifactId>
|
||||||
|
<version>1.1.2</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>Positions</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>${java.version}</source>
|
||||||
|
<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>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</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>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.papermc.paper</groupId>
|
||||||
|
<artifactId>paper-api</artifactId>
|
||||||
|
<version>1.20.4-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
150
src/main/java/de/privacynerd/positions/Positions.java
Normal file
150
src/main/java/de/privacynerd/positions/Positions.java
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
package de.privacynerd.positions;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.ArmorStand;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
class PositionCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
YamlConfiguration positions = new YamlConfiguration();
|
||||||
|
Player player = (Player) sender;
|
||||||
|
try {
|
||||||
|
positions.load("positions.yaml");
|
||||||
|
} catch (IOException e) {
|
||||||
|
try {
|
||||||
|
new File("positions.yaml").createNewFile();
|
||||||
|
player.sendMessage(Positions.PREFIX + ChatColor.RED + "An internal error occurred. Please try to execute the command again.");
|
||||||
|
return true;
|
||||||
|
} catch (IOException ioException) {
|
||||||
|
ioException.printStackTrace();
|
||||||
|
}
|
||||||
|
} catch (InvalidConfigurationException e) {
|
||||||
|
new File("positions.yaml").delete();
|
||||||
|
try {
|
||||||
|
new File("positions.yaml").createNewFile();
|
||||||
|
|
||||||
|
player.sendMessage(Positions.PREFIX + ChatColor.RED + "An internal error occurred. Please try to execute the command again.");
|
||||||
|
return true;
|
||||||
|
} catch (IOException ioException) {
|
||||||
|
ioException.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
List<String> positionList = (List<String>) positions.getList("positions");
|
||||||
|
if(positionList == null) {
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
positions.set("positions", list);
|
||||||
|
try {positions.save("positions.yaml");} catch (IOException e) {e.printStackTrace();} // save the configuration
|
||||||
|
positionList = (List<String>) positions.getList("positions");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(args.length == 0) {player.sendMessage(Positions.PREFIX + ChatColor.RED + "You have to specify at least one argument"); return true;}
|
||||||
|
|
||||||
|
if(args[0].equalsIgnoreCase("list")) {
|
||||||
|
if(positionList.isEmpty()) {
|
||||||
|
player.sendMessage(Positions.PREFIX + ChatColor.GOLD + "You haven't set any positions to display here!");
|
||||||
|
} else {
|
||||||
|
player.sendMessage(Positions.PREFIX + ChatColor.GREEN + "Available positions:");
|
||||||
|
for(String name : positionList) {
|
||||||
|
Location pos = positions.getLocation(name);
|
||||||
|
int x = pos.getBlockX();
|
||||||
|
int y = pos.getBlockY();
|
||||||
|
int z = pos.getBlockZ();
|
||||||
|
player.sendMessage(ChatColor.GOLD + name + ": " + ChatColor.RED + x + ChatColor.DARK_GREEN + " " + y + ChatColor.BLUE + " " + z);
|
||||||
|
}
|
||||||
|
player.sendMessage(Positions.PREFIX + ChatColor.ITALIC + "Type \"/pos <name> del>\" to delete them.");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/*if(args[0].equalsIgnoreCase("show")) {
|
||||||
|
ArmorStand armorStand = player.getWorld().spawn(player.getLocation(), ArmorStand.class);
|
||||||
|
armorStand.setVisible(false);
|
||||||
|
armorStand.setCustomName(ChatColor.GOLD + "POSITION");
|
||||||
|
armorStand.setCustomNameVisible(true);
|
||||||
|
}
|
||||||
|
if(args[0].equalsIgnoreCase("hide")) {
|
||||||
|
|
||||||
|
}*/
|
||||||
|
|
||||||
|
//if(!args[0].equalsIgnoreCase("list") && !args[0].equalsIgnoreCase("show") && !args[0].equalsIgnoreCase("hide")) {
|
||||||
|
if(!args[0].equalsIgnoreCase("list")) { // only save a new position when it's not named list (cause that's another action)
|
||||||
|
if(positionList.contains(args[0])) { // does the position already exist?
|
||||||
|
if(args[0].equalsIgnoreCase("positions")) {
|
||||||
|
player.sendMessage(Positions.PREFIX + ChatColor.RED + "You can't set (or get) the position \"positions\"");
|
||||||
|
return true;
|
||||||
|
} else if(args.length==2 && args[1].startsWith("del")) {
|
||||||
|
positionList.remove(args[0]);
|
||||||
|
positions.set("positions", positionList);
|
||||||
|
try {positions.save("positions.yaml");} catch (IOException e) {e.printStackTrace();} // save the configuration
|
||||||
|
player.sendMessage(Positions.PREFIX + ChatColor.GREEN + "Successfully deleted the position \"" + ChatColor.BLUE + args[0] + ChatColor.GREEN + "\"!");
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
Location pos = positions.getLocation(args[0]);
|
||||||
|
int x = pos.getBlockX();
|
||||||
|
int y = pos.getBlockY();
|
||||||
|
int z = pos.getBlockZ();
|
||||||
|
player.sendMessage(Positions.PREFIX + ChatColor.AQUA + "Position \"" + ChatColor.BLUE + args[0] + ChatColor.AQUA + "\": " + ChatColor.RED + x + ChatColor.GREEN + " " + y + ChatColor.BLUE + " " + z);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(args[0].equalsIgnoreCase("positions")) {
|
||||||
|
player.sendMessage(Positions.PREFIX + ChatColor.RED + "You can't set (or get) the position \"positions\"");
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
Location playerPos = player.getLocation();
|
||||||
|
positionList.add(args[0]);
|
||||||
|
positions.set(args[0], playerPos);
|
||||||
|
positions.set("positions", positionList);
|
||||||
|
try {positions.save("positions.yaml");} catch (IOException e) {e.printStackTrace();} // save the configuration
|
||||||
|
player.sendMessage(Positions.PREFIX + ChatColor.GREEN + "Position \"" + ChatColor.BLUE + args[0] + ChatColor.GREEN + "\" has been saved.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class Positions extends JavaPlugin {
|
||||||
|
public static String PREFIX = ChatColor.BLUE + "[" + ChatColor.LIGHT_PURPLE + "Positions" + ChatColor.BLUE + "] " + ChatColor.WHITE;
|
||||||
|
public static Positions INSTANCE;
|
||||||
|
public Positions() {
|
||||||
|
INSTANCE = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void log(String msg) {
|
||||||
|
Bukkit.getConsoleSender().sendMessage(PREFIX + msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void chat(String msg) {
|
||||||
|
Bukkit.getConsoleSender().sendMessage(PREFIX + msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
// Plugin startup logic
|
||||||
|
log(ChatColor.GREEN + "Plugin has been enabled");
|
||||||
|
|
||||||
|
Bukkit.getPluginCommand("position").setExecutor(new PositionCommand());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
// Plugin shutdown logic
|
||||||
|
log(ChatColor.RED + "Plugin has been disabled");
|
||||||
|
}
|
||||||
|
}
|
11
src/main/resources/plugin.yml
Normal file
11
src/main/resources/plugin.yml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
name: Positions
|
||||||
|
version: '${project.version}'
|
||||||
|
main: de.privacynerd.positions.Positions
|
||||||
|
api-version: '1.20'
|
||||||
|
description: Plugin which provides the command "pos". See "/help pos"!
|
||||||
|
|
||||||
|
commands:
|
||||||
|
position:
|
||||||
|
description: With this command you gain the ability to save your position and get to it later.
|
||||||
|
usage: /position <name> del; /position <name>; /position list;
|
||||||
|
aliases: ["pos"]
|
Loading…
x
Reference in New Issue
Block a user