Skip to content

Commit

Permalink
managers move to manager pack
Browse files Browse the repository at this point in the history
  • Loading branch information
KunoSayo committed Sep 8, 2018
1 parent 343234b commit b561da1
Show file tree
Hide file tree
Showing 23 changed files with 46 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/github/euonmyoji/newhonor/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* @author yinyangshi
*/
public class Main {
public final class Main {
public static void main(String[] args) {
JOptionPane.showMessageDialog(null, "你执行插件jar文件干嘛?:D");
JOptionPane.showMessageDialog(null, "真想搞个无限弹对话窗啊#run");
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/com/github/euonmyoji/newhonor/NewHonor.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@
import com.github.euonmyoji.newhonor.data.HonorValueData;
import com.github.euonmyoji.newhonor.listener.NewHonorMessageListener;
import com.github.euonmyoji.newhonor.listener.UltimateChatEventListener;
import com.github.euonmyoji.newhonor.manager.NucleusManager;
import com.github.euonmyoji.newhonor.manager.PlaceHolderManager;
import com.github.euonmyoji.newhonor.manager.ScoreBoardManager;
import com.github.euonmyoji.newhonor.task.DisplayHonorTaskManager;
import com.github.euonmyoji.newhonor.manager.*;
import com.github.euonmyoji.newhonor.task.EffectsOffer;
import com.github.euonmyoji.newhonor.task.HaloEffectsOffer;
import com.github.euonmyoji.newhonor.task.TaskManager;
import com.google.common.base.Charsets;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.github.euonmyoji.newhonor.NewHonor;
import com.github.euonmyoji.newhonor.configuration.HonorConfig;
import com.github.euonmyoji.newhonor.configuration.LanguageManager;
import com.github.euonmyoji.newhonor.manager.LanguageManager;
import com.github.euonmyoji.newhonor.configuration.NewHonorConfig;
import com.github.euonmyoji.newhonor.data.HonorValueData;
import com.github.euonmyoji.newhonor.manager.PlayerConfigManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import com.github.euonmyoji.newhonor.configuration.EffectsConfig;
import com.github.euonmyoji.newhonor.configuration.HonorConfig;
import com.github.euonmyoji.newhonor.data.HonorValueData;
import com.github.euonmyoji.newhonor.task.TaskManager;
import com.github.euonmyoji.newhonor.manager.TaskManager;
import com.github.euonmyoji.newhonor.util.Log;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.command.CommandResult;
Expand All @@ -23,12 +23,12 @@
import java.util.Objects;
import java.util.stream.Collectors;

import static com.github.euonmyoji.newhonor.configuration.LanguageManager.getText;
import static com.github.euonmyoji.newhonor.configuration.LanguageManager.langBuilder;
import static com.github.euonmyoji.newhonor.manager.LanguageManager.getText;
import static com.github.euonmyoji.newhonor.manager.LanguageManager.langBuilder;
import static org.spongepowered.api.text.Text.of;
import static org.spongepowered.api.text.serializer.TextSerializers.FORMATTING_CODE;

class AdminCommand {
final class AdminCommand {
private static NewHonor plugin = NewHonor.plugin;

static CommandSpec refresh = CommandSpec.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.Optional;
import java.util.stream.Collectors;

class EffectsCommand {
final class EffectsCommand {
static CommandSpec delete = CommandSpec.builder()
.arguments(GenericArguments.onlyOne(GenericArguments.string(Text.of("effectsID"))))
.executor((src, args) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
import java.util.UUID;
import java.util.stream.Collectors;

import static com.github.euonmyoji.newhonor.configuration.LanguageManager.*;
import static com.github.euonmyoji.newhonor.manager.LanguageManager.*;
import static org.spongepowered.api.text.Text.of;
import static org.spongepowered.api.text.action.TextActions.runCommand;
import static org.spongepowered.api.text.action.TextActions.showText;

/**
* @author yinyangshi
*/
public class HonorCommand {
public final class HonorCommand {
private static String ADMIN_PERMISSION = "newhonor.admin";
private static final HashMap<UUID, Integer> USE_CD = new HashMap<>();
private static String ID_KEY = "id";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import static org.spongepowered.api.text.Text.of;

class SettingsArgs {
final class SettingsArgs {

static CommandSpec usehonor = CommandSpec.builder()
.arguments(GenericArguments.bool(of("boolean")))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.github.euonmyoji.newhonor.NewHonor;
import com.github.euonmyoji.newhonor.configuration.LocalPlayerConfig;
import com.github.euonmyoji.newhonor.manager.MysqlManager;
import com.github.euonmyoji.newhonor.configuration.NewHonorConfig;
import com.github.euonmyoji.newhonor.configuration.MysqlManager;
import org.spongepowered.api.command.CommandResult;
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.scheduler.Task;
Expand All @@ -20,7 +20,7 @@
/**
* @author yinyangshi
*/
class SqlCommand {
final class SqlCommand {

static CommandSpec updateToSql = CommandSpec.builder()
.executor((src, args) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static boolean isVirtual(String id) {
return cfg.getChildrenMap();
}

static Optional<Text> getGetMessage(String id, String playername) {
public static Optional<Text> getGetMessage(String id, String playername) {
//noinspection ConstantConditions 之前有检查
return Optional.ofNullable(cfg.getNode(id, "getMessage").getString(null))
.map(s -> "&r" + s.replace("{playername}", playername))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.github.euonmyoji.newhonor.NewHonor;
import com.github.euonmyoji.newhonor.api.configuration.PlayerConfig;
import com.github.euonmyoji.newhonor.manager.MysqlManager;
import com.google.common.reflect.TypeToken;
import ninja.leaping.configurate.ConfigurationOptions;
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
Expand All @@ -17,8 +18,8 @@
/**
* @author yinyangshi
*/
public class NewHonorConfig {
static CommentedConfigurationNode cfg;
public final class NewHonorConfig {
public static CommentedConfigurationNode cfg;
private static final TypeToken<List<String>> LIST_STRING_TYPE = new TypeToken<List<String>>() {
};
private static ConfigurationLoader<CommentedConfigurationNode> loader;
Expand Down Expand Up @@ -58,7 +59,7 @@ public static void init() {
reload();
}

static Locale getUsingLang() {
public static Locale getUsingLang() {
String[] args = cfg.getNode(LANGUAGE).getString(Locale.getDefault().toString()).split("_", 2);
return new Locale(args[0], args[1]);
}
Expand Down Expand Up @@ -95,7 +96,7 @@ public static void save() {
}
}

static Optional<List<String>> getDefaultOwnHonors() {
public static Optional<List<String>> getDefaultOwnHonors() {
try {
return cfg.getNode(DEFAULT_HONORS_SETTINGS, "enable").getBoolean(true) ?
Optional.ofNullable(cfg.getNode(DEFAULT_HONORS_SETTINGS, DEFAULT_HONORS).getValue(LIST_STRING_TYPE)) : Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* @author yinyangshi
*/
public class NewHonorMessageListener {
public final class NewHonorMessageListener {

@Listener(order = Order.LAST)
public void onChat(MessageChannelEvent.Chat event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* @author yinyangshi
*/
public class UltimateChatEventListener {
public final class UltimateChatEventListener {

@Listener
public void sendCME(SendChannelMessageEvent event) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.euonmyoji.newhonor.task;
package com.github.euonmyoji.newhonor.manager;

import com.github.euonmyoji.newhonor.NewHonor;
import com.github.euonmyoji.newhonor.task.DisplayHonorTask;
import org.spongepowered.api.scheduler.Task;
import org.spongepowered.api.scoreboard.Team;
import org.spongepowered.api.text.Text;
Expand All @@ -11,8 +12,8 @@
/**
* @author yinyangshi
*/
public class DisplayHonorTaskManager {
static final HashMap<String, DisplayHonorTask> TASKS = new HashMap<>();
public final class DisplayHonorTaskManager {
public static final HashMap<String, DisplayHonorTask> TASKS = new HashMap<>();

public static void submit(String id, List<Text> values, Team team, int[] delay) {
synchronized (TASKS) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.euonmyoji.newhonor.configuration;
package com.github.euonmyoji.newhonor.manager;

import com.github.euonmyoji.newhonor.NewHonor;
import com.github.euonmyoji.newhonor.configuration.NewHonorConfig;
import com.github.euonmyoji.newhonor.util.Util;
import com.google.common.base.Charsets;
import org.spongepowered.api.Sponge;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.github.euonmyoji.newhonor.configuration;
package com.github.euonmyoji.newhonor.manager;

import com.github.euonmyoji.newhonor.NewHonor;
import com.github.euonmyoji.newhonor.api.configuration.BasePlayerConfig;
import com.github.euonmyoji.newhonor.api.event.PlayerGetHonorEvent;
import com.github.euonmyoji.newhonor.api.event.PlayerLoseHonorEvent;
import com.github.euonmyoji.newhonor.configuration.HonorConfig;
import com.github.euonmyoji.newhonor.configuration.NewHonorConfig;
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.entity.living.player.Player;
Expand All @@ -16,14 +18,14 @@
import java.sql.*;
import java.util.*;

import static com.github.euonmyoji.newhonor.configuration.NewHonorConfig.cfg;
import static com.github.euonmyoji.newhonor.api.configuration.PlayerConfig.*;
import static com.github.euonmyoji.newhonor.configuration.NewHonorConfig.cfg;

/**
* @author yinyangshi
*/
public class MysqlManager {
static boolean enable = false;
public final class MysqlManager {
public static boolean enable = false;
private static final String TABLE_NAME = "NewHonorPlayerData";
private static String address;
private static short port;
Expand All @@ -45,7 +47,7 @@ public static void init() {
node.getNode("update-encoding").setValue(update_encoding);
}

static void reloadSQLInfo() {
public static void reloadSQLInfo() {
CommentedConfigurationNode node = cfg.getNode("SQL-settings");
enable = node.getNode("enable").getBoolean(false);
address = node.getNode("address").getString("address");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* @author yinyangshi
*/
public class NucleusManager {
public final class NucleusManager {
private static boolean done;

public static void doIt() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* @author yinyangshi
*/
public class PlaceHolderManager {
public final class PlaceHolderManager {
private static PlaceHolderManager instance;
private static final String VALUE_T = "value";
private static final String STR_T = "strvalue";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.github.euonmyoji.newhonor.api.configuration.PlayerConfig;
import com.github.euonmyoji.newhonor.configuration.LocalPlayerConfig;
import com.github.euonmyoji.newhonor.configuration.MysqlManager;

import java.util.HashMap;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.github.euonmyoji.newhonor.NewHonor;
import com.github.euonmyoji.newhonor.api.configuration.PlayerConfig;
import com.github.euonmyoji.newhonor.data.HonorValueData;
import com.github.euonmyoji.newhonor.task.DisplayHonorTaskManager;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.scoreboard.Scoreboard;
Expand All @@ -18,7 +17,7 @@
/**
* @author yinyangshi
*/
public class ScoreBoardManager {
public final class ScoreBoardManager {
public static boolean enable = false;
private static Scoreboard scoreboard = Scoreboard.builder().build();
private static final Object LOCK = new Object();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package com.github.euonmyoji.newhonor.task;
package com.github.euonmyoji.newhonor.manager;

import com.github.euonmyoji.newhonor.configuration.EffectsConfig;
import com.github.euonmyoji.newhonor.task.EffectsOffer;
import com.github.euonmyoji.newhonor.task.HaloEffectsOffer;

import java.io.IOException;
import java.util.List;

/**
* @author yinyangshi
*/
public class TaskManager {
public final class TaskManager {
/**
* 更新插件任务缓存
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import java.util.List;

import static com.github.euonmyoji.newhonor.task.DisplayHonorTaskManager.TASKS;
import static com.github.euonmyoji.newhonor.manager.DisplayHonorTaskManager.TASKS;

/**
* @author yinyangshi
Expand All @@ -22,7 +22,7 @@ public class DisplayHonorTask implements Runnable {
private int index;
private volatile boolean running = true;

DisplayHonorTask(String id, List<Text> values, Team team, int[] delay) {
public DisplayHonorTask(String id, List<Text> values, Team team, int[] delay) {
if (values.size() > delay.length) {
throw new IllegalArgumentException();
}
Expand Down Expand Up @@ -54,7 +54,7 @@ public void run() {
}
}

void cancel() {
public void cancel() {
synchronized (TASKS) {
running = false;
TASKS.remove(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class EffectsOffer {
}).name("NewHonor - Effects Offer Task").intervalTicks(Util.INTERVAL_TICKS).submit(NewHonor.plugin);
}

static void update(Iterable<String> effects) {
public static void update(Iterable<String> effects) {
synchronized (TASK_DATA) {
TASK_DATA.clear();
effects.forEach(id -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class HaloEffectsOffer {
}).name("NewHonor - Halo Effects Offer Task").intervalTicks(Util.INTERVAL_TICKS).submit(NewHonor.plugin);
}

static void update(Iterable<String> effects) {
public static void update(Iterable<String> effects) {
synchronized (TASK_DATA) {
TASK_DATA.clear();
effects.forEach(id -> {
Expand Down

0 comments on commit b561da1

Please sign in to comment.