forked from mcMMO-Dev/mcMMO
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
235 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/com/gmail/nossr50/events/skills/fishing/McMMOPlayerMasterAnglerEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.gmail.nossr50.events.skills.fishing; | ||
|
||
import com.gmail.nossr50.datatypes.player.McMMOPlayer; | ||
import com.gmail.nossr50.skills.fishing.FishingManager; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class McMMOPlayerMasterAnglerEvent extends McMMOPlayerFishingEvent { | ||
private int reducedMinWaitTime; | ||
private int reducedMaxWaitTime; | ||
private final FishingManager fishingManager; | ||
|
||
public McMMOPlayerMasterAnglerEvent(@NotNull McMMOPlayer mcMMOPlayer, | ||
int reducedMinWaitTime, | ||
int reducedMaxWaitTime, | ||
FishingManager fishingManager) { | ||
super(mcMMOPlayer); | ||
this.fishingManager = fishingManager; | ||
this.reducedMinWaitTime = Math.max(reducedMinWaitTime, getReducedMinWaitTimeLowerBound()); | ||
this.reducedMaxWaitTime = Math.max(reducedMaxWaitTime, getReducedMaxWaitTimeLowerBound()); | ||
} | ||
|
||
public int getReducedMinWaitTime() { | ||
return reducedMinWaitTime; | ||
} | ||
|
||
public void setReducedMinWaitTime(int reducedMinWaitTime) { | ||
if (reducedMinWaitTime < 0 || reducedMinWaitTime > reducedMaxWaitTime) { | ||
throw new IllegalArgumentException("Reduced min wait time must be greater than or equal to 0" + | ||
" and less than reduced max wait time."); | ||
} | ||
this.reducedMinWaitTime = Math.max(reducedMinWaitTime, getReducedMinWaitTimeLowerBound()); | ||
} | ||
|
||
public int getReducedMaxWaitTime() { | ||
return reducedMaxWaitTime; | ||
} | ||
|
||
public void setReducedMaxWaitTime(int reducedMaxWaitTime) { | ||
if (reducedMaxWaitTime < 0 || reducedMaxWaitTime < reducedMinWaitTime) { | ||
throw new IllegalArgumentException("Reduced max wait time must be greater than or equal to 0" + | ||
" and greater than reduced min wait time."); | ||
} | ||
this.reducedMaxWaitTime = Math.max(reducedMaxWaitTime, getReducedMaxWaitTimeLowerBound()); | ||
} | ||
|
||
public int getReducedMinWaitTimeLowerBound() { | ||
return fishingManager.getMasterAnglerMinWaitLowerBound(); | ||
} | ||
|
||
public int getReducedMaxWaitTimeLowerBound() { | ||
return fishingManager.getMasterAnglerMaxWaitLowerBound(); | ||
} | ||
} |
13 changes: 7 additions & 6 deletions
13
src/main/java/com/gmail/nossr50/listeners/ChunkListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
package com.gmail.nossr50.listeners; | ||
|
||
import com.gmail.nossr50.mcMMO; | ||
import org.bukkit.Chunk; | ||
import org.bukkit.entity.LivingEntity; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.world.ChunkUnloadEvent; | ||
|
||
import java.util.List; | ||
import java.util.Arrays; | ||
|
||
public class ChunkListener implements Listener { | ||
|
||
@EventHandler(ignoreCancelled = true) | ||
public void onChunkUnload(ChunkUnloadEvent event) { | ||
List<LivingEntity> matchingEntities | ||
= mcMMO.getTransientEntityTracker().getAllTransientEntitiesInChunk(event.getChunk()); | ||
for(LivingEntity livingEntity : matchingEntities) { | ||
mcMMO.getTransientEntityTracker().killSummonAndCleanMobFlags(livingEntity, null, false); | ||
} | ||
final Chunk unloadingChunk = event.getChunk(); | ||
Arrays.stream(unloadingChunk.getEntities()) | ||
.filter(LivingEntity.class::isInstance) | ||
.map(LivingEntity.class::cast) | ||
.forEach(livingEntity -> mcMMO.getTransientEntityTracker().removeTrackedEntity(livingEntity)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.