Skip to content

Commit

Permalink
Not yet the best, but added support for 1.8 -> 1.17+ blocks (#4) - ne…
Browse files Browse the repository at this point in the history
…ed more testing
  • Loading branch information
AerWyn81 committed Sep 25, 2021
1 parent 4627080 commit 3b02040
Show file tree
Hide file tree
Showing 28 changed files with 2,518 additions and 682 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = 'me.davidml16'
version = '3.7.3'
version = '3.7.4'
description = 'AParkour'
sourceCompatibility = '1.8'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import me.davidml16.aparkour.managers.ColorManager;
import me.davidml16.aparkour.utils.ActionBar;
import me.davidml16.aparkour.utils.MessageUtils;
import me.davidml16.aparkour.utils.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
Expand Down Expand Up @@ -264,7 +265,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
if(main.getParkourHandler().createParkour(id)) {
FileConfiguration config = main.getParkourHandler().getConfig(id);
config.set("parkour.name", args[2]);
config.set("parkour.icon", "389:0");
config.set("parkour.icon", XMaterial.ITEM_FRAME.name());
config.set("parkour.plateHolograms.start.enabled", false);
config.set("parkour.plateHolograms.start.distanceBelowPlate", 2.5D);
config.set("parkour.plateHolograms.end.enabled", false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import me.davidml16.aparkour.data.Plate;
import me.davidml16.aparkour.managers.ColorManager;
import me.davidml16.aparkour.utils.Sounds;
import me.davidml16.aparkour.utils.XMaterial;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.conversations.*;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -48,8 +48,8 @@ protected Prompt acceptValidatedInput(ConversationContext param1ConversationCont
parkour.getCheckpointLocations().add(loc);

Block block = loc.getWorld().getBlockAt(loc);
if(block.getType() != Material.IRON_PLATE) {
block.setType(Material.IRON_PLATE);
if(block.getType() != XMaterial.HEAVY_WEIGHTED_PRESSURE_PLATE.parseMaterial()) {
block.setType(XMaterial.HEAVY_WEIGHTED_PRESSURE_PLATE.parseMaterial());
}

main.getParkourHandler().loadCheckpointHologram(parkour, checkpoint);
Expand All @@ -71,8 +71,8 @@ protected Prompt acceptValidatedInput(ConversationContext param1ConversationCont

Location loc2 = parkour.getCheckpointLocations().get(parkour.getCheckpointLocations().size() - 1);
Block block = loc2.getWorld().getBlockAt(loc2);
if(block.getType() == Material.IRON_PLATE) {
block.setType(Material.AIR);
if(block.getType() == XMaterial.HEAVY_WEIGHTED_PRESSURE_PLATE.parseMaterial()) {
block.setType(XMaterial.AIR.parseMaterial());
}

parkour.getCheckpointLocations().remove(parkour.getCheckpointLocations().size() - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@

import me.davidml16.aparkour.Main;
import me.davidml16.aparkour.data.Parkour;
import me.davidml16.aparkour.data.Plate;
import me.davidml16.aparkour.managers.ColorManager;
import me.davidml16.aparkour.utils.Sounds;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.conversations.*;
import org.bukkit.entity.Player;

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/me/davidml16/aparkour/data/Parkour.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import java.util.*;

import me.davidml16.aparkour.utils.ItemBuilder;
import me.davidml16.aparkour.utils.XMaterial;
import org.bukkit.Location;

import me.davidml16.aparkour.Main;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.inventory.ItemStack;

Expand All @@ -26,7 +26,7 @@ public class Parkour {
private Location statsHologram;
private Location topHologram;

private List<WalkableBlock> walkableBlocks;
private List<XMaterial> walkableBlocks;
private List<Reward> rewards;
private List<Plate> checkpoints;
private List<Location> checkpointLocations;
Expand Down Expand Up @@ -60,7 +60,7 @@ public Parkour(Main main, String id, String name, Location spawn, Location start
this.startTitleEnabled = false;
this.endTitleEnabled = false;
this.checkpointTitleEnabled = false;
this.icon = new ItemBuilder(Material.getMaterial(389), 1).toItemStack();
this.icon = XMaterial.ITEM_FRAME.parseItem();
this.playing = new HashSet<>();
}

Expand Down Expand Up @@ -94,11 +94,11 @@ public Plate getEnd() {

public void setTopHologram(Location topHologram) { this.topHologram = topHologram; }

public List<WalkableBlock> getWalkableBlocks() {
public List<XMaterial> getWalkableBlocks() {
return walkableBlocks;
}

public void setWalkableBlocks(List<WalkableBlock> walkableBlocks) {
public void setWalkableBlocks(List<XMaterial> walkableBlocks) {
this.walkableBlocks = walkableBlocks;
}

Expand Down
58 changes: 0 additions & 58 deletions src/main/java/me/davidml16/aparkour/data/WalkableBlock.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import me.davidml16.aparkour.data.ParkourSession;
import me.davidml16.aparkour.data.Plate;
import me.davidml16.aparkour.utils.Sounds;
import me.davidml16.aparkour.utils.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
Expand All @@ -30,7 +30,7 @@ public void Plate(PlayerInteractEvent e) {
Action action = e.getAction();

if (action == Action.PHYSICAL) {
if (e.getClickedBlock().getType() == Material.IRON_PLATE) {
if (e.getClickedBlock().getType() == XMaterial.HEAVY_WEIGHTED_PRESSURE_PLATE.parseMaterial()) {

Parkour parkour = main.getParkourHandler().getParkourByLocation(e.getClickedBlock().getLocation());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import me.davidml16.aparkour.handlers.ParkourHandler;
import me.davidml16.aparkour.utils.*;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
Expand All @@ -31,7 +30,7 @@ public void Plate(PlayerInteractEvent e) {
Action action = e.getAction();

if (action == Action.PHYSICAL) {
if (e.getClickedBlock().getType() == Material.GOLD_PLATE) {
if (e.getClickedBlock().getType() == XMaterial.LIGHT_WEIGHTED_PRESSURE_PLATE.parseMaterial()) {

Parkour parkour = main.getParkourHandler().getParkourByLocation(e.getClickedBlock().getLocation());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import me.davidml16.aparkour.handlers.ParkourHandler;
import me.davidml16.aparkour.managers.ColorManager;
import me.davidml16.aparkour.utils.Sounds;
import me.davidml16.aparkour.utils.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
Expand Down Expand Up @@ -35,7 +35,7 @@ public void Plate(PlayerInteractEvent e) {
Action action = e.getAction();

if (action == Action.PHYSICAL) {
if (e.getClickedBlock().getType() == Material.IRON_PLATE) {
if (e.getClickedBlock().getType() == XMaterial.HEAVY_WEIGHTED_PRESSURE_PLATE.parseMaterial()) {

Parkour parkour = main.getParkourHandler().getParkourByLocation(e.getClickedBlock().getLocation());

Expand Down
36 changes: 17 additions & 19 deletions src/main/java/me/davidml16/aparkour/gui/Checkpoints_GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import me.davidml16.aparkour.managers.ColorManager;
import me.davidml16.aparkour.utils.ItemBuilder;
import me.davidml16.aparkour.utils.Sounds;
import me.davidml16.aparkour.utils.XMaterial;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand Down Expand Up @@ -59,9 +59,9 @@ public void loadGUI(String id) {

Inventory gui = Bukkit.createInventory(null, 45, main.getLanguageHandler().getMessage("GUIs.Checkpoints.title").replaceAll("%parkour%", id));

ItemStack edge = new ItemBuilder(Material.STAINED_GLASS_PANE, 1).setDurability((short) 7).setName("").toItemStack();
ItemStack newReward = new ItemBuilder(Material.DOUBLE_PLANT, 1).setName(ColorManager.translate("&aEdit checkpoints")).toItemStack();
ItemStack back = new ItemBuilder(Material.ARROW, 1).setName(ColorManager.translate("&aBack to config")).toItemStack();
ItemStack edge = new ItemBuilder(XMaterial.GRAY_STAINED_GLASS_PANE.parseItem()).setName("").toItemStack();
ItemStack newReward = new ItemBuilder(XMaterial.SUNFLOWER.parseItem()).setName(ColorManager.translate("&aEdit checkpoints")).toItemStack();
ItemStack back = new ItemBuilder(XMaterial.ARROW.parseItem()).setName(ColorManager.translate("&aBack to config")).toItemStack();

for (Integer i : borders) {
gui.setItem(i, edge);
Expand Down Expand Up @@ -107,24 +107,24 @@ private void openPage(Player p, String id, int page) {
gui.setItem(i, null);

if (page > 0) {
gui.setItem(18, new ItemBuilder(Material.ENDER_PEARL, 1).setName(ColorManager.translate("&aPrevious page")).toItemStack());
gui.setItem(18, new ItemBuilder(XMaterial.ENDER_PEARL.parseItem()).setName(ColorManager.translate("&aPrevious page")).toItemStack());
} else {
gui.setItem(18, new ItemBuilder(Material.STAINED_GLASS_PANE, 1).setDurability((short) 7).setName("").toItemStack());
gui.setItem(18, new ItemBuilder(XMaterial.GRAY_STAINED_GLASS_PANE.parseItem()).setName("").toItemStack());
}

if (checkpoints.size() > (page + 1) * 21) {
gui.setItem(26, new ItemBuilder(Material.ENDER_PEARL, 1).setName(ColorManager.translate("&aNext page")).toItemStack());
gui.setItem(26, new ItemBuilder(XMaterial.ENDER_PEARL.parseItem()).setName(ColorManager.translate("&aNext page")).toItemStack());
} else {
gui.setItem(26, new ItemBuilder(Material.STAINED_GLASS_PANE, 1).setDurability((short) 7).setName("").toItemStack());
gui.setItem(26, new ItemBuilder(XMaterial.GRAY_STAINED_GLASS_PANE.parseItem()).setName("").toItemStack());
}

if (checkpoints.size() > 21) checkpoints = checkpoints.subList(page * 21, ((page * 21) + 21) > checkpoints.size() ? checkpoints.size() : (page * 21) + 21);
if (checkpoints.size() > 21) checkpoints = checkpoints.subList(page * 21, Math.min(((page * 21) + 21), checkpoints.size()));

if(checkpoints.size() > 0) {
int iterator = (page * 21) + 1;
for (Plate checkpoint : checkpoints) {
Location loc = checkpoint.getLocation();
gui.addItem(new ItemBuilder(Material.BEACON, 1)
gui.addItem(new ItemBuilder(XMaterial.BEACON.parseMaterial(), 1)
.setName(ColorManager.translate("&aCheckpoint &e#" + iterator))
.setLore(
"",
Expand All @@ -139,7 +139,7 @@ private void openPage(Player p, String id, int page) {
iterator++;
}
} else {
gui.setItem(22, new ItemBuilder(Material.STAINED_GLASS_PANE, 1).setDurability((short) 14).setName(ColorManager.translate("&cAny checkpoints selected")).setLore(
gui.setItem(22, new ItemBuilder(XMaterial.RED_STAINED_GLASS_PANE.parseItem()).setName(ColorManager.translate("&cAny checkpoints selected")).setLore(
"",
ColorManager.translate(" &7You dont have any "),
ColorManager.translate(" &7checkpoints selected. "),
Expand All @@ -163,23 +163,22 @@ public void open(Player p, String id) {
Sounds.playSound(p, p.getLocation(), Sounds.MySound.CLICK, 10, 2);
}

@SuppressWarnings("deprecation")
@EventHandler
public void onInventoryClickEvent(InventoryClickEvent e) {
Player p = (Player) e.getWhoClicked();

if (e.getCurrentItem() == null) return;
if (e.getCurrentItem().getType() == Material.AIR) return;
if (e.getCurrentItem().getType() == XMaterial.AIR.parseMaterial()) return;

if (opened.containsKey(p.getUniqueId())) {
e.setCancelled(true);
int slot = e.getRawSlot();
String id = opened.get(p.getUniqueId()).getParkour();
Parkour parkour = main.getParkourHandler().getParkourById(opened.get(p.getUniqueId()).getParkour());
if (slot == 18 && e.getCurrentItem().getType() == Material.ENDER_PEARL) {
if (slot == 18 && e.getCurrentItem().getType() == XMaterial.ENDER_PEARL.parseMaterial()) {
Sounds.playSound(p, p.getLocation(), Sounds.MySound.CLICK, 10, 2);
openPage(p, id, opened.get(p.getUniqueId()).getPage() - 1);
} else if (slot == 26 && e.getCurrentItem().getType() == Material.ENDER_PEARL) {
} else if (slot == 26 && e.getCurrentItem().getType() == XMaterial.ENDER_PEARL.parseMaterial()) {
Sounds.playSound(p, p.getLocation(), Sounds.MySound.CLICK, 10, 2);
openPage(p, id, opened.get(p.getUniqueId()).getPage() + 1);
} else if (slot == 39) {
Expand All @@ -189,7 +188,7 @@ public void onInventoryClickEvent(InventoryClickEvent e) {
} else if (slot == 41) {
main.getConfigGUI().open(p, parkour.getId());
} else if ((slot >= 10 && slot <= 16) || (slot >= 19 && slot <= 25) || (slot >= 28 && slot <= 34)) {
if (e.getCurrentItem().getType() == Material.AIR) return;
if (e.getCurrentItem().getType() == XMaterial.AIR.parseMaterial()) return;

if (parkour.getCheckpoints().size() == 0) return;

Expand All @@ -201,8 +200,8 @@ public void onInventoryClickEvent(InventoryClickEvent e) {

Location loc = parkour.getCheckpointLocations().get(checkpointID - 1);
Block block = loc.getWorld().getBlockAt(loc);
if(block.getType() == Material.IRON_PLATE) {
block.setType(Material.AIR);
if(block.getType() == XMaterial.HEAVY_WEIGHTED_PRESSURE_PLATE.parseMaterial()) {
block.setType(XMaterial.AIR.parseMaterial());
}

parkour.getCheckpointLocations().remove(checkpointID - 1);
Expand All @@ -223,5 +222,4 @@ public void InventoryCloseEvent(InventoryCloseEvent e) {
opened.remove(p.getUniqueId());
}
}

}
Loading

0 comments on commit 3b02040

Please sign in to comment.