Skip to content
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

TNT Countdown Module - Remove Bukkit implementation #202

Merged

Conversation

ItsNature
Copy link
Collaborator

@ItsNature ItsNature commented Apr 2, 2025

Overview

Description:
Remove the Bukkit-specific implementation from the TNT Countdown Module, which was the only module in the API containing direct event handling. This change aligns the module with the rest of the project

Changes:

  • Removed Bukkit event listeners from the TNT Countdown Module.
  • The example code now manually triggers the functionality that was previously invoked via the Bukkit implementation.
  • Added TntCountdownModule#setTntCountdown(Recipients, ApolloEntity, ticks)

Code Example:

Spawn TNT with Custom Tick amount

public void overrideTntCountdownExample(Player viewer) {
    int customTicks = 200;
 
    TNTPrimed entity = viewer.getWorld().spawn(viewer.getLocation(), TNTPrimed.class);
    entity.setFuseTicks(customTicks);
 
    ApolloEntity apolloEntity = new ApolloEntity(entity.getEntityId(), entity.getUniqueId());
    this.tntCountdownModule.setTntCountdown(Recipients.ofEveryone(), apolloEntity, customTicks);
}

Modify Fuse Ticks on TNT Spawn

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
private void onTntSpawn(EntitySpawnEvent event) {
    String entityName = event.getEntityType().name();
    if (!entityName.equals("PRIMED_TNT") && !entityName.equals("TNT")) {
        return;
    }
 
    TNTPrimed primed = (TNTPrimed) event.getEntity();
    int customTicks = this.tntCountdownModule.getOptions().get(TntCountdownModule.TNT_TICKS);
    int defaultTicks = TntCountdownModule.TNT_TICKS.getDefaultValue();
    int currentTicks = primed.getFuseTicks();
 
    if (currentTicks != defaultTicks && !this.tntCountdownModule.getOptions().get(TntCountdownModule.OVERRIDE_CUSTOM_TICKS)) {
        customTicks = currentTicks;
 
        this.tntCountdownModule.setTntCountdown(Recipients.ofEveryone(),
            new ApolloEntity(primed.getEntityId(), primed.getUniqueId()),
            customTicks
        );
    }
 
    primed.setFuseTicks(customTicks);
}

Review Request Checklist

  • Your code follows the style guidelines of this project.
  • I have performed a self-review of my code.
  • I have tested this change myself. (If applicable)
  • I have made corresponding changes to the documentation. (If applicable)
  • The branch name follows the projects naming conventions. (e.g. feature/add-module & bugfix/fix-issue)

@ItsNature ItsNature added the type: Enhancement Feature improvement or addition label Apr 2, 2025
@ItsNature ItsNature merged commit 6266cb7 into version/1.1.8 Apr 8, 2025
2 checks passed
@ItsNature ItsNature deleted the module/remove-tnt-countdown-bukkit-implementation branch April 8, 2025 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: Enhancement Feature improvement or addition
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants