Everything
This commit is contained in:
parent
8597361e79
commit
30e0896651
14
.idea/deployment.xml
generated
Normal file
14
.idea/deployment.xml
generated
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PublishConfigData" serverName="local">
|
||||
<serverData>
|
||||
<paths name="local">
|
||||
<serverdata>
|
||||
<mappings>
|
||||
<mapping local="$PROJECT_DIR$" web="/" />
|
||||
</mappings>
|
||||
</serverdata>
|
||||
</paths>
|
||||
</serverData>
|
||||
</component>
|
||||
</project>
|
10
.idea/webServers.xml
generated
Normal file
10
.idea/webServers.xml
generated
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="WebServers">
|
||||
<option name="servers">
|
||||
<webServer id="88fccb5d-12b3-48ac-8c70-cf04d03c7b0b" name="local" url="http://localhost">
|
||||
<fileTransfer mountedRoot="D:\LQ_Files\server\plugins" accessType="MOUNT" port="0" />
|
||||
</webServer>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
@ -1,6 +1,7 @@
|
||||
package io.github.officereso;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class InventoryItem {
|
||||
public ItemStack itemStack;
|
||||
@ -15,6 +16,7 @@ public class InventoryItem {
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Integer getInvPosition() {
|
||||
return invPosition;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.github.officereso;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
@ -12,11 +13,11 @@ import java.util.List;
|
||||
|
||||
public class Kit {
|
||||
private final String name;
|
||||
private List<InventoryItem> inventoryItemList;
|
||||
private final List<InventoryItem> inventoryItemList;
|
||||
private int cost;
|
||||
private int viewPosition;
|
||||
private String lore;
|
||||
private Type type;
|
||||
private final int viewPosition;
|
||||
private final List<String> lore;
|
||||
private final Type type;
|
||||
|
||||
|
||||
/**
|
||||
@ -26,12 +27,20 @@ public class Kit {
|
||||
* @param viewPosition Where the kit will show up in the kit selection inventory.
|
||||
* Must be between 0 and 26.
|
||||
*/
|
||||
public Kit(String name, List<InventoryItem> inventoryItemList, int cost, int viewPosition, String lore, Type type) {
|
||||
this.name = name;
|
||||
public Kit(String name, List<InventoryItem> inventoryItemList, int cost, int viewPosition, List<String> lore, Type type) {
|
||||
this.name = ChatColor.translateAlternateColorCodes('&', name);
|
||||
this.inventoryItemList = inventoryItemList;
|
||||
this.cost = cost;
|
||||
this.viewPosition = viewPosition;
|
||||
this.lore = lore;
|
||||
List<String> _lore = new ArrayList<>();
|
||||
if (lore == null) {
|
||||
this.lore = null;
|
||||
} else {
|
||||
for (String item : lore) {
|
||||
_lore.add(ChatColor.translateAlternateColorCodes('&', item));
|
||||
}
|
||||
this.lore = _lore;
|
||||
}
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@ -61,7 +70,7 @@ public class Kit {
|
||||
return viewPosition;
|
||||
}
|
||||
|
||||
public String getLore() {
|
||||
public List<String> getLore() {
|
||||
return lore;
|
||||
}
|
||||
|
||||
|
58
src/main/java/io/github/officereso/Map.java
Normal file
58
src/main/java/io/github/officereso/Map.java
Normal file
@ -0,0 +1,58 @@
|
||||
package io.github.officereso;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class Map {
|
||||
public List<Location> locations;
|
||||
public String mapName;
|
||||
|
||||
public Map(List<String> stringLocations, String mapName) {
|
||||
List<Location> locations = new ArrayList<>();
|
||||
for (String stringLocation : stringLocations) {
|
||||
String[] split = stringLocation.split(" ");
|
||||
World world = Bukkit.getWorld(split[0]);
|
||||
locations.add(new Location(world, Double.parseDouble(split[1]), Double.parseDouble(split[2]), Double.parseDouble(split[3])));
|
||||
}
|
||||
this.locations = locations;
|
||||
this.mapName = mapName;
|
||||
}
|
||||
|
||||
public Location getSpawnLocation() {
|
||||
TreeMap<Integer, Location> spawns = new TreeMap<>();
|
||||
List<Player> players = new ArrayList<>();
|
||||
for (Entity entity : Objects.requireNonNull(locations.get(0).getWorld()).getEntities()) {
|
||||
if (entity instanceof Player) {
|
||||
players.add((Player) entity);
|
||||
}
|
||||
}
|
||||
for (Location location : locations) {
|
||||
int distance = Integer.MAX_VALUE;
|
||||
for (Player player : players) {
|
||||
if (distance >= player.getLocation().distance(location)) {
|
||||
distance = (int) player.getLocation().distance(location);
|
||||
}
|
||||
}
|
||||
if (distance > 400) {
|
||||
distance = Integer.MAX_VALUE;
|
||||
}
|
||||
while (spawns.get(distance) != null) {
|
||||
distance--;
|
||||
}
|
||||
spawns.put(distance, location);
|
||||
}
|
||||
int amount = (int) (locations.size() * .8);
|
||||
for (int i = 0; i <= amount; i++) {
|
||||
spawns.remove(spawns.firstEntry().getKey());
|
||||
}
|
||||
Random generator = new Random();
|
||||
Object[] values = spawns.values().toArray();
|
||||
Object randomValue = values[generator.nextInt(values.length)];
|
||||
return (Location) randomValue;
|
||||
}
|
||||
}
|
@ -47,41 +47,87 @@ public class PlayerSelectionWrapper {
|
||||
return selectedPotions;
|
||||
}
|
||||
|
||||
public HashMap<Integer, Integer> getGreenSlots() {
|
||||
public HashMap<Integer, Integer> getSelectedSlots() {
|
||||
HashMap<Integer, Integer> slots = new HashMap<>();
|
||||
if (selectedKit != null) {
|
||||
if (selectedKit != null)
|
||||
slots.put(selectedKit.getViewPosition(), 1);
|
||||
}
|
||||
if (selectedHelmet != null) {
|
||||
if (selectedHelmet != null)
|
||||
slots.put(selectedHelmet.getViewPosition(), 1);
|
||||
}
|
||||
if (selectedChestplate != null) {
|
||||
if (selectedChestplate != null)
|
||||
slots.put(selectedChestplate.getViewPosition(), 1);
|
||||
}
|
||||
if (selectedLeggings != null) {
|
||||
if (selectedLeggings != null)
|
||||
slots.put(selectedLeggings.getViewPosition(), 1);
|
||||
}
|
||||
if (selectedBoots != null) {
|
||||
if (selectedBoots != null)
|
||||
slots.put(selectedBoots.getViewPosition(), 1);
|
||||
for (Map.Entry<Kit, Integer> entryKit : selectedPotions.entrySet()) {
|
||||
if (entryKit.getValue() == null)
|
||||
continue;
|
||||
slots.put(entryKit.getKey().getViewPosition(), entryKit.getValue());
|
||||
}
|
||||
if (selectedPotions != null) {
|
||||
for (Map.Entry<Kit, Integer> entryKit : selectedPotions.entrySet()) {
|
||||
if (entryKit.getValue() == null)
|
||||
continue;
|
||||
slots.put(entryKit.getKey().getViewPosition(), entryKit.getValue());
|
||||
}
|
||||
}
|
||||
if (selectedAdditions != null) {
|
||||
for (Map.Entry<Kit, Integer> entryKit : selectedAdditions.entrySet()) {
|
||||
if (entryKit.getValue() == null)
|
||||
continue;
|
||||
slots.put(entryKit.getKey().getViewPosition(), entryKit.getValue());
|
||||
}
|
||||
for (Map.Entry<Kit, Integer> entryKit : selectedAdditions.entrySet()) {
|
||||
if (entryKit.getValue() == null)
|
||||
continue;
|
||||
slots.put(entryKit.getKey().getViewPosition(), entryKit.getValue());
|
||||
}
|
||||
|
||||
return slots;
|
||||
}
|
||||
|
||||
public void fillInventory() {
|
||||
player.getInventory().clear();
|
||||
HashMap<Kit, Integer> allKits = new HashMap<>();
|
||||
allKits.put(selectedKit, 1);
|
||||
allKits.put(selectedHelmet, 1);
|
||||
allKits.put(selectedChestplate, 1);
|
||||
allKits.put(selectedLeggings, 1);
|
||||
allKits.put(selectedBoots, 1);
|
||||
for (Map.Entry<Kit, Integer> entryKit : selectedPotions.entrySet()) {
|
||||
allKits.put(entryKit.getKey(), entryKit.getValue());
|
||||
}
|
||||
for (Map.Entry<Kit, Integer> entryKit : selectedAdditions.entrySet()) {
|
||||
allKits.put(entryKit.getKey(), entryKit.getValue());
|
||||
}
|
||||
|
||||
for (Map.Entry<Kit, Integer> entryKit : allKits.entrySet()) {
|
||||
if (entryKit.getKey() == null) {
|
||||
continue;
|
||||
}
|
||||
for (InventoryItem item : entryKit.getKey().getInventoryItemList()) {
|
||||
if (entryKit.getKey().getType() == Kit.Type.HELMET) {
|
||||
player.getInventory().setHelmet(item.getItemStack());
|
||||
continue;
|
||||
}
|
||||
if (entryKit.getKey().getType() == Kit.Type.CHESTPLATE) {
|
||||
player.getInventory().setChestplate(item.getItemStack());
|
||||
continue;
|
||||
}
|
||||
if (entryKit.getKey().getType() == Kit.Type.LEGGINGS) {
|
||||
player.getInventory().setLeggings(item.getItemStack());
|
||||
continue;
|
||||
}
|
||||
if (entryKit.getKey().getType() == Kit.Type.BOOTS) {
|
||||
player.getInventory().setBoots(item.getItemStack());
|
||||
continue;
|
||||
}
|
||||
if (item.getInvPosition() == null) {
|
||||
player.getInventory().addItem(item.getItemStack());
|
||||
continue;
|
||||
}
|
||||
player.getInventory().setItem(item.getInvPosition(), item.getItemStack());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clean() {
|
||||
selectedKit = null;
|
||||
selectedHelmet = null;
|
||||
selectedChestplate = null;
|
||||
selectedLeggings = null;
|
||||
selectedBoots = null;
|
||||
selectedPotions = new HashMap<>();
|
||||
selectedAdditions = new HashMap<>();
|
||||
}
|
||||
|
||||
public void setSelectedAdditions(HashMap<Kit, Integer> selectedAdditions) {
|
||||
this.selectedAdditions = selectedAdditions;
|
||||
}
|
||||
@ -89,7 +135,7 @@ public class PlayerSelectionWrapper {
|
||||
public void addAdditions(Kit kit, int amount) {
|
||||
selectedAdditions.putIfAbsent(kit, 0);
|
||||
if (selectedAdditions.get(kit) + amount <= 0) {
|
||||
selectedAdditions.put(kit, null);
|
||||
selectedAdditions.remove(kit);
|
||||
return;
|
||||
}
|
||||
selectedAdditions.put(kit, selectedAdditions.get(kit) + amount);
|
||||
@ -114,7 +160,7 @@ public class PlayerSelectionWrapper {
|
||||
public void addPotions(Kit kit, int amount) {
|
||||
selectedPotions.putIfAbsent(kit, 0);
|
||||
if (selectedPotions.get(kit) + amount <= 0) {
|
||||
selectedPotions.put(kit, null);
|
||||
selectedPotions.remove(kit);
|
||||
return;
|
||||
}
|
||||
selectedPotions.put(kit, selectedPotions.get(kit) + amount);
|
||||
@ -127,4 +173,25 @@ public class PlayerSelectionWrapper {
|
||||
public void setSelectedKit(Kit selectedKit) {
|
||||
this.selectedKit = selectedKit;
|
||||
}
|
||||
|
||||
public int getTotalXpCost() {
|
||||
int cost = 0;
|
||||
if (selectedKit != null)
|
||||
cost += selectedKit.getCost();
|
||||
if (selectedHelmet != null)
|
||||
cost += selectedHelmet.getCost();
|
||||
if (selectedChestplate != null)
|
||||
cost += selectedChestplate.getCost();
|
||||
if (selectedLeggings != null)
|
||||
cost += selectedLeggings.getCost();
|
||||
if (selectedBoots != null)
|
||||
cost += selectedBoots.getCost();
|
||||
for (Map.Entry<Kit, Integer> entryKit : selectedPotions.entrySet()) {
|
||||
cost += entryKit.getKey().getCost() * entryKit.getValue();
|
||||
}
|
||||
for (Map.Entry<Kit, Integer> entryKit : selectedAdditions.entrySet()) {
|
||||
cost += entryKit.getKey().getCost() * entryKit.getValue();
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package io.github.officereso;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -30,11 +29,14 @@ import java.util.Map;
|
||||
|
||||
public class pvp extends JavaPlugin implements Listener {
|
||||
private final FileConfiguration config = this.getConfig();
|
||||
private HashMap<Integer, Kit> kits = configToKit();
|
||||
private HashMap<Integer, Kit> kits;
|
||||
private HashMap<Integer, Kit> defaultKits = new HashMap<>();
|
||||
private HashMap<Player, Menu> signMenus = new HashMap<>();
|
||||
private HashMap<Player, PlayerSelectionWrapper> selectedKits = new HashMap<>();
|
||||
Block signBlock;
|
||||
|
||||
private List<io.github.officereso.Map> maps;
|
||||
private io.github.officereso.Map enabledMap;
|
||||
Location signBlock;
|
||||
private boolean giveSteak;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
@ -51,93 +53,182 @@ public class pvp extends JavaPlugin implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onClick(PlayerInteractEvent event) {
|
||||
|
||||
Menu menu;
|
||||
Player player = event.getPlayer();
|
||||
if (signMenus.get(player) == null) {
|
||||
signMenus.put(player, ChestMenu.builder(6).title("PVP Selection Menu").build());
|
||||
menu = signMenus.get(player);
|
||||
|
||||
PlayerSelectionWrapper selectionWrapper;
|
||||
if (selectedKits.get(player) == null) { // Gets the selectionWrapper
|
||||
selectionWrapper = new PlayerSelectionWrapper(player); // for the current player.
|
||||
selectedKits.put(player, selectionWrapper); // Makes one if doesnt exist.
|
||||
} else {
|
||||
selectionWrapper = selectedKits.get(player);
|
||||
}
|
||||
|
||||
for (Map.Entry<Integer, Kit> entryKit : kits.entrySet()) {
|
||||
Kit kit = entryKit.getValue();
|
||||
int slotPos = entryKit.getKey();
|
||||
Slot slot = menu.getSlot(slotPos);
|
||||
slot.setItem(kit.getInventoryItemList().get(0).getItemStack());
|
||||
slotFunction(slot, kit, selectionWrapper, menu);
|
||||
}
|
||||
} else {
|
||||
menu = signMenus.get(player);
|
||||
if (event.getClickedBlock() == null) {
|
||||
return;
|
||||
}
|
||||
if (event.getClickedBlock().getLocation().equals(signBlock)) {
|
||||
Menu menu;
|
||||
Player player = event.getPlayer();
|
||||
if (signMenus.get(player) == null) {
|
||||
signMenus.put(player, ChestMenu.builder(6).title("PVP Selection Menu").build());
|
||||
menu = signMenus.get(player);
|
||||
|
||||
PlayerSelectionWrapper selectionWrapper;
|
||||
if (selectedKits.get(player) == null) { // Gets the selectionWrapper
|
||||
selectionWrapper = new PlayerSelectionWrapper(player); // for the current player.
|
||||
selectedKits.put(player, selectionWrapper); // Makes one if doesnt exist.
|
||||
} else {
|
||||
selectionWrapper = selectedKits.get(player);
|
||||
}
|
||||
|
||||
for (Map.Entry<Integer, Kit> entryKit : kits.entrySet()) {
|
||||
Kit kit = entryKit.getValue();
|
||||
int slotPos = entryKit.getKey();
|
||||
Slot slot = menu.getSlot(slotPos);
|
||||
ItemStack itemStack = kit.getInventoryItemList().get(0).getItemStack();
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
itemMeta.setDisplayName(kit.getName());
|
||||
itemMeta.setLore(kit.getLore());
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
slot.setItem(kit.getInventoryItemList().get(0).getItemStack());
|
||||
slotFunction(slot, kit, selectionWrapper, menu);
|
||||
}
|
||||
Slot slot = menu.getSlot(53);
|
||||
ItemStack itemStack = new ItemStack(Material.COMPARATOR);
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&2Go!"));
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
slot.setItem(itemStack);
|
||||
slot.setClickHandler((ignore, info) -> {
|
||||
selectionWrapper.fillInventory();
|
||||
if (giveSteak) {
|
||||
player.getInventory().addItem(new ItemStack(Material.COOKED_BEEF, 64));
|
||||
}
|
||||
for (Map.Entry<Integer, Kit> entryKit : defaultKits.entrySet()) {
|
||||
for (InventoryItem item : entryKit.getValue().getInventoryItemList()) {
|
||||
switch (entryKit.getValue().getType()) {
|
||||
case HELMET:
|
||||
player.getInventory().setHelmet(item.getItemStack());
|
||||
continue;
|
||||
|
||||
case CHESTPLATE:
|
||||
player.getInventory().setChestplate(item.getItemStack());
|
||||
continue;
|
||||
|
||||
case LEGGINGS:
|
||||
player.getInventory().setLeggings(item.getItemStack());
|
||||
continue;
|
||||
|
||||
case BOOTS:
|
||||
player.getInventory().setBoots(item.getItemStack());
|
||||
continue;
|
||||
}
|
||||
if (item.getInvPosition() == null) {
|
||||
player.getInventory().addItem(item.itemStack);
|
||||
continue;
|
||||
}
|
||||
player.getInventory().setItem(item.getInvPosition(), item.getItemStack());
|
||||
}
|
||||
}
|
||||
player.setLevel(player.getLevel() - selectionWrapper.getTotalXpCost());
|
||||
selectionWrapper.clean();
|
||||
player.teleport(enabledMap.getSpawnLocation());
|
||||
});
|
||||
} else {
|
||||
menu = signMenus.get(player);
|
||||
}
|
||||
menu.open(player);
|
||||
}
|
||||
menu.open(player);
|
||||
}
|
||||
|
||||
public void slotFunction(Slot slot, Kit kit, PlayerSelectionWrapper selectionWrapper, Menu menu) {
|
||||
slot.setClickHandler((player, info) -> {
|
||||
Kit.Type type = kit.getType();
|
||||
if (type == Kit.Type.KIT) {
|
||||
if (info.getClickType() == ClickType.LEFT) {
|
||||
selectionWrapper.setSelectedKit(kit);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
} else if (info.getClickType() == ClickType.RIGHT) {
|
||||
selectionWrapper.setSelectedKit(null);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
}
|
||||
} else if (type == Kit.Type.HELMET) {
|
||||
if (info.getClickType() == ClickType.LEFT) {
|
||||
selectionWrapper.setSelectedHelmet(kit);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
} else if (info.getClickType() == ClickType.RIGHT) {
|
||||
selectionWrapper.setSelectedHelmet(null);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
}
|
||||
} else if (type == Kit.Type.CHESTPLATE) {
|
||||
if (info.getClickType() == ClickType.LEFT) {
|
||||
selectionWrapper.setSelectedChestplate(kit);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
} else if (info.getClickType() == ClickType.RIGHT) {
|
||||
selectionWrapper.setSelectedChestplate(null);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
}
|
||||
} else if (type == Kit.Type.LEGGINGS) {
|
||||
if (info.getClickType() == ClickType.LEFT) {
|
||||
selectionWrapper.setSelectedLeggings(kit);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
} else if (info.getClickType() == ClickType.RIGHT) {
|
||||
selectionWrapper.setSelectedLeggings(null);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
}
|
||||
} else if (type == Kit.Type.BOOTS) {
|
||||
if (info.getClickType() == ClickType.LEFT) {
|
||||
selectionWrapper.setSelectedBoots(kit);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
} else if (info.getClickType() == ClickType.RIGHT) {
|
||||
selectionWrapper.setSelectedBoots(null);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
}
|
||||
} else if (type == Kit.Type.POTION) {
|
||||
if (info.getClickType() == ClickType.LEFT) {
|
||||
selectionWrapper.addPotions(kit, 1);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
} else if (info.getClickType() == ClickType.RIGHT) {
|
||||
selectionWrapper.addPotions(kit, -1);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
}
|
||||
} else if (type == Kit.Type.ADDITIONAL) {
|
||||
if (info.getClickType() == ClickType.LEFT) {
|
||||
selectionWrapper.addAdditions(kit, 1);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
} else if (info.getClickType() == ClickType.RIGHT) {
|
||||
selectionWrapper.addAdditions(kit, -1);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
}
|
||||
int playerLevel = player.getLevel();
|
||||
switch (type) {
|
||||
|
||||
case KIT:
|
||||
switch (info.getClickType()) {
|
||||
case LEFT:
|
||||
if (playerLevel >= (kit.getCost() + selectionWrapper.getTotalXpCost())) {
|
||||
selectionWrapper.setSelectedKit(kit);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
} else player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1f, 1f);
|
||||
break;
|
||||
case RIGHT:
|
||||
selectionWrapper.setSelectedKit(null);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
break;
|
||||
}
|
||||
case HELMET:
|
||||
switch (info.getClickType()) {
|
||||
case LEFT:
|
||||
if (playerLevel >= (kit.getCost() + selectionWrapper.getTotalXpCost())) {
|
||||
selectionWrapper.setSelectedHelmet(kit);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
} else player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1f, 1f);
|
||||
break;
|
||||
case RIGHT:
|
||||
selectionWrapper.setSelectedHelmet(null);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
break;
|
||||
}
|
||||
case CHESTPLATE:
|
||||
switch (info.getClickType()) {
|
||||
case LEFT:
|
||||
if (playerLevel >= (kit.getCost() + selectionWrapper.getTotalXpCost())) {
|
||||
selectionWrapper.setSelectedChestplate(kit);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
} else player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1f, 1f);
|
||||
break;
|
||||
case RIGHT:
|
||||
selectionWrapper.setSelectedChestplate(null);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
break;
|
||||
}
|
||||
case LEGGINGS:
|
||||
switch (info.getClickType()) {
|
||||
case LEFT:
|
||||
if (playerLevel >= (kit.getCost() + selectionWrapper.getTotalXpCost())) {
|
||||
selectionWrapper.setSelectedLeggings(kit);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
} else player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1f, 1f);
|
||||
break;
|
||||
case RIGHT:
|
||||
selectionWrapper.setSelectedLeggings(null);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
break;
|
||||
}
|
||||
case BOOTS:
|
||||
switch (info.getClickType()) {
|
||||
case LEFT:
|
||||
if (playerLevel >= (kit.getCost() + selectionWrapper.getTotalXpCost())) {
|
||||
selectionWrapper.setSelectedBoots(kit);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
} else player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1f, 1f);
|
||||
break;
|
||||
case RIGHT:
|
||||
selectionWrapper.setSelectedBoots(null);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
break;
|
||||
}
|
||||
case POTION:
|
||||
switch (info.getClickType()) {
|
||||
case LEFT:
|
||||
if (playerLevel >= (kit.getCost() + selectionWrapper.getTotalXpCost())) {
|
||||
selectionWrapper.addPotions(kit, 1);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
} else player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1f, 1f);
|
||||
break;
|
||||
case RIGHT:
|
||||
selectionWrapper.addPotions(kit, -1);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
break;
|
||||
}
|
||||
case ADDITIONAL:
|
||||
switch (info.getClickType()) {
|
||||
case LEFT:
|
||||
if (playerLevel >= (kit.getCost() + selectionWrapper.getTotalXpCost())) {
|
||||
selectionWrapper.addAdditions(kit, 1);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
} else player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1f, 1f);
|
||||
break;
|
||||
case RIGHT:
|
||||
selectionWrapper.addAdditions(kit, -1);
|
||||
updateMenu(selectionWrapper, menu);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -147,8 +238,8 @@ public class pvp extends JavaPlugin implements Listener {
|
||||
Kit updateKit = entryKit.getValue();
|
||||
int slotPos = entryKit.getKey();
|
||||
Slot updateSlot = menu.getSlot(slotPos);
|
||||
if (selectionWrapper.getGreenSlots().get(slotPos) != null) {
|
||||
updateSlot.setItem(new ItemStack(Material.GREEN_WOOL, selectionWrapper.getGreenSlots().get(slotPos)));
|
||||
if (selectionWrapper.getSelectedSlots().get(slotPos) != null) {
|
||||
updateSlot.setItem(new ItemStack(Material.GREEN_WOOL, selectionWrapper.getSelectedSlots().get(slotPos)));
|
||||
} else {
|
||||
updateSlot.setItem(updateKit.getInventoryItemList().get(0).getItemStack());
|
||||
}
|
||||
@ -156,10 +247,21 @@ public class pvp extends JavaPlugin implements Listener {
|
||||
}
|
||||
|
||||
public void load() {
|
||||
World world = Bukkit.getWorld("world");
|
||||
String[] signPos = config.getString("sign_pos").split(" ");
|
||||
signBlock = world.getBlockAt(Integer.parseInt(signPos[0]), Integer.parseInt(signPos[1]), Integer.parseInt(signPos[2]));
|
||||
configToKit();
|
||||
World world = Bukkit.getWorld(signPos[0]);
|
||||
signBlock = new Location(world, Integer.parseInt(signPos[1]), Integer.parseInt(signPos[2]), Integer.parseInt(signPos[3]));
|
||||
kits = configToKit();
|
||||
maps = configToMaps();
|
||||
enabledMap = maps.get(0); // TODO: 6/21/2020
|
||||
giveSteak = config.getBoolean("giveSteak");
|
||||
}
|
||||
|
||||
private List<io.github.officereso.Map> configToMaps() {
|
||||
List<io.github.officereso.Map> maps = new ArrayList<>();
|
||||
for (String map : config.getConfigurationSection("maps").getKeys(false)) {
|
||||
maps.add(new io.github.officereso.Map((List<String>) config.getList("maps." + map + ".spawns"), config.getString("maps." + map + ".name")));
|
||||
}
|
||||
return maps;
|
||||
}
|
||||
|
||||
private HashMap<Integer, Kit> configToKit() {
|
||||
@ -174,7 +276,7 @@ public class pvp extends JavaPlugin implements Listener {
|
||||
String name = config.getString(root + kit + ".name");
|
||||
Integer cost = (Integer) config.get(root + kit + ".cost");
|
||||
Integer position = (Integer) config.get(root + kit + ".position");
|
||||
String lore = config.getString(root + kit + ".lore");
|
||||
List<String> lore = (List<String>) config.getList(root + kit + ".lore");
|
||||
|
||||
if (name == null) {
|
||||
getLogger().severe(root + ' ' + kit + " has invalid name");
|
||||
@ -268,10 +370,27 @@ public class pvp extends JavaPlugin implements Listener {
|
||||
inventoryItemList.add(new InventoryItem(itemStack, inventoryPos));
|
||||
}
|
||||
Kit kitClass = new Kit(name, inventoryItemList, cost, position, lore, Kit.Type.valueOf(type));
|
||||
if (kit.equals("default")) {
|
||||
defaultKits.put(kitClass.getViewPosition(), kitClass);
|
||||
continue;
|
||||
}
|
||||
kits.put(kitClass.getViewPosition(), kitClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
return kits;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onKill(PlayerDeathEvent event) {
|
||||
if (event.getEntity().getKiller() != null) {
|
||||
if (event.getEntity().getWorld() == getServer().getWorld("spawn")) {
|
||||
int level = event.getEntity().getLevel();
|
||||
event.getEntity().getKiller().setLevel(event.getEntity().getKiller().getLevel() + 2);
|
||||
event.getEntity().getInventory().clear();
|
||||
event.getEntity().setLevel(level);
|
||||
signMenus.remove(event.getEntity());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
name: pvp
|
||||
version: "1.0"
|
||||
main: io.github.officereso.pvp
|
||||
api-version: "1.15"
|
||||
api-version: "1.15"
|
||||
load: POSTWORLD
|
Loading…
x
Reference in New Issue
Block a user