First commit
This commit is contained in:
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/
|
||||
137
pom.xml
Normal file
137
pom.xml
Normal file
@@ -0,0 +1,137 @@
|
||||
<?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>net.knarcraft</groupId>
|
||||
<artifactId>HorseTravel</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HorseTravel</name>
|
||||
|
||||
<properties>
|
||||
<java.version>21</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean package</defaultGoal>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.13.0</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.5.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>net.knarcraft.knarlib</pattern>
|
||||
<shadedPattern>net.knarcraft.minigames.lib.knarlib</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>net.knarcraft.knargui</pattern>
|
||||
<shadedPattern>net.knarcraft.minigames.lib.knargui</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.jetbrains.annotations</pattern>
|
||||
<shadedPattern>net.knarcraft.minigames.lib.annotations</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>net.knarcraft:knarlib</artifact>
|
||||
<includes>
|
||||
<include>net/knarcraft/knarlib/**</include>
|
||||
</includes>
|
||||
</filter>
|
||||
<filter>
|
||||
<artifact>net.knarcraft:knargui</artifact>
|
||||
<includes>
|
||||
<include>net/knarcraft/knargui/**</include>
|
||||
</includes>
|
||||
</filter>
|
||||
<filter>
|
||||
<artifact>org.jetbrains:annotations</artifact>
|
||||
<includes>
|
||||
<include>org/jetbrains/annotations/**</include>
|
||||
</includes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigotmc-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>knarcraft-repo</id>
|
||||
<url>https://git.knarcraft.net/api/packages/EpicKnarvik97/maven</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.21.8-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>24.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.knarcraft</groupId>
|
||||
<artifactId>knargui</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.knarcraft</groupId>
|
||||
<artifactId>knarlib</artifactId>
|
||||
<version>1.2.17</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.MilkBowl</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
40
src/main/java/net/knarcraft/horsetravel/HorseTravel.java
Normal file
40
src/main/java/net/knarcraft/horsetravel/HorseTravel.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package net.knarcraft.horsetravel;
|
||||
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public final class HorseTravel extends JavaPlugin {
|
||||
|
||||
// TODO: Load this from the config
|
||||
public static final @NotNull List<EntityType> travelEntities = List.of(EntityType.HORSE, EntityType.DONKEY,
|
||||
EntityType.MULE, EntityType.CAMEL);
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Plugin startup logic
|
||||
/*
|
||||
Horse RPG Travel
|
||||
|
||||
/htp create Network Name
|
||||
|
||||
If network exists, automatically connect.
|
||||
Spawn horse at current location. Clicking on the horse should open a GUI with travel locations.
|
||||
Should be able to customize the horse by clicking on it?
|
||||
Should be able to customize the item shown, by holding it in the player's hand.
|
||||
|
||||
/htp setitem Network Name
|
||||
|
||||
Ability to set a cost on teleportation, global modifyable for each location
|
||||
Able to set a permission requirement for a network or a location
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Plugin shutdown logic
|
||||
}
|
||||
}
|
||||
30
src/main/java/net/knarcraft/horsetravel/gui/HorseGUI.java
Normal file
30
src/main/java/net/knarcraft/horsetravel/gui/HorseGUI.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package net.knarcraft.horsetravel.gui;
|
||||
|
||||
import net.knarcraft.knargui.AbstractGUI;
|
||||
import net.knarcraft.knargui.GUIAction;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HorseGUI extends AbstractGUI {
|
||||
|
||||
int counter = 0;
|
||||
int maxSize;
|
||||
|
||||
public HorseGUI(int inventorySize, String inventoryName) {
|
||||
super(inventorySize, inventoryName, InventoryType.CHEST);
|
||||
this.maxSize = inventorySize;
|
||||
}
|
||||
|
||||
public boolean addIcon(@NotNull ItemStack itemStack, @NotNull GUIAction guiAction) {
|
||||
if (counter >= maxSize) {
|
||||
return false;
|
||||
}
|
||||
setItem(counter, itemStack);
|
||||
setClickAction(counter, ClickType.RIGHT, guiAction);
|
||||
setClickAction(counter++, ClickType.LEFT, guiAction);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package net.knarcraft.horsetravel.listener;
|
||||
|
||||
import net.knarcraft.horsetravel.HorseTravel;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityInteractEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class HorseListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onHorseInteract(@NotNull EntityInteractEvent event) {
|
||||
// TODO: Decide if the event is a horse travel point
|
||||
if (!HorseTravel.travelEntities.contains(event.getEntityType())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Need to check some identifier
|
||||
event.getEntity().getUniqueId();
|
||||
|
||||
// TODO: Horse travel points should show the name of their location
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package net.knarcraft.horsetravel.manager;
|
||||
|
||||
import net.knarcraft.horsetravel.travelpoint.TravelPoint;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TravelManager {
|
||||
|
||||
private Map<String, Set<TravelPoint>> travelPoints;
|
||||
private Map<UUID, TravelPoint> travelPointLookup;
|
||||
|
||||
@Nullable
|
||||
public Set<TravelPoint> getNetworkPoints(@NotNull String networkName) {
|
||||
return new HashSet<>(travelPoints.get(networkName));
|
||||
}
|
||||
|
||||
public TravelPoint getFromId(@NotNull UUID uuid) {
|
||||
return travelPointLookup.get(uuid);
|
||||
}
|
||||
|
||||
public void addTravelPoint(@NotNull TravelPoint travelPoint) {
|
||||
travelPoints.putIfAbsent(travelPoint.getNetworkName(), new HashSet<>());
|
||||
travelPoints.get(travelPoint.getNetworkName()).add(travelPoint);
|
||||
travelPointLookup.put(travelPoint.getEntityId(), travelPoint);
|
||||
}
|
||||
|
||||
public void removeTravelPoint(@NotNull TravelPoint travelPoint) {
|
||||
if (travelPoints.containsKey(travelPoint.getNetworkName())) {
|
||||
travelPoints.get(travelPoint.getNetworkName()).remove(travelPoint);
|
||||
}
|
||||
travelPointLookup.remove(travelPoint.getEntityId());
|
||||
}
|
||||
|
||||
public Set<TravelPoint> getRelatedPoints(@NotNull TravelPoint travelPoint) {
|
||||
Set<TravelPoint> points = travelPoints.get(travelPoint.getNetworkName());
|
||||
points.removeIf((point) -> point.equals(travelPoint));
|
||||
return points;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package net.knarcraft.horsetravel.travelpoint;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class TravelPoint {
|
||||
|
||||
private UUID entityId;
|
||||
private String networkName;
|
||||
private ItemStack appearingItem;
|
||||
private TravelPointRequirements requirements;
|
||||
|
||||
public UUID getEntityId() {
|
||||
return this.entityId;
|
||||
}
|
||||
|
||||
public String getNetworkName() {
|
||||
return this.networkName;
|
||||
}
|
||||
|
||||
// TODO: Check/take cost before allowing usage
|
||||
// TODO: Check if player has permission before allowing usage
|
||||
// TODO: Interactable travel points should be marked as enchanted.
|
||||
// TODO: Use lore to explain reason of non-availability
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package net.knarcraft.horsetravel.travelpoint;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TravelPointRequirements {
|
||||
|
||||
private List<String> permissions;
|
||||
private double cost;
|
||||
|
||||
}
|
||||
4
src/main/resources/plugin.yml
Normal file
4
src/main/resources/plugin.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
name: HorseTravel
|
||||
version: '1.0-SNAPSHOT'
|
||||
main: net.knarcraft.horsetravel.HorseTravel
|
||||
api-version: '1.21'
|
||||
Reference in New Issue
Block a user