code refactoring
This commit is contained in:
parent
fc9db70d90
commit
1829e2a80b
17 changed files with 84 additions and 65 deletions
|
@ -6,6 +6,7 @@ import static me.unurled.sacredrealms.sr.utils.SRPlayerUtils.syncSRToPlayer;
|
|||
import me.unurled.sacredrealms.sr.components.attributes.Attribute;
|
||||
import me.unurled.sacredrealms.sr.components.player.PlayerManager;
|
||||
import me.unurled.sacredrealms.sr.components.player.SRPlayer;
|
||||
import me.unurled.sacredrealms.sr.managers.Manager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
@ -42,7 +43,7 @@ public class AttributeItem extends AbstractItem {
|
|||
double value = 0;
|
||||
|
||||
if (targetPlayer != null) {
|
||||
PlayerManager playerManager = PlayerManager.getInstance(PlayerManager.class);
|
||||
PlayerManager playerManager = Manager.getInstance(PlayerManager.class);
|
||||
SRPlayer sp = playerManager.getPlayer(targetPlayer.getUniqueId());
|
||||
if (sp != null) value = sp.getAttribute(attribute);
|
||||
}
|
||||
|
@ -83,7 +84,7 @@ public class AttributeItem extends AbstractItem {
|
|||
@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {
|
||||
|
||||
if (targetPlayer != null) {
|
||||
PlayerManager playerManager = PlayerManager.getInstance(PlayerManager.class);
|
||||
PlayerManager playerManager = Manager.getInstance(PlayerManager.class);
|
||||
SRPlayer sp = playerManager.getPlayer(targetPlayer.getUniqueId());
|
||||
if (sp != null) {
|
||||
if (clickType == ClickType.LEFT) {
|
||||
|
|
|
@ -47,5 +47,7 @@ public class EntityArmorItem extends AbstractItem {
|
|||
*/
|
||||
@Override
|
||||
public void handleClick(
|
||||
@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {}
|
||||
@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {
|
||||
/* TODO need to implements this */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,5 +42,7 @@ public class EntityBehaviorItem extends AbstractItem {
|
|||
*/
|
||||
@Override
|
||||
public void handleClick(
|
||||
@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {}
|
||||
@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {
|
||||
/* TODO need to implements this */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,5 +42,7 @@ public class EntityExpItem extends AbstractItem {
|
|||
*/
|
||||
@Override
|
||||
public void handleClick(
|
||||
@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {}
|
||||
@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {
|
||||
/* TODO need to implements this */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,5 +42,7 @@ public class EntityItemDisplay extends AbstractItem {
|
|||
*/
|
||||
@Override
|
||||
public void handleClick(
|
||||
@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {}
|
||||
@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {
|
||||
/* TODO need to implements this */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,5 +42,7 @@ public class EntityLevelItem extends AbstractItem {
|
|||
*/
|
||||
@Override
|
||||
public void handleClick(
|
||||
@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {}
|
||||
@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {
|
||||
/* TODO need to implements this */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,5 +35,7 @@ public class EntityLootItem extends AbstractItem {
|
|||
*/
|
||||
@Override
|
||||
public void handleClick(
|
||||
@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {}
|
||||
@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {
|
||||
/* TODO need to implements this */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,5 +42,7 @@ public class EntityNameItem extends AbstractItem {
|
|||
*/
|
||||
@Override
|
||||
public void handleClick(
|
||||
@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {}
|
||||
@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {
|
||||
/* TODO need to implements this */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,5 +48,7 @@ public class EntityStatsItem extends AbstractItem {
|
|||
*/
|
||||
@Override
|
||||
public void handleClick(
|
||||
@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {}
|
||||
@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {
|
||||
/* TODO need to implements this */
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ import xyz.xenondevs.invui.item.builder.ItemBuilder;
|
|||
import xyz.xenondevs.invui.item.impl.SimpleItem;
|
||||
|
||||
public class EntityTypeGUI {
|
||||
private EntityTypeGUI() {}
|
||||
|
||||
public static @NotNull Gui listGui() {
|
||||
EntityManager em = EntityManager.getInstance(EntityManager.class);
|
||||
List<Item> items =
|
||||
|
@ -23,20 +25,18 @@ public class EntityTypeGUI {
|
|||
.map(type -> new SimpleItem(new ItemBuilder(type.getItem())))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Gui gui =
|
||||
PagedGui.items()
|
||||
.setStructure(
|
||||
"# # # # # # # # #",
|
||||
"# X X X X X X X #",
|
||||
"# X X X X X X X #",
|
||||
"# X X X X X X X #",
|
||||
"# # # < # > # # #")
|
||||
.addIngredient('X', Markers.CONTENT_LIST_SLOT_HORIZONTAL)
|
||||
.addIngredient('<', new BackItem())
|
||||
.addIngredient('>', new ForwardItem())
|
||||
.setContent(items)
|
||||
.build();
|
||||
return gui;
|
||||
return PagedGui.items()
|
||||
.setStructure(
|
||||
"# # # # # # # # #",
|
||||
"# X X X X X X X #",
|
||||
"# X X X X X X X #",
|
||||
"# X X X X X X X #",
|
||||
"# # # < # > # # #")
|
||||
.addIngredient('X', Markers.CONTENT_LIST_SLOT_HORIZONTAL)
|
||||
.addIngredient('<', new BackItem())
|
||||
.addIngredient('>', new ForwardItem())
|
||||
.setContent(items)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static @NotNull Gui createGui(SREntityType type) {
|
||||
|
@ -44,30 +44,28 @@ public class EntityTypeGUI {
|
|||
Item border =
|
||||
new SimpleItem(new ItemBuilder(Material.BLACK_STAINED_GLASS_PANE).setDisplayName("§r"));
|
||||
|
||||
Gui gui =
|
||||
Gui.normal()
|
||||
.setStructure(
|
||||
"# # # # # # # # #",
|
||||
"# T B O I S N L #", // Type, Behavior, lOot, Item display, Stats, Name, Level
|
||||
"# X X X P X X X #", // exPerience
|
||||
"# H C E B X M A #", // Helmet, Chestplate, lEgging, Boots, Main hand, second hAnd
|
||||
"# # # # # # # # #")
|
||||
.addIngredient('#', border)
|
||||
.addIngredient('T', new EntityTypeItem(type))
|
||||
.addIngredient('B', new EntityBehaviorItem(type))
|
||||
.addIngredient('O', new EntityLootItem())
|
||||
.addIngredient('I', new EntityItemDisplay(type))
|
||||
.addIngredient('S', new EntityStatsItem(type))
|
||||
.addIngredient('N', new EntityNameItem(type))
|
||||
.addIngredient('L', new EntityLevelItem(type))
|
||||
.addIngredient('P', new EntityExpItem(type))
|
||||
.addIngredient('H', new EntityArmorItem(type, 0))
|
||||
.addIngredient('C', new EntityArmorItem(type, 1))
|
||||
.addIngredient('E', new EntityArmorItem(type, 2))
|
||||
.addIngredient('B', new EntityArmorItem(type, 3))
|
||||
.addIngredient('M', new EntityArmorItem(type, 4))
|
||||
.addIngredient('A', new EntityArmorItem(type, 5))
|
||||
.build();
|
||||
return gui;
|
||||
return Gui.normal()
|
||||
.setStructure(
|
||||
"# # # # # # # # #",
|
||||
"# T B O I S N L #", // Type, Behavior, lOot, Item display, Stats, Name, Level
|
||||
"# X X X P X X X #", // exPerience
|
||||
"# H C E B X M A #", // Helmet, Chestplate, lEgging, Boots, Main hand, second hAnd
|
||||
"# # # # # # # # #")
|
||||
.addIngredient('#', border)
|
||||
.addIngredient('T', new EntityTypeItem(type))
|
||||
.addIngredient('B', new EntityBehaviorItem(type))
|
||||
.addIngredient('O', new EntityLootItem())
|
||||
.addIngredient('I', new EntityItemDisplay(type))
|
||||
.addIngredient('S', new EntityStatsItem(type))
|
||||
.addIngredient('N', new EntityNameItem(type))
|
||||
.addIngredient('L', new EntityLevelItem(type))
|
||||
.addIngredient('P', new EntityExpItem(type))
|
||||
.addIngredient('H', new EntityArmorItem(type, 0))
|
||||
.addIngredient('C', new EntityArmorItem(type, 1))
|
||||
.addIngredient('E', new EntityArmorItem(type, 2))
|
||||
.addIngredient('B', new EntityArmorItem(type, 3))
|
||||
.addIngredient('M', new EntityArmorItem(type, 4))
|
||||
.addIngredient('A', new EntityArmorItem(type, 5))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue