mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-08 09:27:45 +01:00
[Debt] Fixed Plugin Enable Sequence
Removed PlanPlugin.getInstance() Temporarily disabled Plugin Bridge hooking
This commit is contained in:
parent
e60e1abe9a
commit
bd636892d6
@ -34,7 +34,6 @@ import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||
import com.djrapitops.plan.system.settings.theme.PlanColorScheme;
|
||||
import com.djrapitops.plan.utilities.metrics.BStatsBukkit;
|
||||
import com.djrapitops.plugin.BukkitPlugin;
|
||||
import com.djrapitops.plugin.StaticHolder;
|
||||
import com.djrapitops.plugin.benchmarking.Benchmark;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
@ -105,18 +104,8 @@ public class Plan extends BukkitPlugin implements PlanPlugin {
|
||||
private PlanSystem system;
|
||||
private Locale locale;
|
||||
|
||||
/**
|
||||
* Used to get the plugin-instance singleton.
|
||||
*
|
||||
* @return this object.
|
||||
*/
|
||||
public static Plan getInstance() {
|
||||
return (Plan) StaticHolder.getInstance(Plan.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
super.onEnable();
|
||||
PlanComponent component = DaggerPlanComponent.builder().plan(this).build();
|
||||
try {
|
||||
timings.start("Enable");
|
||||
|
@ -18,7 +18,6 @@ import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||
import com.djrapitops.plan.system.settings.theme.PlanColorScheme;
|
||||
import com.djrapitops.plan.utilities.metrics.BStatsBungee;
|
||||
import com.djrapitops.plugin.BungeePlugin;
|
||||
import com.djrapitops.plugin.StaticHolder;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
@ -85,13 +84,8 @@ public class PlanBungee extends BungeePlugin implements PlanPlugin {
|
||||
private PlanSystem system;
|
||||
private Locale locale;
|
||||
|
||||
public static PlanBungee getInstance() {
|
||||
return (PlanBungee) StaticHolder.getInstance(PlanBungee.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
super.onEnable();
|
||||
PlanBungeeComponent component = DaggerPlanBungeeComponent.builder().plan(this).build();
|
||||
try {
|
||||
system = component.system();
|
||||
|
@ -6,7 +6,6 @@ package com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.plan.system.PlanSystem;
|
||||
import com.djrapitops.plugin.IPlugin;
|
||||
import com.djrapitops.plugin.api.Check;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
|
||||
import java.io.File;
|
||||
@ -18,40 +17,6 @@ import java.io.InputStream;
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public interface PlanPlugin extends IPlugin {
|
||||
@Deprecated
|
||||
static PlanPlugin getInstance() {
|
||||
boolean bukkitAvailable = Check.isBukkitAvailable();
|
||||
boolean bungeeAvailable = Check.isBungeeAvailable();
|
||||
boolean spongeAvailable = Check.isSpongeAvailable();
|
||||
if (bukkitAvailable) {
|
||||
try {
|
||||
Plan instance = Plan.getInstance();
|
||||
if (instance != null) {
|
||||
return instance;
|
||||
}
|
||||
} catch (IllegalStateException ignored) {
|
||||
}
|
||||
}
|
||||
if (bungeeAvailable) {
|
||||
try {
|
||||
PlanBungee instance = PlanBungee.getInstance();
|
||||
if (instance != null) {
|
||||
return instance;
|
||||
}
|
||||
} catch (IllegalStateException ignored) {
|
||||
}
|
||||
}
|
||||
if (spongeAvailable) {
|
||||
try {
|
||||
PlanSponge instance = PlanSponge.getInstance();
|
||||
if (instance != null) {
|
||||
return instance;
|
||||
}
|
||||
} catch (IllegalStateException ignored) {
|
||||
}
|
||||
}
|
||||
throw new IllegalAccessError("Plugin instance not available");
|
||||
}
|
||||
|
||||
@Override
|
||||
File getDataFolder();
|
||||
|
@ -15,7 +15,6 @@ import com.djrapitops.plan.system.locale.lang.PluginLang;
|
||||
import com.djrapitops.plan.system.settings.theme.PlanColorScheme;
|
||||
import com.djrapitops.plan.utilities.metrics.BStatsSponge;
|
||||
import com.djrapitops.plugin.SpongePlugin;
|
||||
import com.djrapitops.plugin.StaticHolder;
|
||||
import com.djrapitops.plugin.command.ColorScheme;
|
||||
import com.djrapitops.plugin.command.CommandNode;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
@ -107,13 +106,8 @@ public class PlanSponge extends SpongePlugin implements PlanPlugin {
|
||||
onDisable();
|
||||
}
|
||||
|
||||
public static PlanSponge getInstance() {
|
||||
return (PlanSponge) StaticHolder.getInstance(PlanSponge.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
super.onEnable();
|
||||
PlanSpongeComponent component = DaggerPlanSpongeComponent.builder().plan(this).build();
|
||||
try {
|
||||
system = component.system();
|
||||
|
@ -5,7 +5,6 @@ import com.djrapitops.plan.system.SubSystem;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.console.PluginLogger;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
import com.djrapitops.pluginbridge.plan.Bridge;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
@ -39,7 +38,7 @@ public class HookHandler implements SubSystem {
|
||||
@Override
|
||||
public void enable() {
|
||||
try {
|
||||
Bridge.hook(this);
|
||||
// Bridge.hook(this);
|
||||
} catch (Exception e) {
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
logger.error("Plan Plugin Bridge not included in the plugin jar.");
|
||||
|
@ -28,6 +28,7 @@ import java.util.*;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -38,7 +39,7 @@ public abstract class Importer {
|
||||
|
||||
private final GeolocationCache geolocationCache;
|
||||
private final Database database;
|
||||
protected final UUID serverUUID;
|
||||
protected final Supplier<UUID> serverUUID;
|
||||
|
||||
private final String name;
|
||||
private final Plan plugin;
|
||||
@ -52,7 +53,7 @@ public abstract class Importer {
|
||||
) {
|
||||
this.geolocationCache = geolocationCache;
|
||||
this.database = database;
|
||||
this.serverUUID = serverInfo.getServerUUID();
|
||||
this.serverUUID = serverInfo::getServerUUID;
|
||||
|
||||
this.name = name;
|
||||
this.plugin = plugin;
|
||||
@ -97,8 +98,8 @@ public abstract class Importer {
|
||||
ExecutorService service = Executors.newCachedThreadPool();
|
||||
|
||||
SaveOperations save = database.save();
|
||||
submitTo(service, () -> save.insertTPS(ImmutableMap.of(serverUUID, serverImportData.getTpsData())));
|
||||
submitTo(service, () -> save.insertCommandUsage(ImmutableMap.of(serverUUID, serverImportData.getCommandUsages())));
|
||||
submitTo(service, () -> save.insertTPS(ImmutableMap.of(serverUUID.get(), serverImportData.getTpsData())));
|
||||
submitTo(service, () -> save.insertCommandUsage(ImmutableMap.of(serverUUID.get(), serverImportData.getCommandUsages())));
|
||||
|
||||
service.shutdown();
|
||||
try {
|
||||
@ -120,7 +121,7 @@ public abstract class Importer {
|
||||
userImportData = userImportRefiner.refineData();
|
||||
|
||||
Set<UUID> existingUUIDs = database.fetch().getSavedUUIDs();
|
||||
Set<UUID> existingUserInfoTableUUIDs = database.fetch().getSavedUUIDs(serverUUID);
|
||||
Set<UUID> existingUserInfoTableUUIDs = database.fetch().getSavedUUIDs(serverUUID.get());
|
||||
|
||||
Map<UUID, UserInfo> users = new HashMap<>();
|
||||
List<UserInfo> userInfo = new ArrayList<>();
|
||||
@ -152,10 +153,10 @@ public abstract class Importer {
|
||||
SaveOperations save = database.save();
|
||||
|
||||
save.insertUsers(users);
|
||||
submitTo(service, () -> save.insertSessions(ImmutableMap.of(serverUUID, sessions), true));
|
||||
submitTo(service, () -> save.insertSessions(ImmutableMap.of(serverUUID.get(), sessions), true));
|
||||
submitTo(service, () -> save.kickAmount(timesKicked));
|
||||
submitTo(service, () -> save.insertUserInfo(ImmutableMap.of(serverUUID, userInfo)));
|
||||
submitTo(service, () -> save.insertNicknames(ImmutableMap.of(serverUUID, nickNames)));
|
||||
submitTo(service, () -> save.insertUserInfo(ImmutableMap.of(serverUUID.get(), userInfo)));
|
||||
submitTo(service, () -> save.insertNicknames(ImmutableMap.of(serverUUID.get(), nickNames)));
|
||||
submitTo(service, () -> save.insertAllGeoInfo(geoInfo));
|
||||
|
||||
service.shutdown();
|
||||
@ -185,7 +186,7 @@ public abstract class Importer {
|
||||
int mobKills = userImportData.getMobKills();
|
||||
int deaths = userImportData.getDeaths();
|
||||
|
||||
Session session = new Session(0, userImportData.getUuid(), serverUUID, 0L, 0L, mobKills, deaths, 0);
|
||||
Session session = new Session(0, userImportData.getUuid(), serverUUID.get(), 0L, 0L, mobKills, deaths, 0);
|
||||
|
||||
session.setPlayerKills(userImportData.getKills());
|
||||
session.setWorldTimes(new WorldTimes(userImportData.getWorldTimes()));
|
||||
|
@ -50,7 +50,7 @@ public class OfflinePlayerImporter extends Importer {
|
||||
Set<OfflinePlayer> banned = Bukkit.getBannedPlayers();
|
||||
|
||||
Arrays.stream(Bukkit.getOfflinePlayers()).parallel().forEach(player -> {
|
||||
UserImportData.UserImportDataBuilder builder = UserImportData.builder(serverUUID);
|
||||
UserImportData.UserImportDataBuilder builder = UserImportData.builder(serverUUID.get());
|
||||
builder.name(player.getName())
|
||||
.uuid(player.getUniqueId())
|
||||
.registered(player.getFirstPlayed());
|
||||
|
@ -18,12 +18,12 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class Locale extends HashMap<Lang, Message> {
|
||||
|
||||
public static Locale forLangCodeString(String code) throws IOException {
|
||||
return forLangCode(LangCode.fromString(code));
|
||||
public static Locale forLangCodeString(PlanPlugin plugin, String code) throws IOException {
|
||||
return forLangCode(LangCode.fromString(code), plugin);
|
||||
}
|
||||
|
||||
public static Locale forLangCode(LangCode code) throws IOException {
|
||||
return new LocaleFileReader(PlanPlugin.getInstance(), code.getFileName()).load();
|
||||
public static Locale forLangCode(LangCode code, PlanPlugin plugin) throws IOException {
|
||||
return new LocaleFileReader(plugin, code.getFileName()).load();
|
||||
}
|
||||
|
||||
public static Locale fromFile(File file) throws IOException {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.djrapitops.plan.system.locale;
|
||||
|
||||
import com.djrapitops.plan.PlanPlugin;
|
||||
import com.djrapitops.plan.system.SubSystem;
|
||||
import com.djrapitops.plan.system.file.PlanFiles;
|
||||
import com.djrapitops.plan.system.locale.lang.*;
|
||||
@ -28,6 +29,7 @@ import java.util.stream.Collectors;
|
||||
@Singleton
|
||||
public class LocaleSystem implements SubSystem {
|
||||
|
||||
private final PlanPlugin plugin;
|
||||
private final PlanFiles files;
|
||||
private final PlanConfig config;
|
||||
private final PluginLogger logger;
|
||||
@ -37,11 +39,13 @@ public class LocaleSystem implements SubSystem {
|
||||
|
||||
@Inject
|
||||
public LocaleSystem(
|
||||
PlanPlugin plugin,
|
||||
PlanFiles files,
|
||||
PlanConfig config,
|
||||
PluginLogger logger,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
this.plugin = plugin;
|
||||
this.files = files;
|
||||
this.config = config;
|
||||
this.logger = logger;
|
||||
@ -111,7 +115,7 @@ public class LocaleSystem implements SubSystem {
|
||||
try {
|
||||
String setting = config.getString(Settings.LOCALE);
|
||||
if (!setting.equalsIgnoreCase("default")) {
|
||||
return Optional.of(Locale.forLangCodeString(setting));
|
||||
return Optional.of(Locale.forLangCodeString(plugin, setting));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.warn("Failed to read locale from jar: " + config.getString(Settings.LOCALE) + ", " + e.toString());
|
||||
|
Loading…
Reference in New Issue
Block a user