-
-
Notifications
You must be signed in to change notification settings - Fork 0
GH-72 Create universal hologram provider instead of HoloEasy. #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
49baa20
594096d
3a54669
7c01196
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,31 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 4 | ||
ij_any_block_comment_add_space = false | ||
ij_any_block_comment_at_first_column = false | ||
ij_any_line_comment_at_first_column = false | ||
ij_any_line_comment_add_space = true | ||
|
||
[*.bat] | ||
end_of_line = crlf | ||
|
||
[{*.yaml,*.yml}] | ||
[*.yml] | ||
indent_size = 2 | ||
ij_yaml_align_values_properties = do_not_align | ||
ij_yaml_autoinsert_sequence_marker = true | ||
ij_yaml_block_mapping_on_new_line = false | ||
ij_yaml_indent_sequence_value = true | ||
ij_yaml_keep_indents_on_empty_lines = false | ||
ij_yaml_keep_line_breaks = true | ||
ij_yaml_sequence_on_new_line = false | ||
ij_yaml_space_before_colon = false | ||
ij_yaml_spaces_within_braces = true | ||
ij_yaml_spaces_within_brackets = true | ||
|
||
[*.java] | ||
ij_continuation_indent_size = 4 | ||
ij_java_class_count_to_use_import_on_demand = 999999 | ||
ij_java_insert_inner_class_imports = false | ||
ij_java_names_count_to_use_import_on_demand = 999999 | ||
ij_java_imports_layout = *, |, $* | ||
ij_java_generate_final_locals = true | ||
ij_java_generate_final_parameters = true | ||
ij_java_method_parameters_new_line_after_left_paren = true | ||
ij_java_method_parameters_right_paren_on_new_line = true | ||
ij_java_use_fq_class_names = false | ||
ij_java_class_names_in_javadoc = 1 |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
plugins { | ||
id("java-library") | ||
} | ||
|
||
group = "com.eternalcode" | ||
version = "1.0.4-SNAPSHOT" | ||
|
||
java { | ||
toolchain.languageVersion.set(JavaLanguageVersion.of(21)) | ||
} | ||
|
||
tasks.compileJava { | ||
options.compilerArgs = listOf("-Xlint:deprecation", "-parameters") | ||
options.encoding = "UTF-8" | ||
options.release = 21 | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,12 @@ | ||
package com.eternalcode.lobbyheads; | ||
|
||
import com.eternalcode.lobbyheads.head.HeadManager; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Root entry point for interacting with the LobbyHeads API. | ||
*/ | ||
public interface LobbyHeadsApi { | ||
|
||
HeadManager getHeadManager(); | ||
@NotNull HeadManager getHeadManager(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,44 @@ | ||
package com.eternalcode.lobbyheads; | ||
|
||
public class LobbyHeadsApiProvider { | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
private static LobbyHeadsApi lobbyHeadsApi; | ||
/** | ||
* Provides global access to the LobbyHeads API. | ||
*/ | ||
public final class LobbyHeadsApiProvider { | ||
|
||
public static LobbyHeadsApi provide() { | ||
if (lobbyHeadsApi == null) { | ||
throw new IllegalStateException("LobbyHeadsApi has not been initialized yet!"); | ||
} | ||
private static volatile LobbyHeadsApi api; | ||
|
||
return lobbyHeadsApi; | ||
private LobbyHeadsApiProvider() { | ||
throw new UnsupportedOperationException("This is a utility class."); | ||
} | ||
|
||
static void initialize(LobbyHeadsApi lobbyHeadsApi) { | ||
if (LobbyHeadsApiProvider.lobbyHeadsApi != null) { | ||
throw new IllegalStateException("LobbyHeadsApi has already been initialized!"); | ||
/** | ||
* @return The initialized LobbyHeadsApi instance. | ||
* @throws IllegalStateException if not initialized. | ||
*/ | ||
public static @NotNull LobbyHeadsApi get() { | ||
LobbyHeadsApi instance = api; | ||
if (instance == null) { | ||
throw new IllegalStateException("LobbyHeadsApi is not initialized yet."); | ||
} | ||
return instance; | ||
} | ||
|
||
LobbyHeadsApiProvider.lobbyHeadsApi = lobbyHeadsApi; | ||
/** | ||
* Internal use only. | ||
*/ | ||
static void initialize(@NotNull LobbyHeadsApi lobbyHeadsApi) { | ||
if (api != null) { | ||
throw new IllegalStateException("LobbyHeadsApi is already initialized."); | ||
} | ||
api = lobbyHeadsApi; | ||
} | ||
|
||
static void deinitialize() { | ||
if (lobbyHeadsApi == null) { | ||
throw new IllegalStateException("LobbyHeadsApi has not been initialized yet!"); | ||
if (api == null) { | ||
throw new IllegalStateException("LobbyHeadsApi is not initialized."); | ||
} | ||
|
||
lobbyHeadsApi = null; | ||
api = null; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,40 +1,54 @@ | ||||||||||||||||||||||||||||||||||||||||||||
package com.eternalcode.lobbyheads.head; | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
import com.eternalcode.lobbyheads.position.Position; | ||||||||||||||||||||||||||||||||||||||||||||
import com.eternalcode.lobbyheads.position.PositionAdapter; | ||||||||||||||||||||||||||||||||||||||||||||
import java.io.Serializable; | ||||||||||||||||||||||||||||||||||||||||||||
import java.util.Objects; | ||||||||||||||||||||||||||||||||||||||||||||
import java.util.UUID; | ||||||||||||||||||||||||||||||||||||||||||||
import org.bukkit.Location; | ||||||||||||||||||||||||||||||||||||||||||||
import org.jetbrains.annotations.NotNull; | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
public class Head { | ||||||||||||||||||||||||||||||||||||||||||||
public class Head implements Serializable { | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
private final String world; | ||||||||||||||||||||||||||||||||||||||||||||
private final double x, y, z; | ||||||||||||||||||||||||||||||||||||||||||||
private final float yaw, pitch; | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
private final Position position; | ||||||||||||||||||||||||||||||||||||||||||||
private String playerName; | ||||||||||||||||||||||||||||||||||||||||||||
private UUID playerUUID; | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
public Head(Position position, String playerName, UUID playerUUID) { | ||||||||||||||||||||||||||||||||||||||||||||
this.position = position; | ||||||||||||||||||||||||||||||||||||||||||||
public Head() { | ||||||||||||||||||||||||||||||||||||||||||||
this.world = null; | ||||||||||||||||||||||||||||||||||||||||||||
this.x = this.y = this.z = 0; | ||||||||||||||||||||||||||||||||||||||||||||
this.yaw = this.pitch = 0; | ||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+18
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Watch out for null world! The no-arg constructor sets 🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
public Head(@NotNull Location location, String playerName, UUID playerUUID) { | ||||||||||||||||||||||||||||||||||||||||||||
this.world = location.getWorld().getName(); | ||||||||||||||||||||||||||||||||||||||||||||
this.x = location.getX(); | ||||||||||||||||||||||||||||||||||||||||||||
this.y = location.getY(); | ||||||||||||||||||||||||||||||||||||||||||||
this.z = location.getZ(); | ||||||||||||||||||||||||||||||||||||||||||||
this.yaw = location.getYaw(); | ||||||||||||||||||||||||||||||||||||||||||||
this.pitch = location.getPitch(); | ||||||||||||||||||||||||||||||||||||||||||||
this.playerName = playerName; | ||||||||||||||||||||||||||||||||||||||||||||
this.playerUUID = playerUUID; | ||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
public Position getPosition() { | ||||||||||||||||||||||||||||||||||||||||||||
return this.position; | ||||||||||||||||||||||||||||||||||||||||||||
public @NotNull Location getLocation() { | ||||||||||||||||||||||||||||||||||||||||||||
return new Location( | ||||||||||||||||||||||||||||||||||||||||||||
org.bukkit.Bukkit.getWorld(this.world), | ||||||||||||||||||||||||||||||||||||||||||||
this.x, this.y, this.z, | ||||||||||||||||||||||||||||||||||||||||||||
this.yaw, this.pitch | ||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+35
to
41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add null safety for world The Consider adding a null check: public @NotNull Location getLocation() {
+ if (this.world == null) {
+ throw new IllegalStateException("World is not set");
+ }
+ var world = org.bukkit.Bukkit.getWorld(this.world);
+ if (world == null) {
+ throw new IllegalStateException("World '" + this.world + "' not found");
+ }
return new Location(
- org.bukkit.Bukkit.getWorld(this.world),
+ world,
this.x, this.y, this.z,
this.yaw, this.pitch
);
} 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
public Location getLocation() { | ||||||||||||||||||||||||||||||||||||||||||||
return PositionAdapter.convert(this.position); | ||||||||||||||||||||||||||||||||||||||||||||
public @NotNull UUID getPlayerUuid() { | ||||||||||||||||||||||||||||||||||||||||||||
return this.playerUUID; | ||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
public String getPlayerName() { | ||||||||||||||||||||||||||||||||||||||||||||
public @NotNull String getPlayerName() { | ||||||||||||||||||||||||||||||||||||||||||||
return this.playerName; | ||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
public UUID getPlayerUUID() { | ||||||||||||||||||||||||||||||||||||||||||||
return this.playerUUID; | ||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
public void replacePlayer(String newPlayerName, UUID newPlayerUUID) { | ||||||||||||||||||||||||||||||||||||||||||||
public void replacePlayer(@NotNull String newPlayerName, @NotNull UUID newPlayerUUID) { | ||||||||||||||||||||||||||||||||||||||||||||
this.playerName = newPlayerName; | ||||||||||||||||||||||||||||||||||||||||||||
this.playerUUID = newPlayerUUID; | ||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||
|
@@ -44,17 +58,15 @@ public boolean equals(Object object) { | |||||||||||||||||||||||||||||||||||||||||||
if (this == object) { | ||||||||||||||||||||||||||||||||||||||||||||
return true; | ||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
if (object == null || getClass() != object.getClass()) { | ||||||||||||||||||||||||||||||||||||||||||||
if (!(object instanceof Head other)) { | ||||||||||||||||||||||||||||||||||||||||||||
return false; | ||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
Head head = (Head) object; | ||||||||||||||||||||||||||||||||||||||||||||
return Objects.equals(this.position, head.position); | ||||||||||||||||||||||||||||||||||||||||||||
return this.world.equals(other.world) && | ||||||||||||||||||||||||||||||||||||||||||||
this.x == other.x && this.y == other.y && this.z == other.z; | ||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+64
to
66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing null check in equals The Add a null check: -return this.world.equals(other.world) &&
+return Objects.equals(this.world, other.world) &&
this.x == other.x && this.y == other.y && this.z == other.z; 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||
@Override | ||||||||||||||||||||||||||||||||||||||||||||
public int hashCode() { | ||||||||||||||||||||||||||||||||||||||||||||
return Objects.hash(this.position); | ||||||||||||||||||||||||||||||||||||||||||||
return Objects.hash(this.world, this.x, this.y, this.z); | ||||||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||||||
} |
Uh oh!
There was an error while loading. Please reload this page.