-
-
Notifications
You must be signed in to change notification settings - Fork 19
GH-1031 Add vanish feature. #1048
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
Merged
+1,371
−34
Merged
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
7f19708
init vanish
P1otrulla 7671e1e
update
P1otrulla 58394c5
remove memory-leak, add quit off vanish and others
P1otrulla fac2d17
Update eternalcore-core/src/main/java/com/eternalcode/core/feature/va…
P1otrulla 10b0419
Update eternalcore-core/src/main/java/com/eternalcode/core/feature/va…
P1otrulla 900f403
Update eternalcore-core/src/main/java/com/eternalcode/core/feature/va…
P1otrulla 057accd
follow smart's review
P1otrulla a8d52fc
Merge branch 'master' into 2.0/vanish-implementation
P1otrulla b1f5d60
Merge branch 'master' into 2.0/vanish-implementation
P1otrulla b430ca0
Added if-checks
P1otrulla 12fc65f
implemented messages and config
P1otrulla cb80662
add messages and follow suggestions
P1otrulla 6906800
add getVanished players to api and implement reminder task
P1otrulla e8855a6
some code stylish fixes and removed unused imports
P1otrulla 525ccdd
added missing inject annotation
P1otrulla f43ae5e
Merge branch 'master' into 2.0/vanish-implementation
P1otrulla 7a7c5ad
follow mądra głowa gemini suggestions
P1otrulla f6898ca
follow Martin's suggestions
P1otrulla 880e0a0
repair project building failure
P1otrulla 9304ad0
use package-private
Rollczi 3ae571f
use package-private
Rollczi 8170308
follow team member suggestions
P1otrulla 5505d4f
Merge remote-tracking branch 'origin/2.0/vanish-implementation' into …
P1otrulla 59adeb7
fix space
P1otrulla 77de94b
fix codestyle
P1otrulla 3b1f4fc
Merge branch 'master' into 2.0/vanish-implementation
vLuckyyy f8c3305
Add a less restrictive silent inventory opener
vLuckyyy 80eae83
Fix team removal, improve food key name, improve default actionbar me…
vLuckyyy 5d86f18
fixed event calling logic
P1otrulla 29614d2
Merge remote-tracking branch 'origin/2.0/vanish-implementation' into …
P1otrulla 3d0fd89
Fix.
vLuckyyy ff3026b
cr
Rollczi eed8225
Update eternalcore-core/src/main/java/com/eternalcode/core/feature/va…
P1otrulla 1fce077
Update eternalcore-core/src/main/java/com/eternalcode/core/feature/va…
P1otrulla cffe1db
follow Rollczi suggestions & added EternalReloadEvent
P1otrulla 6665420
Merge remote-tracking branch 'origin/2.0/vanish-implementation' into …
P1otrulla 6ed3286
fix
P1otrulla cd8f7fe
i was trying...
P1otrulla cb2b1b2
veni vidi vici
P1otrulla d62503b
Update eternalcore-core/src/main/java/com/eternalcode/core/publish/ev…
Rollczi 6a62064
Optimize vanished player name complete removal logic.
Rollczi 4af126c
Merge remote-tracking branch 'origin/2.0/vanish-implementation' into …
Rollczi edc2803
Move Cancellable to AbstractVanishEvent
Rollczi 96629f3
Move Cancellable to AbstractVanishEvent
Rollczi cda2867
Update eternalcore-core/src/main/java/com/eternalcode/core/configurat…
P1otrulla 44b3a2e
Update eternalcore-core/src/main/java/com/eternalcode/core/feature/va…
P1otrulla 6ce8689
Fix okaeri
Rollczi 0d55747
Follow review feedback, complete using proxy.
vLuckyyy 263c460
config -> settings, removed unused imports
P1otrulla File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
eternalcore-api/src/main/java/com/eternalcode/core/feature/vanish/VanishService.java
This file contains hidden or 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,72 @@ | ||
package com.eternalcode.core.feature.vanish; | ||
|
||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.ApiStatus; | ||
|
||
import java.util.Set; | ||
import java.util.UUID; | ||
|
||
public interface VanishService { | ||
|
||
/** | ||
* Enables vanish for the specified player. | ||
* | ||
* @param player The player to enable vanish for. | ||
*/ | ||
void enableVanish(Player player); | ||
|
||
/** | ||
* Disables vanish for the specified player. | ||
* | ||
* @param player The player to disable vanish for. | ||
*/ | ||
void disableVanish(Player player); | ||
|
||
/** | ||
* Checks if the specified player is vanished. | ||
* | ||
* @param player The player to check. | ||
* @return true if the player is vanished, false otherwise. | ||
*/ | ||
boolean isVanished(Player player); | ||
|
||
default boolean toggleVanish(Player player) { | ||
if (isVanished(player)) { | ||
disableVanish(player); | ||
return false; | ||
} | ||
enableVanish(player); | ||
return true; | ||
} | ||
|
||
/** | ||
* Checks if the player with the specified unique ID is vanished. | ||
* | ||
* @param uniqueId The unique ID of the player to check. | ||
* @return true if the player is vanished, false otherwise. | ||
*/ | ||
boolean isVanished(UUID uniqueId); | ||
|
||
/** | ||
* Hides vanished players from the specified player. | ||
* | ||
* @param observer The player from whom vanished players should be hidden. | ||
*/ | ||
@ApiStatus.Internal | ||
void hideVanishedPlayersFrom(Player observer); | ||
P1otrulla marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* Gets a set of UUIDs of all vanished players. | ||
* | ||
* @return A set containing the unique IDs of all vanished players. | ||
*/ | ||
Set<UUID> getVanishedPlayers(); | ||
|
||
/** | ||
* Gets a set of names of all vanished players. | ||
* | ||
* @return A set containing the names of all vanished players. | ||
*/ | ||
Set<String> getVanishedPlayerNames(); | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...core-api/src/main/java/com/eternalcode/core/feature/vanish/event/AbstractVanishEvent.java
This file contains hidden or 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,30 @@ | ||
package com.eternalcode.core.feature.vanish.event; | ||
|
||
import org.bukkit.event.Cancellable; | ||
import org.bukkit.event.Event; | ||
import org.bukkit.entity.Player; | ||
|
||
public abstract class AbstractVanishEvent extends Event implements Cancellable { | ||
|
||
private final Player player; | ||
private boolean cancelled = false; | ||
|
||
public AbstractVanishEvent(Player player) { | ||
this.player = player; | ||
} | ||
|
||
public Player getPlayer() { | ||
return this.player; | ||
} | ||
|
||
@Override | ||
public boolean isCancelled() { | ||
return this.cancelled; | ||
} | ||
|
||
@Override | ||
public void setCancelled(boolean cancel) { | ||
this.cancelled = cancel; | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
...lcore-api/src/main/java/com/eternalcode/core/feature/vanish/event/DisableVanishEvent.java
This file contains hidden or 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,23 @@ | ||
package com.eternalcode.core.feature.vanish.event; | ||
|
||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.HandlerList; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class DisableVanishEvent extends AbstractVanishEvent { | ||
P1otrulla marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
private static final HandlerList HANDLERS = new HandlerList(); | ||
|
||
public DisableVanishEvent(Player player) { | ||
super(player); | ||
} | ||
|
||
@Override | ||
public @NotNull HandlerList getHandlers() { | ||
return HANDLERS; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return HANDLERS; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...alcore-api/src/main/java/com/eternalcode/core/feature/vanish/event/EnableVanishEvent.java
This file contains hidden or 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,23 @@ | ||
package com.eternalcode.core.feature.vanish.event; | ||
|
||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.HandlerList; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class EnableVanishEvent extends AbstractVanishEvent { | ||
P1otrulla marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
private static final HandlerList HANDLERS = new HandlerList(); | ||
|
||
public EnableVanishEvent(Player player) { | ||
super(player); | ||
} | ||
|
||
@Override | ||
public @NotNull HandlerList getHandlers() { | ||
return HANDLERS; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return HANDLERS; | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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
52 changes: 52 additions & 0 deletions
52
eternalcore-core/src/main/java/com/eternalcode/core/feature/vanish/VanishCommand.java
This file contains hidden or 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,52 @@ | ||
package com.eternalcode.core.feature.vanish; | ||
|
||
import com.eternalcode.annotations.scan.command.DescriptionDocs; | ||
import com.eternalcode.core.feature.vanish.messages.VanishMessages; | ||
import com.eternalcode.core.injector.annotations.Inject; | ||
import com.eternalcode.core.notice.NoticeService; | ||
import com.eternalcode.multification.notice.provider.NoticeProvider; | ||
import dev.rollczi.litecommands.annotations.argument.Arg; | ||
import dev.rollczi.litecommands.annotations.command.Command; | ||
import dev.rollczi.litecommands.annotations.context.Context; | ||
import dev.rollczi.litecommands.annotations.execute.Execute; | ||
import dev.rollczi.litecommands.annotations.permission.Permission; | ||
import org.bukkit.entity.Player; | ||
|
||
@Command(name = "vanish", aliases = {"v"}) | ||
@Permission(VanishPermissionConstant.VANISH_COMMAND_PERMISSION) | ||
class VanishCommand { | ||
|
||
private final NoticeService noticeService; | ||
private final VanishService vanishService; | ||
|
||
@Inject | ||
public VanishCommand(NoticeService noticeService, VanishService vanishService) { | ||
this.noticeService = noticeService; | ||
this.vanishService = vanishService; | ||
} | ||
|
||
@Execute | ||
@DescriptionDocs(description = "Toggle your vanish state") | ||
void vanishSelf(@Context Player player) { | ||
boolean vanished = this.vanishService.toggleVanish(player); | ||
this.sendMessage(player, player, vanished ? VanishMessages::vanishEnabled : VanishMessages::vanishDisabled); | ||
} | ||
|
||
@Execute | ||
@Permission(VanishPermissionConstant.VANISH_COMMAND_PERMISSION_OTHER) | ||
@DescriptionDocs(description = "Toggle vanish state for another player") | ||
void vanishOther(@Context Player player, @Arg Player target) { | ||
boolean vanished = this.vanishService.toggleVanish(target); | ||
this.sendMessage(player, target, vanished ? VanishMessages::vanishEnabledOther : VanishMessages::vanishDisabledOther); | ||
} | ||
|
||
private void sendMessage(Player sender, Player target, NoticeProvider<VanishMessages> message) { | ||
this.noticeService.create() | ||
.player(sender.getUniqueId()) | ||
.placeholder("{PLAYER}", target.getName()) | ||
.notice(messages -> message.extract(messages.vanish())) | ||
.send(); | ||
} | ||
|
||
} | ||
|
49 changes: 49 additions & 0 deletions
49
eternalcore-core/src/main/java/com/eternalcode/core/feature/vanish/VanishConfig.java
This file contains hidden or 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,49 @@ | ||
package com.eternalcode.core.feature.vanish; | ||
|
||
import eu.okaeri.configs.OkaeriConfig; | ||
import eu.okaeri.configs.annotation.Comment; | ||
import lombok.Getter; | ||
import lombok.experimental.Accessors; | ||
import org.bukkit.ChatColor; | ||
|
||
@Getter | ||
@Accessors(fluent = true) | ||
public class VanishConfig extends OkaeriConfig implements VanishSettings { | ||
|
||
@Comment("Should players with eternalcore.vanish.join permission join in vanish mode without join message") | ||
public boolean silentJoin = false; | ||
|
||
@Comment("Should vanished players be invulnerable to damage from other players") | ||
public boolean godMode = true; | ||
|
||
@Comment("Give night vision effect to vanished players") | ||
public boolean nightVision = true; | ||
|
||
@Comment("Should vanished players be able to silently view other players' inventories?") | ||
public boolean silentInventoryAccess = true; | ||
|
||
@Comment("Should vanished players glow to make them visible to other staff members?") | ||
public boolean glowEffect = true; | ||
|
||
@Comment("Color of the glow effect for vanished players") | ||
public ChatColor color = ChatColor.LIGHT_PURPLE; | ||
|
||
@Comment("Prevent vanished players from dropping items") | ||
public boolean blockItemDropping = false; | ||
|
||
@Comment("Prevent vanished players from picking up items") | ||
public boolean blockItemPickup = true; | ||
|
||
@Comment("Prevent vanished players from hunger loss") | ||
public boolean blockHungerLoss = true; | ||
|
||
@Comment("Prevent vanished players from using public chat") | ||
public boolean blockChatUsage = false; | ||
|
||
@Comment("Prevent vanished players from breaking blocks") | ||
public boolean blockBlockBreaking = false; | ||
|
||
@Comment("Prevent vanished players from placing blocks") | ||
public boolean blockBlockPlacing = false; | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.