Skip to content

Conversation

@Pinont
Copy link
Owner

@Pinont Pinont commented Nov 6, 2025

No description provided.

@Pinont Pinont requested a review from Copilot November 6, 2025 08:50
@Pinont Pinont merged commit db0b33f into main Nov 6, 2025
8 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request introduces significant architectural changes to support Folia compatibility, refactor the plugin structure, and update the ItemCreator API to require plugin instances. The changes include package restructuring, removal of deprecated features, and introduction of a new scheduler abstraction for Folia/Bukkit compatibility.

  • Package reorganization: Moving core plugin classes from com.github.pinont.singularitylib.plugin to com.github.pinont.plugin
  • API breaking change: ItemCreator constructors now require a Plugin parameter
  • New functionality: Folia detection and Scheduler abstraction for cross-platform task scheduling
  • Cleanup: Removal of deprecated commands (DevTool, FlySpeed, Vanish)

Reviewed Changes

Copilot reviewed 34 out of 34 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
ItemCreatorMetaTest.java Updated all ItemCreator instantiations to include plugin parameter
TestPlugin.java Updated CorePlugin import path after package restructure
paper-plugin.yml New plugin configuration file for Paper/Folia
api-version.yml Removed version configuration file
Vanish.java, FlySpeed.java, DevTool.java Removed deprecated command implementations
ItemCreator.java Updated to require Plugin parameter, moved static utility methods to ItemInteraction
ItemHeadCreator.java, CrossbowCreator.java Updated constructors to accept Plugin parameter
ItemInteraction.java Changed from interface to abstract class, added static utility methods
Menu.java, Layout.java Updated to require Plugin parameter, changed Layout to concrete class
Scheduler.java, Runner.java New Folia/Bukkit scheduler abstraction layer
EntityCreator.java Refactored to use HashMap for properties instead of individual boolean flags
ConfigManager.java Added reloadConfig method, changed config field to non-final
CorePlugin.java Added Folia detection, updated package paths
pom.xml Updated version to 1.3.0-SNAPSHOT, added Folia API dependency
Various manager/util classes Updated import statements for new package structure
Comments suppressed due to low confidence (1)

src/main/java/com/github/pinont/singularitylib/api/entity/EntityCreator.java:243

  • Variable properties may be null at this access as suggested by this null guard.
        if (properties.containsKey("maxHealth")) {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


private boolean isSetMaxHealth = false;
private double maxHealth;
private HashMap<String, Object> properties;
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The properties HashMap is never initialized, which will cause a NullPointerException when any setter method is called (e.g., addPassenger, setMaxHealth). Initialize the HashMap in the constructor: this.properties = new HashMap<>();

Copilot uses AI. Check for mistakes.
Entity entity = Objects.requireNonNull(location.getWorld()).spawnEntity(location, entityType);
sendDebugMessage("Spawned " + entityType + " at " + location);
if (isSetMaxHealth) {
if (properties != null) return entity;
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is inverted. The method returns early if properties is NOT null, which means all property configurations are ignored. This should be if (properties == null) return entity; to skip property application only when no properties have been set.

Suggested change
if (properties != null) return entity;
if (properties == null) return entity;

Copilot uses AI. Check for mistakes.
scheduledTask = regionScheduler.runAtFixedRate(plugin, location, _ -> runner.run(), delayTicks, periodTicks);
} else {
bukkitScheduler = server.getScheduler();
bukkitTask = bukkitScheduler.runTaskTimer(plugin, runner::run, 0L, periodTicks * timeUnit.toMillis(periodTicks));
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect calculation for Bukkit task timer period. The timeUnit.toMillis(periodTicks) converts ticks to milliseconds, but runTaskTimer expects ticks. This should use Common.toTicks(periodTicks, timeUnit) instead to convert the period to ticks correctly.

Suggested change
bukkitTask = bukkitScheduler.runTaskTimer(plugin, runner::run, 0L, periodTicks * timeUnit.toMillis(periodTicks));
bukkitTask = bukkitScheduler.runTaskTimer(plugin, runner::run, 0L, Common.toTicks(periodTicks, timeUnit));

Copilot uses AI. Check for mistakes.
}

public void runRepeatingTask(Plugin plugin, World world, Runner runner, int delayTicks, long periodTicks, TimeUnit timeUnit) {
new Scheduler().runRepeatingTask(plugin, new Location(world, 0, 0, 0), runner,delayTicks, periodTicks, timeUnit);
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a new Scheduler instance and calling an instance method is inefficient and loses the reference to the scheduled task. This should either call the method on the current instance (this.runRepeatingTask(...)) or return the created Scheduler so the caller can manage the task.

Suggested change
new Scheduler().runRepeatingTask(plugin, new Location(world, 0, 0, 0), runner,delayTicks, periodTicks, timeUnit);
this.runRepeatingTask(plugin, new Location(world, 0, 0, 0), runner, delayTicks, periodTicks, timeUnit);

Copilot uses AI. Check for mistakes.
}

public void runRepeatingTask(Plugin plugin, World world, Runner runner, int delayTicks, long periodTicks, TimeUnit timeUnit) {
new Scheduler().runRepeatingTask(plugin, new Location(world, 0, 0, 0), runner,delayTicks, periodTicks, timeUnit);
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after comma in method call arguments between runner and delayTicks.

Suggested change
new Scheduler().runRepeatingTask(plugin, new Location(world, 0, 0, 0), runner,delayTicks, periodTicks, timeUnit);
new Scheduler().runRepeatingTask(plugin, new Location(world, 0, 0, 0), runner, delayTicks, periodTicks, timeUnit);

Copilot uses AI. Check for mistakes.
* A layout maps a character key to a button for menu positioning.
*/
public interface Layout {
public class Layout {
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing Layout from an interface to a concrete class is a breaking API change that will affect any code that implements the interface. Consider deprecating the interface first or providing a migration path for existing implementations.

Copilot uses AI. Check for mistakes.
<dependency>
<groupId>com.github.Pinont</groupId>
<artifactId>Singularity-DevTool</artifactId>
<version>cbd0e31e44</version>
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Using a git commit hash as a version for the Singularity-DevTool dependency is not recommended for production. Consider using a tagged release version for better version tracking and stability.

Suggested change
<version>cbd0e31e44</version>
<version>1.2.0</version>

Copilot uses AI. Check for mistakes.
public Player getDamager() {
return this.damager;
}

Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method overrides Event.callEvent; it is advisable to add an Override annotation.

Suggested change
@Override

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants