Adding a kit preview during kit selection #93
@ -10,8 +10,7 @@ import de.steamwar.fightsystem.kit.KitManager;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
class Commands {
|
public class Commands {
|
||||||
|
|
||||||
private Commands(){}
|
private Commands(){}
|
||||||
|
|
||||||
private static void errNoTeam(Player p){
|
private static void errNoTeam(Player p){
|
||||||
@ -176,7 +175,7 @@ class Commands {
|
|||||||
fightTeam.removePlayer(target);
|
fightTeam.removePlayer(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void kit(Player p, String kitName){
|
public static void kit(Player p, String kitName){
|
||||||
if(checkSetup(p))
|
if(checkSetup(p))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -82,10 +82,7 @@ public class GUI {
|
|||||||
iconList.add(new Pair<>(new SWItem(Material.LEATHER_CHESTPLATE, k.getName(), null, !k.isMemberAllowed(), null), k));
|
iconList.add(new Pair<>(new SWItem(Material.LEATHER_CHESTPLATE, k.getName(), null, !k.isMemberAllowed(), null), k));
|
||||||
}
|
}
|
||||||
|
|
||||||
SWListInv<Kit> inv = new SWListInv<>(p, "Kitauswahl", (ClickType click, Kit k) -> {
|
SWListInv<Kit> inv = new SWListInv<>(p, "Kitauswahl", (ClickType click, Kit k) -> k.preview(p), iconList);
|
||||||
Commands.kit(p, k.getName());
|
|
||||||
p.closeInventory();
|
|
||||||
}, iconList);
|
|
||||||
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
|
||||||
inv.open();
|
inv.open();
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
package de.steamwar.fightsystem.kit;
|
package de.steamwar.fightsystem.kit;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.commands.Commands;
|
||||||
|
import de.steamwar.fightsystem.commands.GUI;
|
||||||
|
import de.steamwar.inventory.SWInventory;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Kit {
|
public class Kit {
|
||||||
@ -70,4 +75,47 @@ public class Kit {
|
|||||||
section.set("MemberAllowed", memberAllowed);
|
section.set("MemberAllowed", memberAllowed);
|
||||||
section.set("Effects", effects);
|
section.set("Effects", effects);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens a kit preview with the options to go back to kit selection or to select the kit.
|
||||||
|
* @param player
|
||||||
|
*/
|
||||||
|
public void preview(Player player){
|
||||||
|
SWInventory inv = new SWInventory(player, 54, name);
|
||||||
|
|
||||||
|
//36 = Inventargröße
|
||||||
|
for(int i = 0; i < 36; i++){
|
||||||
|
SWItem item = new SWItem();
|
||||||
|
item.setItemStack(inventory[i]);
|
||||||
|
inv.setItem(i, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(armor != null){
|
||||||
|
for(int i = 0; i < 4; i++){
|
||||||
|
SWItem item = new SWItem();
|
||||||
|
item.setItemStack(armor[i]);
|
||||||
|
inv.setItem(36 + i, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(effects != null){
|
||||||
|
Iterator<PotionEffect> it = effects.iterator();
|
||||||
|
int pos = 44;
|
||||||
|
while(it.hasNext()){
|
||||||
|
PotionEffect effect = it.next();
|
||||||
|
SWItem item = new SWItem(SWItem.getMaterial("POTION"), effect.getType().getName());
|
||||||
|
inv.setItem(pos, item);
|
||||||
|
pos--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inv.setCallback(-999, (click) -> GUI.kitSelection(player));
|
||||||
|
inv.addCloseCallback((click) -> GUI.kitSelection(player));
|
||||||
|
inv.setItem(45, SWItem.getDye(10), (byte)10, "§aKit wählen", (click) -> {
|
||||||
|
Commands.kit(player, name);
|
||||||
|
player.closeInventory();
|
||||||
|
});
|
||||||
|
inv.setItem(53, SWItem.getDye(14), (byte)14, "§cZurück", (click) -> GUI.kitSelection(player));
|
||||||
|
inv.open();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren