|
@ -9,7 +9,6 @@ import java.util.UUID; |
|
|
|
|
|
|
|
|
import org.bukkit.Bukkit; |
|
|
import org.bukkit.Bukkit; |
|
|
import org.bukkit.ChatColor; |
|
|
import org.bukkit.ChatColor; |
|
|
import org.bukkit.Material; |
|
|
|
|
|
import org.bukkit.entity.HumanEntity; |
|
|
import org.bukkit.entity.HumanEntity; |
|
|
import org.bukkit.entity.Player; |
|
|
import org.bukkit.entity.Player; |
|
|
import org.bukkit.event.EventHandler; |
|
|
import org.bukkit.event.EventHandler; |
|
@ -18,6 +17,7 @@ import org.bukkit.event.inventory.InventoryClickEvent; |
|
|
import org.bukkit.event.inventory.InventoryCloseEvent; |
|
|
import org.bukkit.event.inventory.InventoryCloseEvent; |
|
|
import org.bukkit.inventory.Inventory; |
|
|
import org.bukkit.inventory.Inventory; |
|
|
import org.bukkit.inventory.ItemStack; |
|
|
import org.bukkit.inventory.ItemStack; |
|
|
|
|
|
import org.bukkit.inventory.meta.ItemMeta; |
|
|
|
|
|
|
|
|
import com.entryrise.afkguard.Main; |
|
|
import com.entryrise.afkguard.Main; |
|
|
import com.entryrise.afkguard.mineutils.ItemBuilder; |
|
|
import com.entryrise.afkguard.mineutils.ItemBuilder; |
|
@ -49,7 +49,7 @@ public class CaptchaGUI implements Listener { |
|
|
public static class CaptchaData { |
|
|
public static class CaptchaData { |
|
|
|
|
|
|
|
|
public CaptchaCategory category; |
|
|
public CaptchaCategory category; |
|
|
public Material example; |
|
|
|
|
|
|
|
|
public ItemStack example; |
|
|
public Inventory inv; |
|
|
public Inventory inv; |
|
|
|
|
|
|
|
|
public int counter; |
|
|
public int counter; |
|
@ -145,7 +145,7 @@ public class CaptchaGUI implements Listener { |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Main.captchaResult(p, itm.getType()); |
|
|
|
|
|
|
|
|
Main.captchaResult(p, itm); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -190,27 +190,33 @@ public class CaptchaGUI implements Listener { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static void setRandomExample(Inventory inv, CaptchaData cd) { |
|
|
public static void setRandomExample(Inventory inv, CaptchaData cd) { |
|
|
ItemStack itm = new ItemBuilder(Main.config, "settings.captcha.gui.example").setType(cd.example.name()).build(); |
|
|
|
|
|
|
|
|
ItemStack itm = new ItemBuilder(Main.config, "settings.captcha.gui.example").build(); |
|
|
|
|
|
ItemMeta imeta = itm.getItemMeta(); |
|
|
|
|
|
itm = cd.example.clone(); |
|
|
|
|
|
itm.setItemMeta(imeta); |
|
|
inv.setItem(4, itm); |
|
|
inv.setItem(4, itm); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static void setRandomAnswers(Inventory inv, CaptchaData cd) { |
|
|
public static void setRandomAnswers(Inventory inv, CaptchaData cd) { |
|
|
List<Material> mats = cd.category.getShuffledFiller(); |
|
|
|
|
|
|
|
|
List<ItemStack> mats = cd.category.getShuffledFiller(); |
|
|
|
|
|
|
|
|
for (int i = 0; i < filler.size(); i++) { |
|
|
for (int i = 0; i < filler.size(); i++) { |
|
|
Material mat = mats.get(i); |
|
|
|
|
|
|
|
|
ItemStack mat = mats.get(i); |
|
|
int slot = filler.get(i); |
|
|
int slot = filler.get(i); |
|
|
|
|
|
|
|
|
ItemStack itm = prepareItemStack(mat); |
|
|
|
|
|
inv.setItem(slot, itm); |
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
// ItemStack itm = prepareItemStack(mat);
|
|
|
|
|
|
inv.setItem(slot, mat); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
inv.setItem(filler.get(sr.nextInt(filler.size())), prepareItemStack(cd.category.getRandom(cd.example))); |
|
|
|
|
|
|
|
|
inv.setItem(filler.get(sr.nextInt(filler.size())), cd.category.getRandom(cd.example)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static ItemStack prepareItemStack(Material mat) { |
|
|
|
|
|
ItemStack itm = new ItemBuilder(Main.config, "settings.captcha.gui.item").setType(mat.name()).build(); |
|
|
|
|
|
return itm; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// private static ItemStack prepareItemStack(ItemStack type) {
|
|
|
|
|
|
// ItemStack itm = new ItemBuilder(Main.config, "settings.captcha.gui.item").build();
|
|
|
|
|
|
// ItemMeta imeta = itm.getItemMeta();
|
|
|
|
|
|
// itm = type.clone();
|
|
|
|
|
|
// itm.setItemMeta(imeta);
|
|
|
|
|
|
// return itm;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|