iHCF Enderpearl Off Cap-Zone fix

Status
This thread has been locked.

aitch

Banned
Feedback score
-1
Posts
43
Reactions
16
Resources
0
In some versions of iHCF, if you enderpearl from the capzone when you're capping outside of the event's territory it will keep you capping.

I had a friend come to me and ask me to fix this after asking Notifyz to help him, and he then said he'd do this for $25. 25 fucking dollars for about 20 lines of code.

So I helped him, and here's the fix for free, for everyone so you don't have to deal with scummy people like him.

Code:
    @EventHandler
    public void onTeleport(PlayerTeleportEvent event){
        EventTimer eventTimer = plugin.getTimerManager().getEventTimer();
        if(eventTimer.getRemaining() < 0L) return;
        EventFaction eventFaction = eventTimer.getEventFaction();
        if(event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL || plugin.getTimerManager().getEventTimer() == null || eventFaction == null || eventFaction.getCaptureZones() == null) {
            return;
        }
        for(CaptureZone captureZone : eventFaction.getCaptureZones()) {
            if(captureZone.getCappingPlayer() == event.getPlayer()) {
                plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, () -> {
                    if(!captureZone.getCuboid().contains(event.getPlayer().getLocation())) {
                        eventFaction.getEventType().getEventTracker().onControlLoss(event.getPlayer(), captureZone, eventFaction);
                        captureZone.setCappingPlayer(null);
                    }
                }, 10L);
            }
        }
    }
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

aitch

Banned
Feedback score
-1
Posts
43
Reactions
16
Resources
0
Actually I was joking with that, because he always asked me to help him for every single thing.

And not even going to mention how awful that code is, yet you used task to remove capping player. facepalm
Teleport event is called when the teleport() method is called, you need a runnable.
 
Banned forever. Reason: Ban Evading (declynXD, https://builtbybit.com/members/declynxd.139302/)

aitch

Banned
Feedback score
-1
Posts
43
Reactions
16
Resources
0
What has event calling to do with the #setCappingPlayer?

And I said you don't even this whole thing facepalm
What's wrong with calling #setCappingPlayer in a new thread/task?
 
Banned forever. Reason: Ban Evading (declynXD, https://builtbybit.com/members/declynxd.139302/)
Status
This thread has been locked.
Top