Ability to create new LinkedBeaconTeleporterItem
This commit is contained in:
parent
efb18aa711
commit
b1169f48db
@ -27,4 +27,15 @@ public class Function {
|
||||
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;
|
||||
|
||||
import eu.ruekov.ruakij.LinkedBeaconTeleporters.Function;
|
||||
import org.bukkit.Location;
|
||||
|
||||
/**
|
||||
@ -10,6 +11,9 @@ public abstract class LinkedBeaconTeleporter {
|
||||
// Persistent id for linked-beacons
|
||||
public String teleporterId;
|
||||
|
||||
LinkedBeaconTeleporter(){
|
||||
this.teleporterId = Function.randomString("abcdefghijklmnopqrstuvwxyz0123456789", 10);
|
||||
}
|
||||
public LinkedBeaconTeleporter(String teleporterId){
|
||||
this.teleporterId = teleporterId;
|
||||
}
|
||||
|
@ -13,6 +13,12 @@ public class LinkedBeaconTeleporterItem extends LinkedBeaconTeleporter {
|
||||
// INFO: Safe to store as its always cloned by bukkit
|
||||
ItemStack item;
|
||||
|
||||
public LinkedBeaconTeleporterItem(ItemStack item){
|
||||
// Create a new LinkedBeaconTeleporter
|
||||
super();
|
||||
|
||||
this.item = item;
|
||||
}
|
||||
public LinkedBeaconTeleporterItem(String teleporterId, ItemStack item) {
|
||||
super(teleporterId);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user