-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for see through Text Holograms (#85)
* Initial see through implementation * Added command implementation * Added storage implementation * Added missing references
- Loading branch information
Showing
12 changed files
with
121 additions
and
4 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
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
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
69 changes: 69 additions & 0 deletions
69
src/main/java/de/oliver/fancyholograms/commands/hologram/SeeThroughCMD.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,69 @@ | ||
package de.oliver.fancyholograms.commands.hologram; | ||
|
||
import de.oliver.fancyholograms.FancyHolograms; | ||
import de.oliver.fancyholograms.api.Hologram; | ||
import de.oliver.fancyholograms.api.data.TextHologramData; | ||
import de.oliver.fancyholograms.api.events.HologramUpdateEvent; | ||
import de.oliver.fancyholograms.commands.HologramCMD; | ||
import de.oliver.fancyholograms.commands.Subcommand; | ||
import de.oliver.fancylib.MessageHelper; | ||
import org.bukkit.command.CommandSender; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.List; | ||
import java.util.Locale; | ||
|
||
public class SeeThroughCMD implements Subcommand { | ||
|
||
@Override | ||
public List<String> tabcompletion(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean run(@NotNull CommandSender player, @Nullable Hologram hologram, @NotNull String[] args) { | ||
if (!(hologram.getData().getTypeData() instanceof TextHologramData textData)) { | ||
MessageHelper.error(player, "This command can only be used on text holograms"); | ||
return false; | ||
} | ||
|
||
|
||
final var enabled = switch (args[3].toLowerCase(Locale.ROOT)) { | ||
case "true" -> true; | ||
case "false" -> false; | ||
default -> null; | ||
}; | ||
|
||
if (enabled == null) { | ||
MessageHelper.error(player, "Could not parse see through flag"); | ||
return false; | ||
} | ||
|
||
if (enabled == textData.isSeeThrough()) { | ||
MessageHelper.warning(player, "This hologram already has see through " + (enabled ? "enabled" : "disabled")); | ||
return false; | ||
} | ||
|
||
final var copied = hologram.getData().copy(); | ||
((TextHologramData) copied.getTypeData()).setSeeThrough(enabled); | ||
|
||
if (!HologramCMD.callModificationEvent(hologram, player, copied, HologramUpdateEvent.HologramModification.SEE_THROUGH)) { | ||
return false; | ||
} | ||
|
||
if (enabled == textData.isSeeThrough()) { | ||
MessageHelper.warning(player, "This hologram already has see through " + (enabled ? "enabled" : "disabled")); | ||
return false; | ||
} | ||
|
||
textData.setSeeThrough(((TextHologramData) copied.getTypeData()).isSeeThrough()); | ||
|
||
if (FancyHolograms.get().getHologramConfiguration().isSaveOnChangedEnabled()) { | ||
FancyHolograms.get().getHologramStorage().save(hologram); | ||
} | ||
|
||
MessageHelper.success(player, "Changed see through"); | ||
return true; | ||
} | ||
} |
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