From 7e6601d56d7503592e0312eef0645339309e4aed Mon Sep 17 00:00:00 2001 From: Ruakij Date: Tue, 11 May 2021 12:46:03 +0200 Subject: [PATCH] Implemented config-option id --- .../linkedBeaconTeleporter/LinkedBeaconTeleporter.java | 4 +++- .../linkedBeaconTeleporter/LinkedBeaconTeleporterManager.java | 4 ++++ src/main/resources/config.yml | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporter.java b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporter.java index 38f6230..3cf4625 100644 --- a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporter.java +++ b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporter.java @@ -11,6 +11,8 @@ import java.util.List; * Describes a placed-beacon-teleporter in the world */ public abstract class LinkedBeaconTeleporter { + static String id_alphabet = "abcdefghijklmnopqrstuvwxyz0123456789"; + static int id_length = 10; // Persistent id for linked-beacons public String teleporterId; @@ -19,7 +21,7 @@ public abstract class LinkedBeaconTeleporter { protected List linkedBeaconTeleporters = new ArrayList<>(); LinkedBeaconTeleporter(){ - this.teleporterId = Function.randomString("abcdefghijklmnopqrstuvwxyz0123456789", 10); + this.teleporterId = Function.randomString(id_alphabet, id_length); linkedBeaconTeleporters = new ArrayList<>(); } diff --git a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterManager.java b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterManager.java index d82d71f..c013647 100644 --- a/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterManager.java +++ b/src/main/java/eu/ruekov/ruakij/LinkedBeaconTeleporters/linkedBeaconTeleporter/LinkedBeaconTeleporterManager.java @@ -34,6 +34,10 @@ public class LinkedBeaconTeleporterManager { Main.config.getStringList("item.lore") ); + // Load settings + LinkedBeaconTeleporter.id_alphabet = Main.config.getString("id.alphabet"); + LinkedBeaconTeleporter.id_length = Main.config.getInt("id.length"); + // Construct & add crafting-receipes constructAndAddRecipes(); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 2d377a5..f2dfd78 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -7,7 +7,7 @@ item: - '§8§o%id%' -id: # TODO +id: # Alphabet to use for random-generation alphabet: 'abcdefghijklmnopqrstuvwxyz0123456789' # Length of id