Skip to content

Commit

Permalink
per waypoint max_distance
Browse files Browse the repository at this point in the history
  • Loading branch information
ewof committed Oct 27, 2024
1 parent 7f87b56 commit 1e8834b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ stable:
max: 1 # Max number of plots of this type allowed per town.
travel_with_vehicle: true # If true, player's vehicle will travel with the player.
permission: townywaypoints.landpoint.stable # Permission node required to set a plot to a type of this waypoint, if no permission is set anyone can create this waypoint, grant it in townyperms.yml
# The maximum number of blocks a player can travel between waypoints.
# Uses the global value if -1
max_distance: '-1'
allowed_biomes: # List of biomes this plot type can be created on. If it's not provided the plot type can be created on any biome.
- FOREST
- PLAINS
Expand All @@ -93,6 +96,9 @@ seaport:
max: 1 # Max number of plots of this type allowed per town.
travel_with_vehicle: false # If true, player's vehicle will travel with the player.
permission: townywaypoints.seapoint.seaport # Permission node required to set a plot to a type of this waypoint, if no permission is set anyone can create this waypoint, grant it in townyperms.yml
# The maximum number of blocks a player can travel between waypoints.
# Uses the global value if -1
max_distance: '6000'
allowed_biomes: # List of biomes this plot type can be created on. If it's not provided the plot type can be created on any biome.
- COLD_OCEAN
- DEEP_COLD_OCEAN
Expand Down
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = "net.mvndicraft.townywaypoints"
version = "1.4"
version = "1.5"
description = "Configurable plot types for Towny that players can teleport between."

repositories {
Expand All @@ -17,7 +17,7 @@ repositories {
}

dependencies {
compileOnly("io.papermc.paper:paper-api:1.20-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT")
compileOnly("com.palmergames.bukkit.towny:towny:0.99.5.0")
compileOnly("io.github.townyadvanced.commentedconfiguration:CommentedConfiguration:1.0.0")
compileOnly("com.github.MilkBowl:VaultAPI:1.7")
Expand All @@ -41,7 +41,7 @@ tasks {

archiveFileName.set("${project.name}-${project.version}.jar")
}
assemble {
build {
dependsOn(shadowJar)
}
compileJava {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ private static Waypoint createWaypoint(ConfigurationSection config)
config.getBoolean("sea"),
config.getBoolean("travel_with_vehicle"),
config.getString("permission"),
config.getInt("max_distance"),
config.contains(instance.biomeKey) ? config.getStringList(instance.biomeKey) : new ArrayList<>()
);
}
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/net/mvndicraft/townywaypoints/Waypoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ public final class Waypoint {
private final boolean sea;
private final boolean travelWithVehicle;
private final String permission;
private final int max_distance;
private final List<String> allowedBiomes;

public Waypoint(String name, String mapKey, double cost, double travelCost, int max, boolean sea, boolean travelWithVehicle, String permission, List<String> allowedBiomes)
public Waypoint(String name, String mapKey, double cost, double travelCost, int max, boolean sea, boolean travelWithVehicle, String permission, int max_distance, List<String> allowedBiomes)
{
this.name = name;
this.mapKey = mapKey;
Expand All @@ -23,6 +24,7 @@ public Waypoint(String name, String mapKey, double cost, double travelCost, int
this.sea = sea;
this.travelWithVehicle = travelWithVehicle;
this.permission = permission;
this.max_distance = max_distance;
this.allowedBiomes = allowedBiomes;
}

Expand Down Expand Up @@ -62,6 +64,11 @@ public String getPermission()
return permission;
}

public int getMaxDistance()
{
return max_distance;
}

public List<String> getAllowedBiomes()
{
return allowedBiomes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class TownyWaypointsCommand extends BaseCommand {
@Default
@Description("Lists the version of the plugin")
public static void onTownyWaypoints(CommandSender player) {
player.sendMessage(Component.text(TownyWaypoints.getInstance().toString()));
player.sendMessage(Component.text(TownyWaypoints.getInstance().toString()).toString());
}

@Subcommand("reload")
Expand Down Expand Up @@ -138,10 +138,13 @@ public static void onTravel(Player player, String townName, String waypointName,
return;
}

if (!admin && (TownyWaypointsSettings.getMaxDistance() != -1
&& player.getLocation().distance(loc) > TownyWaypointsSettings.getMaxDistance())) {
double dist = player.getLocation().distance(loc);
int dist_to = waypoint.getMaxDistance() != -1 ? waypoint.getMaxDistance()
: TownyWaypointsSettings.getMaxDistance();

if (!admin && (dist > dist_to)) {
Messaging.sendErrorMsg(player, Translatable.of("msg_err_waypoint_travel_too_far", townBlock.getName(),
TownyWaypointsSettings.getMaxDistance()));
dist_to));
return;
}

Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/waypoints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ stable:
max: 1 # Max number of plots of this type allowed per town.
travel_with_vehicle: true # If true, player's vehicle will travel with the player.
permission: townywaypoints.landpoint.stable # Permission node required to set a plot to a type of this waypoint, if no permission is set anyone can create this waypoint, grant it in townyperms.yml
# The maximum number of blocks a player can travel between waypoints.
# Uses the global value if -1
max_distance: -1
allowed_biomes: # List of biomes this plot type can be created on. If it's not provided the plot type can be created on any biome.
- FOREST
- PLAINS
Expand All @@ -24,6 +27,9 @@ seaport:
max: 1 # Max number of plots of this type allowed per town.
travel_with_vehicle: false # If true, player's vehicle will travel with the player.
permission: townywaypoints.seapoint.seaport # Permission node required to set a plot to a type of this waypoint, if no permission is set anyone can create this waypoint, grant it in townyperms.yml
# The maximum number of blocks a player can travel between waypoints.
# Uses the global value if -1
max_distance: 6000
allowed_biomes: # List of biomes this plot type can be created on. If it's not provided the plot type can be created on any biome.
- COLD_OCEAN
- DEEP_COLD_OCEAN
Expand Down

0 comments on commit 1e8834b

Please sign in to comment.