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

1.16.5対応 #13

Merged
merged 43 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e8837c9
[Clean] move packages
sysnote8main Oct 5, 2024
c637980
[Change] update to 1.16.5 and add DecentHolograms to dependency
sysnote8main Oct 5, 2024
eee1e64
[Fix] forget to import package
sysnote8main Oct 5, 2024
8b76608
[Fix] RankingDisplayer.java move package to root
sysnote8main Oct 5, 2024
723266c
[Add] API wrapper for KDStatusReloaded
sysnote8main Oct 6, 2024
e4a6e4e
[Add] CacheManager to separate logic
sysnote8main Oct 6, 2024
6524108
[Add] initialize CacheManager in RankingDisplayer.java
sysnote8main Oct 6, 2024
763e563
[Change] move classes to correct packages
sysnote8main Oct 6, 2024
177d7fd
[Change] Add PlaceholderAPI to dependency
sysnote8main Oct 6, 2024
c07553e
[Change] Use Instance for CacheManager
sysnote8main Oct 6, 2024
4f28646
[Add] Convert method for RankingType from String
sysnote8main Oct 6, 2024
ac2f5db
[Remove] unused field `cache`
sysnote8main Oct 6, 2024
2beed49
[Change] rename & remove unused field for other data cache
sysnote8main Oct 6, 2024
093e332
[Add] KDSPlaceholderExpansion support placeholders
sysnote8main Oct 6, 2024
8c0750a
[Add] README.md for human
sysnote8main Oct 6, 2024
5815ea7
[Add] Caution for each method
sysnote8main Oct 6, 2024
86ddc6d
[Add] Javadoc and comments for KDSPlaceholderExpansion
sysnote8main Oct 6, 2024
3951832
[Remove] sk89q maven from pom.xml
sysnote8main Oct 6, 2024
b1bcd30
[Add] DH Action generator
sysnote8main Oct 6, 2024
0f4b288
[Add] Easy system to add page rotation
sysnote8main Oct 6, 2024
1c9be2f
[Update] Comment of KDSAPI.java
sysnote8main Oct 6, 2024
963c4b5
[Fix] Placeholder works now
sysnote8main Oct 6, 2024
6419ebf
[Add] Load ranking on startup
sysnote8main Oct 6, 2024
4895c9c
[Add] Data holder for each ranking data
sysnote8main Oct 6, 2024
f8b8c4e
[Add] Hologram generator
sysnote8main Oct 6, 2024
f7d3630
[Add] Manager of holograms in the world
sysnote8main Oct 6, 2024
c9bb854
[Add] Command to control holograms in minecraft
sysnote8main Oct 6, 2024
3b9295f
[Update] gitignore for intellij
sysnote8main Oct 6, 2024
6b962c1
[Change] apply intellij format
sysnote8main Oct 6, 2024
3b142e0
[Fix] forget to return
sysnote8main Oct 6, 2024
eb79773
[Add] Cache update option
sysnote8main Oct 8, 2024
610f24b
[Update] upload build artifacts
sysnote8main Oct 8, 2024
14a1914
[Remove] unusable comment
sysnote8main Oct 8, 2024
e20cec1
[Format] PluginConfig.java
sysnote8main Oct 12, 2024
bdc53cc
[Add] Load all holo
sysnote8main Oct 12, 2024
5b5c0dc
[Add] Add hologram from config location
sysnote8main Oct 12, 2024
750a88c
[Fix] Calculate last update time
sysnote8main Oct 12, 2024
452df19
[Change] Remove unused comment and add listener
sysnote8main Oct 12, 2024
2164fd9
[Add] Authors
sysnote8main Oct 12, 2024
85e52ec
[Fix] Placeholder text
sysnote8main Oct 12, 2024
82104d7
[Feat] Support load holograms which created before
sysnote8main Oct 12, 2024
066f91e
[Remove] unused comment
sysnote8main Oct 12, 2024
dd87c78
[Change] apply intellij format action
sysnote8main Oct 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ jobs:
- run: java -version
- run: mvn --version
- run: mvn -B package
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4.4.1
with:
path: /home/runner/work/RankingDisplayer/RankingDisplayer/target/
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,7 @@ buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar

# End of https://www.gitignore.io/api/maven,eclipse
# End of https://www.gitignore.io/api/maven,eclipse

.idea/
*.iml
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## RankingDisplayer

## Supported Placeholders (PlaceholderAPI)
- Under construction...
26 changes: 21 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,25 @@
<id>rayzr-repo</id>
<url>https://raw.githubusercontent.com/Rayzr522/maven-repo/master/</url>
</repository>
<repository>
<id>sk89q-repo</id>
<url>https://maven.sk89q.com/repo/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io/</url>
</repository>
<repository>
<id>codemc</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<version>1.16.5-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand All @@ -79,5 +83,17 @@
<artifactId>KDStatusReloaded</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>com.github.decentsoftware-eu</groupId>
<artifactId>decentholograms</artifactId>
<version>2.8.11</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.6</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
23 changes: 0 additions & 23 deletions src/main/java/jp/azisaba/lgw/rankingdisplayer/DisplayType.java

This file was deleted.

69 changes: 46 additions & 23 deletions src/main/java/jp/azisaba/lgw/rankingdisplayer/RankingDisplayer.java
Original file line number Diff line number Diff line change
@@ -1,52 +1,75 @@
package jp.azisaba.lgw.rankingdisplayer;

import java.io.File;
import java.util.UUID;

import jp.azisaba.lgw.rankingdisplayer.command.RankingHoloCommand;
import jp.azisaba.lgw.rankingdisplayer.config.PluginConfig;
import jp.azisaba.lgw.rankingdisplayer.holo.DHListener;
import jp.azisaba.lgw.rankingdisplayer.integration.KDSAPI;
import jp.azisaba.lgw.rankingdisplayer.integration.KDSPlaceholderExpansion;
import jp.azisaba.lgw.rankingdisplayer.manager.RankingCacheManager;
import jp.azisaba.lgw.rankingdisplayer.manager.RankingHideManager;
import jp.azisaba.lgw.rankingdisplayer.ranking.RankingCommand;
import jp.azisaba.lgw.rankingdisplayer.task.AfterWorldLoadTask;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import net.md_5.bungee.api.ChatColor;
import java.io.File;
import java.util.UUID;

public class RankingDisplayer extends JavaPlugin {

private static PluginConfig config;
private DisplayListener listener;
private DHListener dhListener;

@Override
public void onEnable() {
if (!Bukkit.getPluginManager().isPluginEnabled("KDStatusReloaded")) {
getLogger().severe("KDStatusReloaded is not loaded.");
Bukkit.getPluginManager().disablePlugin(this);
}

// Migrate
convertSettingsFromLocalFile();

// Config
RankingDisplayer.config = new PluginConfig(this);
RankingDisplayer.config.loadConfig();

listener = new DisplayListener(this);
Bukkit.getPluginManager().registerEvents(listener, this);
// KDStatusReloaded API Setup
KDSAPI.loadPlugin(getLogger());

// Setup cacheManager's logger
RankingCacheManager.getInstance().setLogger(getLogger());
RankingCacheManager.getInstance().loadRanking();

// Events
dhListener = new DHListener();
Bukkit.getPluginManager().registerEvents(dhListener, this);

// Tasks
new AfterWorldLoadTask().runTaskLaterAsynchronously(this, 100);

// Commands
Bukkit.getPluginCommand("ranking").setExecutor(new RankingCommand());
Bukkit.getPluginCommand("ranking").setPermissionMessage(ChatColor.RED + "権限がありません!");

if ( Bukkit.getOnlinePlayers().size() > 0 ) {
for ( Player p : Bukkit.getOnlinePlayers() ) {
World world = p.getWorld();
if ( world == config.displayLocation.getWorld() ) {
listener.displayRankingForPlayerAsync(p, false);
}
}
Bukkit.getPluginCommand("rankingholo").setExecutor(new RankingHoloCommand());
Bukkit.getPluginCommand("rankingholo").setPermissionMessage(ChatColor.RED + "権限がありません!");

if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
new KDSPlaceholderExpansion().register();
}

// Finish message
Bukkit.getLogger().info(getName() + " enabled.");
}

@Override
public void onDisable() {
if ( listener != null ) {
listener.removeAllBoards();
}
// if (listener != null) {
// listener.removeAllBoards();
// }

Bukkit.getLogger().info(getName() + " disabled.");
}
Expand All @@ -66,21 +89,21 @@ public static PluginConfig getPluginConfig() {
private void convertSettingsFromLocalFile() {
File file = new File(getDataFolder(), "HideFromRanking.yml");

if ( !file.exists() ) {
if (!file.exists()) {
return;
}

YamlConfiguration conf = YamlConfiguration.loadConfiguration(file);

if ( conf.getConfigurationSection("") == null || conf.getConfigurationSection("").getKeys(false) == null ) {
if (conf.getConfigurationSection("") == null || conf.getConfigurationSection("").getKeys(false) == null) {
return;
}

for ( String key : conf.getConfigurationSection("").getKeys(false) ) {
for (String key : conf.getConfigurationSection("").getKeys(false)) {
UUID uuid = null;
try {
uuid = UUID.fromString(key);
} catch ( Exception e ) {
} catch (Exception e) {
Bukkit.getLogger().warning("Could not parse String \"" + key + "\"");
continue;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package jp.azisaba.lgw.rankingdisplayer.command;

import jp.azisaba.lgw.rankingdisplayer.manager.HoloManager;
import jp.azisaba.lgw.rankingdisplayer.manager.RankingCacheManager;
import jp.azisaba.lgw.rankingdisplayer.ranking.RankingType;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.*;

public class RankingHoloCommand implements CommandExecutor, TabCompleter {
public static final List<String> modes = Arrays.asList("place", "remove", "remove-all", "list", "cache-update");

@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
if (args.length < 1) {
return false;
}
String mode = args[0];
if (sender instanceof Player) {
Player player = (Player) sender;
switch (mode) {
case "place":
sender.sendMessage("hologram was created!");
HoloManager.addHolo(player.getLocation());
return true;
case "remove":
if (args.length != 2) {
sender.sendMessage("/" + command.getName() + " remove <hologramName>");
return true;
}
if (!HoloManager.getAllHoloNames().contains(args[1])) {
sender.sendMessage("This hologramName is invalid.");
return true;
}
HoloManager.removeHolo(args[1]);
sender.sendMessage("Successfully to remove hologram (name:" + args[1] + ")");
return true;
case "remove-all":
HoloManager.removeAllHolo();
sender.sendMessage("Successfully to remove all status holograms!");
return true;
case "list":
Set<String> names = HoloManager.getAllHoloNames();
sender.sendMessage("Size: " + names.size());
return true;
case "cache-update":
for (RankingType type : RankingType.values()) {
RankingCacheManager.getInstance().updateCache(type);
}
return true;
}
}
return false;
}

@Nullable
@Override
public List<String> onTabComplete(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
if (args.length == 1) {
return modes;
}

if (args.length == 2) {
if (args[0].equals("remove")) {
return new ArrayList<>(HoloManager.getAllHoloNames());
}
}

return Collections.emptyList();
}
}
Loading
Loading