mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Removed temporary migration method
This commit is contained in:
parent
a37fe6d62a
commit
cc21fb8fe3
@ -195,29 +195,20 @@ public class Research implements Keyed {
|
||||
|
||||
PlayerProfile.get(p, profile -> {
|
||||
if (!profile.hasUnlocked(this)) {
|
||||
Runnable runnable = () -> {
|
||||
profile.setResearched(this, true);
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.unlocked", true, msg -> msg.replace(PLACEHOLDER_RESEARCH, getName(p)));
|
||||
|
||||
if (SlimefunPlugin.getRegistry().isResearchFireworkEnabled() && SlimefunGuideSettings.hasFireworksEnabled(p)) {
|
||||
FireworkUtils.launchRandom(p, 1);
|
||||
}
|
||||
};
|
||||
|
||||
Slimefun.runSync(() -> {
|
||||
ResearchUnlockEvent event = new ResearchUnlockEvent(p, this);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
if (instant) {
|
||||
runnable.run();
|
||||
finishResearch(p, profile);
|
||||
}
|
||||
else if (SlimefunPlugin.getRegistry().getCurrentlyResearchingPlayers().add(p.getUniqueId())) {
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.research.start", true, msg -> msg.replace(PLACEHOLDER_RESEARCH, getName(p)));
|
||||
playResearchAnimation(p);
|
||||
|
||||
Slimefun.runSync(() -> {
|
||||
runnable.run();
|
||||
finishResearch(p, profile);
|
||||
SlimefunPlugin.getRegistry().getCurrentlyResearchingPlayers().remove(p.getUniqueId());
|
||||
}, (RESEARCH_PROGRESS.length + 1) * 20L);
|
||||
}
|
||||
@ -227,6 +218,15 @@ public class Research implements Keyed {
|
||||
});
|
||||
}
|
||||
|
||||
private void finishResearch(Player p, PlayerProfile profile) {
|
||||
profile.setResearched(this, true);
|
||||
SlimefunPlugin.getLocal().sendMessage(p, "messages.unlocked", true, msg -> msg.replace(PLACEHOLDER_RESEARCH, getName(p)));
|
||||
|
||||
if (SlimefunPlugin.getRegistry().isResearchFireworkEnabled() && SlimefunGuideSettings.hasFireworksEnabled(p)) {
|
||||
FireworkUtils.launchRandom(p, 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void playResearchAnimation(Player p) {
|
||||
for (int i = 1; i < RESEARCH_PROGRESS.length + 1; i++) {
|
||||
int j = i;
|
||||
@ -245,7 +245,6 @@ public class Research implements Keyed {
|
||||
SlimefunPlugin.getResearchCfg().setDefaultValue("enable-researching", true);
|
||||
|
||||
String path = key.getNamespace() + '.' + key.getKey();
|
||||
migrate(id, path);
|
||||
|
||||
if (SlimefunPlugin.getResearchCfg().contains(path + ".enabled") && !SlimefunPlugin.getResearchCfg().getBoolean(path + ".enabled")) {
|
||||
for (SlimefunItem item : new ArrayList<>(items)) {
|
||||
@ -267,19 +266,6 @@ public class Research implements Keyed {
|
||||
SlimefunPlugin.getRegistry().getResearches().add(this);
|
||||
}
|
||||
|
||||
// Temporary migration method from ids to Namespaced Keys.
|
||||
private void migrate(int id, String path) {
|
||||
if (SlimefunPlugin.getResearchCfg().contains(id + ".enabled")) {
|
||||
SlimefunPlugin.getResearchCfg().setValue(path + ".enabled", SlimefunPlugin.getResearchCfg().getBoolean(id + ".enabled"));
|
||||
}
|
||||
|
||||
if (SlimefunPlugin.getResearchCfg().contains(id + ".cost")) {
|
||||
SlimefunPlugin.getResearchCfg().setValue(path + ".cost", SlimefunPlugin.getResearchCfg().getInt(id + ".cost"));
|
||||
}
|
||||
|
||||
SlimefunPlugin.getResearchCfg().setValue(String.valueOf(id), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to get a {@link Research} with the given ID.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user