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;
|
package io.github.officereso;
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class InventoryItem {
|
public class InventoryItem {
|
||||||
public ItemStack itemStack;
|
public ItemStack itemStack;
|
||||||
@ -15,6 +16,7 @@ public class InventoryItem {
|
|||||||
return itemStack;
|
return itemStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public Integer getInvPosition() {
|
public Integer getInvPosition() {
|
||||||
return invPosition;
|
return invPosition;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package io.github.officereso;
|
package io.github.officereso;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
@ -12,11 +13,11 @@ import java.util.List;
|
|||||||
|
|
||||||
public class Kit {
|
public class Kit {
|
||||||
private final String name;
|
private final String name;
|
||||||
private List<InventoryItem> inventoryItemList;
|
private final List<InventoryItem> inventoryItemList;
|
||||||
private int cost;
|
private int cost;
|
||||||
private int viewPosition;
|
private final int viewPosition;
|
||||||
private String lore;
|
private final List<String> lore;
|
||||||
private Type type;
|
private final Type type;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,12 +27,20 @@ public class Kit {
|
|||||||
* @param viewPosition Where the kit will show up in the kit selection inventory.
|
* @param viewPosition Where the kit will show up in the kit selection inventory.
|
||||||
* Must be between 0 and 26.
|
* Must be between 0 and 26.
|
||||||
*/
|
*/
|
||||||
public Kit(String name, List<InventoryItem> inventoryItemList, int cost, int viewPosition, String lore, Type type) {
|
public Kit(String name, List<InventoryItem> inventoryItemList, int cost, int viewPosition, List<String> lore, Type type) {
|
||||||
this.name = name;
|
this.name = ChatColor.translateAlternateColorCodes('&', name);
|
||||||
this.inventoryItemList = inventoryItemList;
|
this.inventoryItemList = inventoryItemList;
|
||||||
this.cost = cost;
|
this.cost = cost;
|
||||||
this.viewPosition = viewPosition;
|
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;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +70,7 @@ public class Kit {
|
|||||||
return viewPosition;
|
return viewPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLore() {
|
public List<String> getLore() {
|
||||||
return lore;
|
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;
|
return selectedPotions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<Integer, Integer> getGreenSlots() {
|
public HashMap<Integer, Integer> getSelectedSlots() {
|
||||||
HashMap<Integer, Integer> slots = new HashMap<>();
|
HashMap<Integer, Integer> slots = new HashMap<>();
|
||||||
if (selectedKit != null) {
|
if (selectedKit != null)
|
||||||
slots.put(selectedKit.getViewPosition(), 1);
|
slots.put(selectedKit.getViewPosition(), 1);
|
||||||
}
|
if (selectedHelmet != null)
|
||||||
if (selectedHelmet != null) {
|
|
||||||
slots.put(selectedHelmet.getViewPosition(), 1);
|
slots.put(selectedHelmet.getViewPosition(), 1);
|
||||||
}
|
if (selectedChestplate != null)
|
||||||
if (selectedChestplate != null) {
|
|
||||||
slots.put(selectedChestplate.getViewPosition(), 1);
|
slots.put(selectedChestplate.getViewPosition(), 1);
|
||||||
}
|
if (selectedLeggings != null)
|
||||||
if (selectedLeggings != null) {
|
|
||||||
slots.put(selectedLeggings.getViewPosition(), 1);
|
slots.put(selectedLeggings.getViewPosition(), 1);
|
||||||
}
|
if (selectedBoots != null)
|
||||||
if (selectedBoots != null) {
|
|
||||||
slots.put(selectedBoots.getViewPosition(), 1);
|
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 : selectedAdditions.entrySet()) {
|
||||||
for (Map.Entry<Kit, Integer> entryKit : selectedPotions.entrySet()) {
|
if (entryKit.getValue() == null)
|
||||||
if (entryKit.getValue() == null)
|
continue;
|
||||||
continue;
|
slots.put(entryKit.getKey().getViewPosition(), entryKit.getValue());
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return slots;
|
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) {
|
public void setSelectedAdditions(HashMap<Kit, Integer> selectedAdditions) {
|
||||||
this.selectedAdditions = selectedAdditions;
|
this.selectedAdditions = selectedAdditions;
|
||||||
}
|
}
|
||||||
@ -89,7 +135,7 @@ public class PlayerSelectionWrapper {
|
|||||||
public void addAdditions(Kit kit, int amount) {
|
public void addAdditions(Kit kit, int amount) {
|
||||||
selectedAdditions.putIfAbsent(kit, 0);
|
selectedAdditions.putIfAbsent(kit, 0);
|
||||||
if (selectedAdditions.get(kit) + amount <= 0) {
|
if (selectedAdditions.get(kit) + amount <= 0) {
|
||||||
selectedAdditions.put(kit, null);
|
selectedAdditions.remove(kit);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
selectedAdditions.put(kit, selectedAdditions.get(kit) + amount);
|
selectedAdditions.put(kit, selectedAdditions.get(kit) + amount);
|
||||||
@ -114,7 +160,7 @@ public class PlayerSelectionWrapper {
|
|||||||
public void addPotions(Kit kit, int amount) {
|
public void addPotions(Kit kit, int amount) {
|
||||||
selectedPotions.putIfAbsent(kit, 0);
|
selectedPotions.putIfAbsent(kit, 0);
|
||||||
if (selectedPotions.get(kit) + amount <= 0) {
|
if (selectedPotions.get(kit) + amount <= 0) {
|
||||||
selectedPotions.put(kit, null);
|
selectedPotions.remove(kit);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
selectedPotions.put(kit, selectedPotions.get(kit) + amount);
|
selectedPotions.put(kit, selectedPotions.get(kit) + amount);
|
||||||
@ -127,4 +173,25 @@ public class PlayerSelectionWrapper {
|
|||||||
public void setSelectedKit(Kit selectedKit) {
|
public void setSelectedKit(Kit selectedKit) {
|
||||||
this.selectedKit = 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;
|
package io.github.officereso;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.*;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.event.inventory.ClickType;
|
import org.bukkit.event.inventory.ClickType;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -30,11 +29,14 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class pvp extends JavaPlugin implements Listener {
|
public class pvp extends JavaPlugin implements Listener {
|
||||||
private final FileConfiguration config = this.getConfig();
|
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, Menu> signMenus = new HashMap<>();
|
||||||
private HashMap<Player, PlayerSelectionWrapper> selectedKits = 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
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
@ -51,93 +53,182 @@ public class pvp extends JavaPlugin implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onClick(PlayerInteractEvent event) {
|
public void onClick(PlayerInteractEvent event) {
|
||||||
|
if (event.getClickedBlock() == null) {
|
||||||
Menu menu;
|
return;
|
||||||
Player player = event.getPlayer();
|
}
|
||||||
if (signMenus.get(player) == null) {
|
if (event.getClickedBlock().getLocation().equals(signBlock)) {
|
||||||
signMenus.put(player, ChestMenu.builder(6).title("PVP Selection Menu").build());
|
Menu menu;
|
||||||
menu = signMenus.get(player);
|
Player player = event.getPlayer();
|
||||||
|
if (signMenus.get(player) == null) {
|
||||||
PlayerSelectionWrapper selectionWrapper;
|
signMenus.put(player, ChestMenu.builder(6).title("PVP Selection Menu").build());
|
||||||
if (selectedKits.get(player) == null) { // Gets the selectionWrapper
|
menu = signMenus.get(player);
|
||||||
selectionWrapper = new PlayerSelectionWrapper(player); // for the current player.
|
|
||||||
selectedKits.put(player, selectionWrapper); // Makes one if doesnt exist.
|
PlayerSelectionWrapper selectionWrapper;
|
||||||
} else {
|
if (selectedKits.get(player) == null) { // Gets the selectionWrapper
|
||||||
selectionWrapper = selectedKits.get(player);
|
selectionWrapper = new PlayerSelectionWrapper(player); // for the current player.
|
||||||
}
|
selectedKits.put(player, selectionWrapper); // Makes one if doesnt exist.
|
||||||
|
} else {
|
||||||
for (Map.Entry<Integer, Kit> entryKit : kits.entrySet()) {
|
selectionWrapper = selectedKits.get(player);
|
||||||
Kit kit = entryKit.getValue();
|
}
|
||||||
int slotPos = entryKit.getKey();
|
|
||||||
Slot slot = menu.getSlot(slotPos);
|
for (Map.Entry<Integer, Kit> entryKit : kits.entrySet()) {
|
||||||
slot.setItem(kit.getInventoryItemList().get(0).getItemStack());
|
Kit kit = entryKit.getValue();
|
||||||
slotFunction(slot, kit, selectionWrapper, menu);
|
int slotPos = entryKit.getKey();
|
||||||
}
|
Slot slot = menu.getSlot(slotPos);
|
||||||
} else {
|
ItemStack itemStack = kit.getInventoryItemList().get(0).getItemStack();
|
||||||
menu = signMenus.get(player);
|
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) {
|
public void slotFunction(Slot slot, Kit kit, PlayerSelectionWrapper selectionWrapper, Menu menu) {
|
||||||
slot.setClickHandler((player, info) -> {
|
slot.setClickHandler((player, info) -> {
|
||||||
Kit.Type type = kit.getType();
|
Kit.Type type = kit.getType();
|
||||||
if (type == Kit.Type.KIT) {
|
int playerLevel = player.getLevel();
|
||||||
if (info.getClickType() == ClickType.LEFT) {
|
switch (type) {
|
||||||
selectionWrapper.setSelectedKit(kit);
|
|
||||||
updateMenu(selectionWrapper, menu);
|
case KIT:
|
||||||
} else if (info.getClickType() == ClickType.RIGHT) {
|
switch (info.getClickType()) {
|
||||||
selectionWrapper.setSelectedKit(null);
|
case LEFT:
|
||||||
updateMenu(selectionWrapper, menu);
|
if (playerLevel >= (kit.getCost() + selectionWrapper.getTotalXpCost())) {
|
||||||
}
|
selectionWrapper.setSelectedKit(kit);
|
||||||
} else if (type == Kit.Type.HELMET) {
|
updateMenu(selectionWrapper, menu);
|
||||||
if (info.getClickType() == ClickType.LEFT) {
|
} else player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1f, 1f);
|
||||||
selectionWrapper.setSelectedHelmet(kit);
|
break;
|
||||||
updateMenu(selectionWrapper, menu);
|
case RIGHT:
|
||||||
} else if (info.getClickType() == ClickType.RIGHT) {
|
selectionWrapper.setSelectedKit(null);
|
||||||
selectionWrapper.setSelectedHelmet(null);
|
updateMenu(selectionWrapper, menu);
|
||||||
updateMenu(selectionWrapper, menu);
|
break;
|
||||||
}
|
}
|
||||||
} else if (type == Kit.Type.CHESTPLATE) {
|
case HELMET:
|
||||||
if (info.getClickType() == ClickType.LEFT) {
|
switch (info.getClickType()) {
|
||||||
selectionWrapper.setSelectedChestplate(kit);
|
case LEFT:
|
||||||
updateMenu(selectionWrapper, menu);
|
if (playerLevel >= (kit.getCost() + selectionWrapper.getTotalXpCost())) {
|
||||||
} else if (info.getClickType() == ClickType.RIGHT) {
|
selectionWrapper.setSelectedHelmet(kit);
|
||||||
selectionWrapper.setSelectedChestplate(null);
|
updateMenu(selectionWrapper, menu);
|
||||||
updateMenu(selectionWrapper, menu);
|
} else player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1f, 1f);
|
||||||
}
|
break;
|
||||||
} else if (type == Kit.Type.LEGGINGS) {
|
case RIGHT:
|
||||||
if (info.getClickType() == ClickType.LEFT) {
|
selectionWrapper.setSelectedHelmet(null);
|
||||||
selectionWrapper.setSelectedLeggings(kit);
|
updateMenu(selectionWrapper, menu);
|
||||||
updateMenu(selectionWrapper, menu);
|
break;
|
||||||
} else if (info.getClickType() == ClickType.RIGHT) {
|
}
|
||||||
selectionWrapper.setSelectedLeggings(null);
|
case CHESTPLATE:
|
||||||
updateMenu(selectionWrapper, menu);
|
switch (info.getClickType()) {
|
||||||
}
|
case LEFT:
|
||||||
} else if (type == Kit.Type.BOOTS) {
|
if (playerLevel >= (kit.getCost() + selectionWrapper.getTotalXpCost())) {
|
||||||
if (info.getClickType() == ClickType.LEFT) {
|
selectionWrapper.setSelectedChestplate(kit);
|
||||||
selectionWrapper.setSelectedBoots(kit);
|
updateMenu(selectionWrapper, menu);
|
||||||
updateMenu(selectionWrapper, menu);
|
} else player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1f, 1f);
|
||||||
} else if (info.getClickType() == ClickType.RIGHT) {
|
break;
|
||||||
selectionWrapper.setSelectedBoots(null);
|
case RIGHT:
|
||||||
updateMenu(selectionWrapper, menu);
|
selectionWrapper.setSelectedChestplate(null);
|
||||||
}
|
updateMenu(selectionWrapper, menu);
|
||||||
} else if (type == Kit.Type.POTION) {
|
break;
|
||||||
if (info.getClickType() == ClickType.LEFT) {
|
}
|
||||||
selectionWrapper.addPotions(kit, 1);
|
case LEGGINGS:
|
||||||
updateMenu(selectionWrapper, menu);
|
switch (info.getClickType()) {
|
||||||
} else if (info.getClickType() == ClickType.RIGHT) {
|
case LEFT:
|
||||||
selectionWrapper.addPotions(kit, -1);
|
if (playerLevel >= (kit.getCost() + selectionWrapper.getTotalXpCost())) {
|
||||||
updateMenu(selectionWrapper, menu);
|
selectionWrapper.setSelectedLeggings(kit);
|
||||||
}
|
updateMenu(selectionWrapper, menu);
|
||||||
} else if (type == Kit.Type.ADDITIONAL) {
|
} else player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 1f, 1f);
|
||||||
if (info.getClickType() == ClickType.LEFT) {
|
break;
|
||||||
selectionWrapper.addAdditions(kit, 1);
|
case RIGHT:
|
||||||
updateMenu(selectionWrapper, menu);
|
selectionWrapper.setSelectedLeggings(null);
|
||||||
} else if (info.getClickType() == ClickType.RIGHT) {
|
updateMenu(selectionWrapper, menu);
|
||||||
selectionWrapper.addAdditions(kit, -1);
|
break;
|
||||||
updateMenu(selectionWrapper, menu);
|
}
|
||||||
}
|
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();
|
Kit updateKit = entryKit.getValue();
|
||||||
int slotPos = entryKit.getKey();
|
int slotPos = entryKit.getKey();
|
||||||
Slot updateSlot = menu.getSlot(slotPos);
|
Slot updateSlot = menu.getSlot(slotPos);
|
||||||
if (selectionWrapper.getGreenSlots().get(slotPos) != null) {
|
if (selectionWrapper.getSelectedSlots().get(slotPos) != null) {
|
||||||
updateSlot.setItem(new ItemStack(Material.GREEN_WOOL, selectionWrapper.getGreenSlots().get(slotPos)));
|
updateSlot.setItem(new ItemStack(Material.GREEN_WOOL, selectionWrapper.getSelectedSlots().get(slotPos)));
|
||||||
} else {
|
} else {
|
||||||
updateSlot.setItem(updateKit.getInventoryItemList().get(0).getItemStack());
|
updateSlot.setItem(updateKit.getInventoryItemList().get(0).getItemStack());
|
||||||
}
|
}
|
||||||
@ -156,10 +247,21 @@ public class pvp extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void load() {
|
public void load() {
|
||||||
World world = Bukkit.getWorld("world");
|
|
||||||
String[] signPos = config.getString("sign_pos").split(" ");
|
String[] signPos = config.getString("sign_pos").split(" ");
|
||||||
signBlock = world.getBlockAt(Integer.parseInt(signPos[0]), Integer.parseInt(signPos[1]), Integer.parseInt(signPos[2]));
|
World world = Bukkit.getWorld(signPos[0]);
|
||||||
configToKit();
|
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() {
|
private HashMap<Integer, Kit> configToKit() {
|
||||||
@ -174,7 +276,7 @@ public class pvp extends JavaPlugin implements Listener {
|
|||||||
String name = config.getString(root + kit + ".name");
|
String name = config.getString(root + kit + ".name");
|
||||||
Integer cost = (Integer) config.get(root + kit + ".cost");
|
Integer cost = (Integer) config.get(root + kit + ".cost");
|
||||||
Integer position = (Integer) config.get(root + kit + ".position");
|
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) {
|
if (name == null) {
|
||||||
getLogger().severe(root + ' ' + kit + " has invalid name");
|
getLogger().severe(root + ' ' + kit + " has invalid name");
|
||||||
@ -268,10 +370,27 @@ public class pvp extends JavaPlugin implements Listener {
|
|||||||
inventoryItemList.add(new InventoryItem(itemStack, inventoryPos));
|
inventoryItemList.add(new InventoryItem(itemStack, inventoryPos));
|
||||||
}
|
}
|
||||||
Kit kitClass = new Kit(name, inventoryItemList, cost, position, lore, Kit.Type.valueOf(type));
|
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);
|
kits.put(kitClass.getViewPosition(), kitClass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return kits;
|
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
|
name: pvp
|
||||||
version: "1.0"
|
version: "1.0"
|
||||||
main: io.github.officereso.pvp
|
main: io.github.officereso.pvp
|
||||||
api-version: "1.15"
|
api-version: "1.15"
|
||||||
|
load: POSTWORLD
|
Loading…
x
Reference in New Issue
Block a user