Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
hostadam committed Oct 18, 2024
1 parent 24744ba commit 67c8bd8
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 16 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.hostadam.ares</groupId>
<artifactId>Ares</artifactId>
<version>0.8</version>
<version>1.1</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
Expand All @@ -25,13 +25,13 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.1-R0.1-SNAPSHOT</version>
<version>1.21.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
<version>1.18.30</version>
<scope>compile</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/github/hostadam/Ares.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public Ares(JavaPlugin parent) {

public void setScoreboardAdapter(BoardAdapter adapter) {
this.boardHandler.setAdapter(adapter);
//TODO: Refresh for all online players.
this.boardHandler.refresh();
}

/** Board **/
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/github/hostadam/board/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class Board {

private Player player;
private BoardObjective objective;
@Setter
private BoardAdapter adapter;

private Scoreboard scoreboard;
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/github/hostadam/board/BoardHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ public Board getScoreboard(UUID uniqueId) {
return this.boards.get(uniqueId);
}

public void refresh() {
this.boards.values().forEach(board -> {
board.setAdapter(this.adapter);
board.update();
});
}

@EventHandler
public void onJoin(PlayerJoinEvent event) {
if(this.adapter == null) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,4 @@ public Team createTeam(String teamName, int priority) {
String teamNameIdentifier = String.valueOf(CHARACTERS.charAt(remainder)).repeat(iteration) + "-" + teamName;
return this.board.registerNewTeam(teamNameIdentifier);
}

}
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
package com.github.hostadam.command.parameter;

import com.github.hostadam.command.ParameterConverter;
import org.bukkit.Bukkit;
import com.github.hostadam.utils.PlayerUtils;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;

public class OfflinePlayerConverter implements ParameterConverter<OfflinePlayer> {
@Override
public OfflinePlayer convert(String arg) {
OfflinePlayer player = Bukkit.getOfflinePlayer(arg);
if(!player.hasPlayedBefore() && !player.isOnline()) {
return null;
}

return player;
return PlayerUtils.getOfflinePlayer(arg);
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/github/hostadam/menu/MenuListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public void onClose(InventoryCloseEvent event) {
@EventHandler
public void onClick(InventoryClickEvent event) {
Player player = (Player) event.getWhoClicked();
Menu.getPlayerMenu(player).ifPresent(newMenu -> {
boolean cancel = newMenu.click(event);
Menu.getPlayerMenu(player).ifPresent(menu -> {
boolean cancel = menu.click(event);
event.setCancelled(cancel);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/github/hostadam/utils/ItemBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public ItemBuilder glow() {

public ItemBuilder glow(boolean shouldApply) {
if(shouldApply) {
this.enchant(Enchantment.ARROW_INFINITE, 0);
this.enchant(Enchantment.INFINITY, 0);
this.itemFlag(ItemFlag.HIDE_ENCHANTS);
}

Expand Down
25 changes: 25 additions & 0 deletions src/main/java/com/github/hostadam/utils/PlayerUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,27 @@

import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;

import java.util.UUID;

public class PlayerUtils {

public static Player getDamager(Entity entity) {
if(entity.getType() == EntityType.PLAYER) {
return (Player) entity;
}

if(entity instanceof Projectile projectile && projectile.getShooter() instanceof Player) {
return (Player) projectile.getShooter();
}

return null;
}

public static OfflinePlayer getOfflinePlayer(String name) {
OfflinePlayer player = Bukkit.getOfflinePlayer(name);
if(!player.hasPlayedBefore() && !player.isOnline()) {
Expand All @@ -15,4 +31,13 @@ public static OfflinePlayer getOfflinePlayer(String name) {

return player;
}

public static OfflinePlayer getOfflinePlayer(UUID uniqueId) {
OfflinePlayer player = Bukkit.getOfflinePlayer(uniqueId);
if(!player.hasPlayedBefore() && !player.isOnline()) {
return null;
}

return player;
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/github/hostadam/utils/TimeUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class TimeUtils {
);

public static long parseTime(String string) {
if(string.contains("perm")) {
if(string.contains("perm") || string.equalsIgnoreCase("lifetime")) {
return Long.MAX_VALUE;
}

Expand Down

0 comments on commit 67c8bd8

Please sign in to comment.