Skip to content

Commit

Permalink
Merge pull request #28 from Grzybol/addElytra-command
Browse files Browse the repository at this point in the history
- added command for shitty imitation ofElytra effect (more like long …
  • Loading branch information
Grzybol authored Mar 18, 2024
2 parents af9c772 + 0a7ae17 commit 27e1d82
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>betterbox.mine.game</groupId>
<artifactId>BetterElo</artifactId>
<version>3.2.61-SNAPSHOT</version>
<version>3.2.63-SNAPSHOT</version>
<packaging>jar</packaging>

<name>BetterElo</name>
Expand Down
47 changes: 33 additions & 14 deletions src/main/java/betterbox/mine/game/betterelo/BetterEloCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,22 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
break;
case 1:
switch (args[0].toLowerCase()) {

case "addelytra":
if (sender instanceof Player) {
Player player = (Player) sender;
if(!player.isOp()){
sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.DARK_RED + " You don't have permission to use that command!");
break;
}
ItemStack itemInHand = player.getInventory().getItemInMainHand();
if(itemInHand.getType() != Material.AIR && itemInHand.getType().toString().contains("CHESTPLATE")) {
addElytraLore(player,itemInHand);
sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.AQUA + " Elytra effect added.");
}
}else{
sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.DARK_RED + " This command can be used only by as a player.");
}
break;
case "stopevent":
if(sender.isOp()){
sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.AQUA + " Event stopped,data removed.");
Expand Down Expand Up @@ -571,6 +586,8 @@ private void handleHelpCommand(CommandSender sender){
sender.sendMessage(ChatColor.AQUA + "/be holo <event/main/daily/weekly/monthly> " + ChatColor.GREEN + "- creates holo at your position.");
sender.sendMessage(ChatColor.AQUA + "/be holo delete <event/main/daily/weekly/monthly> " + ChatColor.GREEN + "- delete given holo");
sender.sendMessage(ChatColor.AQUA + "/be antyweb <radius> " + ChatColor.GREEN + "- creates antyweb effect with given radius");
sender.sendMessage(ChatColor.AQUA + "/be addelytra " + ChatColor.GREEN + "- adds Elytra Effect to the chestplate (works only with infinite Infinite Firework)");
sender.sendMessage(ChatColor.AQUA + "/be firework <power> " + ChatColor.GREEN + "- creates an Infinite Firework with given power");
}
}
private void handleTimeLeft(CommandSender sender){
Expand Down Expand Up @@ -616,31 +633,33 @@ public void addAntywebLore(Player player, ItemStack itemStack, int radius) {
if (itemMeta == null) {
return; // Przerwij, jeśli nie można pobrać metadanych przedmiotu
}

String antywebLore = ChatColor.GOLD + "" + ChatColor.BOLD + "Antyweb " + radius;
List<String> lore = itemMeta.getLore();
if (lore == null) {
lore = new ArrayList<>();
}
lore.add(antywebLore);
itemMeta.setLore(lore);
/*
itemStack.setItemMeta(itemMeta);
if (itemMeta.hasLore()) {
// Jeśli istnieje już lore, dodaj nową linię
itemMeta.getLore().add(lore);
} else {
// Jeśli nie ma jeszcze lore, utwórz nową listę
itemMeta.setLore(Collections.singletonList(lore));
}
player.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.AQUA + " Added Antyweb lore with radius "+radius);

*/
}
public void addElytraLore(Player player, ItemStack itemStack) {
ItemMeta itemMeta = itemStack.getItemMeta();

if (itemMeta == null) {
return; // Przerwij, jeśli nie można pobrać metadanych przedmiotu
}
String antywebLore = ChatColor.GOLD + "" + ChatColor.BOLD + "Elytra effect" ;
List<String> lore = itemMeta.getLore();
if (lore == null) {
lore = new ArrayList<>();
}
lore.add(antywebLore);
itemMeta.setLore(lore);
itemStack.setItemMeta(itemMeta);
player.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.AQUA + " Added Elytra effect");

// Informuj gracza o dodaniu lore
player.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "[BetterElo]" + ChatColor.AQUA + " Added Antyweb lore with radius "+radius);
//player.sendMessage("Added Antyweb lore with radius " + radius + " to the item.");
}


Expand Down
37 changes: 33 additions & 4 deletions src/main/java/betterbox/mine/game/betterelo/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -514,18 +514,25 @@ public void onPlayerInteract(PlayerInteractEvent event) {

double fireworkCooldown = (double) (configManager.fireworkCooldown) /1000;
if (item != null && item.getType() == Material.FIREWORK_ROCKET) {
if(event.getAction() == Action.RIGHT_CLICK_AIR){
if(event.getAction() != Action.RIGHT_CLICK_AIR) {
event.setCancelled(true);
return;
}
Location location = player.getLocation();
Location blockBelowLocation = location.clone().subtract(0, 1, 0);
boolean isNotOnGround = blockBelowLocation.getBlock().isPassable();

ItemStack chestplate = player.getInventory().getChestplate();
if (chestplate == null || !chestplate.getType().toString().contains("ELYTRA")) {
if(chestplate == null ){
event.setCancelled(true);
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"Event.onPlayerInteract player is not wearing Elytra!");
return;

}
if (chestplate.getType().toString().contains("ELYTRA") || hasElytraLore(chestplate)) {

pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"Event.onPlayerInteract player is not wearing Elytra!");






Expand Down Expand Up @@ -573,6 +580,28 @@ private static void applyBoosterEffect(Player player,int power) {
Vector velocity = player.getLocation().getDirection().multiply(power); // Przykładowa prędkość (można dostosować)
player.setVelocity(velocity);
}
public boolean hasElytraLore(ItemStack itemStack) {
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"Event.hasElytraLore called");
if (itemStack == null || !itemStack.hasItemMeta()) {
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"Event.hasElytraLore itemmeta check failed");
return false;
}

ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta == null || !itemMeta.hasLore()) {
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"Event.hasElytraLore lore check failed");
return false;
}

for (String lore : itemMeta.getLore()) {
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"Event.hasElytraLore Elytra check triggered, checking lore and foramtting");
if (lore != null && lore.contains("§6§lElytra effect")) {
return true;
}
}

return false;
}
public boolean hasAntywebLore(ItemStack itemStack) {
pluginLogger.log(PluginLogger.LogLevel.DEBUG_LVL3,"Event.hasAntywebLore called");
if (itemStack == null || !itemStack.hasItemMeta()) {
Expand Down

0 comments on commit 27e1d82

Please sign in to comment.