Skip to content

Instantly share code, notes, and snippets.

@AL1L
Created April 30, 2017 01:16
Show Gist options
  • Save AL1L/90edb10cb1e9ab9e228de6eafb5ccc51 to your computer and use it in GitHub Desktop.
Save AL1L/90edb10cb1e9ab9e228de6eafb5ccc51 to your computer and use it in GitHub Desktop.
package me.diamonddev.craftoblo.menus;
import com.coalesce.gui.PlayerGui;
import com.coalesce.gui.ItemBuilder;
import me.diamonddev.craftoblo.Craftoblo;
import me.diamonddev.craftoblo.abilitys.AbilityObject;
import me.diamonddev.craftoblo.camera.CameraManager;
import me.diamonddev.craftoblo.classes.ClassType;
import me.diamonddev.craftoblo.playerdata.DataManager;
import me.diamonddev.craftoblo.playerdata.PlayerData;
import me.diamonddev.craftoblo.scoreboard.SetupScorboard;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.scheduler.BukkitRunnable;
public class ClassSelectionMenu extends PlayerGui {
public ClassSelectionMenu() {
super(Craftoblo.gi(), 9, ChatColor.RED + "" + ChatColor.UNDERLINE + "Class Selector");
int count = 1;
for (ClassType classType : ClassType.getRealClasses()) {
setItem(count, player -> classType.getIcon(),
(player, clickType) -> {
switch (classType) {
case MONK:
player.playSound(player.getLocation(), Sound.ENTITY_ELDER_GUARDIAN_CURSE, 1, 1);
break;
case WIZARD:
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1);
break;
case CRUSADER:
player.playSound(player.getLocation(), Sound.BLOCK_SHULKER_BOX_OPEN, 1, 1);
break;
case BARBARIAN:
player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_PLACE, 1, 1);
break;
case NECROMANCER:
player.playSound(player.getLocation(), Sound.ENTITY_ENDERDRAGON_GROWL, 1, 1);
break;
case DEMON_HUNTER:
new BukkitRunnable() {
int times = 3;
public void run() {
player.playSound(player.getLocation(), Sound.ENTITY_ARROW_SHOOT, 1, 1);
--times;
if (times == 0)
this.cancel();
}
}.runTaskTimer(Craftoblo.gi(), 0, 3);
break;
case WITCH_DOCTOR:
player.playSound(player.getLocation(), Sound.ENTITY_WITCH_AMBIENT, 1, 1);
break;
default:
player.sendMessage("ERROR!");
player.closeInventory();
break;
}
player.sendMessage(ChatColor.AQUA + "Your class was set to " + classType.getFullName(ChatColor.BOLD) + ChatColor.AQUA + ".");
DataManager.getPlayerData(player.getUniqueId()).setPlayerClass(classType.toString());
PlayerData data = DataManager.getPlayerData(player.getUniqueId());
String playerClass = classType.toString();
if (!DataManager.getPlayerData(player.getUniqueId()).getData()
.contains(ClassType.valueOf(playerClass.toUpperCase()).name() + ".orb"))
DataManager.getPlayerData(player.getUniqueId()).setOrb(100, ClassType.valueOf(playerClass.toUpperCase()));
PlayerInventory pinv = player.getInventory();
pinv.clear();
AbilityObject[] abilitys = data.getActionBar(data.getPlayerClassType());
pinv.setHeldItemSlot(7);
for (int i = 0; i < abilitys.length; i++) {
pinv.setItem(i, abilitys[i].getItem(player));
}
player.closeInventory();
SetupScorboard.set(player);
CameraManager.getManager().detach(player);
CameraManager.getManager().attach(player, 5, 5, 5);
});
count++;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment