package com.agricraft.agricore.templates;

import com.agricraft.agricore.core.AgriCore;
import com.google.gson.JsonObject;

public class AgriMutationTrigger {
    private final String id;
    private final boolean required;
    private final boolean guaranteed;
    private final JsonObject parameters;

    public AgriMutationTrigger() {
        this.id = "none";
        this.required = false;
        this.guaranteed = false;
        this.parameters = new JsonObject();
    }

    public AgriMutationTrigger(String id, boolean required, boolean guaranteed, JsonObject parameters) {
        this.id = id;
        this.required = required;
        this.guaranteed = guaranteed;
        this.parameters = parameters;
    }

    public String getId() {
        return this.id;
    }

    public boolean isRequired() {
        return this.required;
    }

    public boolean isGuaranteed() {
        return this.guaranteed;
    }

    public JsonObject getParameters() {
        return this.parameters;
    }

    public boolean validate() {
        boolean valid = AgriCore.getValidator().isValidMutationTrigger(this.getId(), this.getParameters());
        if(!valid) {
            AgriCore.getCoreLogger().info("Invalid Mutation trigger {0}: {1}", this.getId(), this.getParameters());
        }
        return valid;
    }
}

@@ -235,23 +235,22 @@
 e final 
-boolean
+double
  guarant
@@ -248,24 +248,30 @@
 e guaranteed
+Chance
 ;%0A    privat
@@ -417,24 +417,26 @@
 aranteed
- = false
+Chance = 0
 ;%0A      
@@ -540,23 +540,22 @@
 quired, 
-boolean
+double
  guarant
@@ -557,16 +557,22 @@
 aranteed
+Chance
 , JsonOb
@@ -669,16 +669,22 @@
 aranteed
+Chance
  = guara
@@ -684,24 +684,30 @@
 = guaranteed
+Chance
 ;%0A        th
@@ -882,26 +882,26 @@
  public 
-boolean is
+double get
 Guarante
@@ -902,16 +902,22 @@
 aranteed
+Chance
 () %7B%0A   
@@ -943,16 +943,22 @@
 aranteed
+Chance
 ;%0A    %7D%0A
@@ -1081,24 +1081,12 @@
     
-boolean valid = 
+if(!
 Agri
@@ -1163,26 +1163,31 @@
 eters())
-;%0A
+) %7B%0A   
         
 if(!vali
@@ -1182,32 +1182,8 @@
     
-if(!valid) %7B%0A           
  Agr
@@ -1243,16 +1243,318 @@
 %7B0%7D: %7B1%7D
+%22, this.getId(), this.getParameters());%0A            return false;%0A        %7D%0A        if(this.getGuaranteedChance() %3C 0 %7C%7C this.getGuaranteedChance() %3E 1) %7B%0A            AgriCore.getCoreLogger().info(%22Invalid Mutation trigger guaranteed probability: %7B1%7D, the value must be between 0 and 1 (both inclusive)
 %22, this.
@@ -1577,32 +1577,58 @@
 tParameters());%0A
+            return false;%0A
         %7D%0A      
@@ -1636,21 +1636,20 @@
  return 
-valid
+true
 ;%0A    %7D%0A

Make mutation trigger guarantee a probability