Ability to create new LinkedBeaconTeleporterItem

master
Ruakij 4 years ago
parent efb18aa711
commit b1169f48db

@ -27,4 +27,15 @@ public class Function {
throw new InvalidPropertiesFormatException("Could not deserialize BlockLocation '"+ serialisedLoc +"'"); throw new InvalidPropertiesFormatException("Could not deserialize BlockLocation '"+ serialisedLoc +"'");
} }
} }
public static String randomString(String alphabet, int length){
char[] alphabetChars = alphabet.toCharArray();
String str = "";
Random random = new Random();
for(int i=0; i<length; i++){
str += alphabetChars[random.nextInt(alphabet.length())];
}
return str;
}
} }

@ -1,5 +1,6 @@
package eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter; package eu.ruekov.ruakij.LinkedBeaconTeleporters.linkedBeaconTeleporter;
import eu.ruekov.ruakij.LinkedBeaconTeleporters.Function;
import org.bukkit.Location; import org.bukkit.Location;
/** /**
@ -10,6 +11,9 @@ public abstract class LinkedBeaconTeleporter {
// Persistent id for linked-beacons // Persistent id for linked-beacons
public String teleporterId; public String teleporterId;
LinkedBeaconTeleporter(){
this.teleporterId = Function.randomString("abcdefghijklmnopqrstuvwxyz0123456789", 10);
}
public LinkedBeaconTeleporter(String teleporterId){ public LinkedBeaconTeleporter(String teleporterId){
this.teleporterId = teleporterId; this.teleporterId = teleporterId;
} }

@ -13,6 +13,12 @@ public class LinkedBeaconTeleporterItem extends LinkedBeaconTeleporter {
// INFO: Safe to store as its always cloned by bukkit // INFO: Safe to store as its always cloned by bukkit
ItemStack item; ItemStack item;
public LinkedBeaconTeleporterItem(ItemStack item){
// Create a new LinkedBeaconTeleporter
super();
this.item = item;
}
public LinkedBeaconTeleporterItem(String teleporterId, ItemStack item) { public LinkedBeaconTeleporterItem(String teleporterId, ItemStack item) {
super(teleporterId); super(teleporterId);

Loading…
Cancel
Save