1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 11:45:51 +00:00

Merge pull request #448 from dpkirchner/master

Don't consume XP until we are about to unlock the requested research.
This commit is contained in:
TheBusyBiscuit 2017-10-07 09:15:57 +02:00 committed by GitHub
commit 5dd53540ee

View File

@ -672,11 +672,15 @@ public class SlimefunGuide {
@Override @Override
public void run(final Player p) { public void run(final Player p) {
if (!Research.isResearching(p)) {
if (research.canUnlock(p)) { if (research.canUnlock(p)) {
if (research.hasUnlocked(p))
openCategory(p, category, true, selected_page, experimental);
else {
if (!(p.getGameMode() == GameMode.CREATIVE && Research.creative_research)) {
p.setLevel(p.getLevel() - research.getCost()); p.setLevel(p.getLevel() - research.getCost());
}
if (research.hasUnlocked(p)) openCategory(p, category, true, selected_page, experimental);
else if (!Research.isResearching(p)) {
if (p.getGameMode() == GameMode.CREATIVE) { if (p.getGameMode() == GameMode.CREATIVE) {
research.unlock(p, true); research.unlock(p, true);
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() { Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() {
@ -686,8 +690,7 @@ public class SlimefunGuide {
openCategory(p, category, survival, selected_page, experimental); openCategory(p, category, survival, selected_page, experimental);
} }
}, 1L); }, 1L);
} } else {
else {
research.unlock(p, false); research.unlock(p, false);
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() { Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() {
@ -698,8 +701,8 @@ public class SlimefunGuide {
}, 103L); }, 103L);
} }
} }
} else Messages.local.sendTranslation(p, "messages.not-enough-xp", true);
} }
else Messages.local.sendTranslation(p, "messages.not-enough-xp", true);
} }
}); });
} }
@ -859,18 +862,19 @@ public class SlimefunGuide {
@Override @Override
public boolean onClick(final Player p, int slot, ItemStack item, ClickAction action) { public boolean onClick(final Player p, int slot, ItemStack item, ClickAction action) {
if (!Research.isResearching(p)) {
if (research.canUnlock(p)) { if (research.canUnlock(p)) {
if (research.hasUnlocked(p))
openCategory(p, category, true, selected_page, experimental);
else {
if (!(p.getGameMode() == GameMode.CREATIVE && Research.creative_research)) { if (!(p.getGameMode() == GameMode.CREATIVE && Research.creative_research)) {
p.setLevel(p.getLevel() - research.getCost()); p.setLevel(p.getLevel() - research.getCost());
} }
if (research.hasUnlocked(p)) openCategory(p, category, true, selected_page, experimental);
else if (!Research.isResearching(p)) {
if (p.getGameMode() == GameMode.CREATIVE) { if (p.getGameMode() == GameMode.CREATIVE) {
research.unlock(p, Research.creative_research); research.unlock(p, Research.creative_research);
openCategory(p, category, survival, selected_page, experimental); openCategory(p, category, survival, selected_page, experimental);
} } else {
else {
research.unlock(p, false); research.unlock(p, false);
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() { Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunStartup.instance, new Runnable() {
@ -881,8 +885,8 @@ public class SlimefunGuide {
}, 103L); }, 103L);
} }
} }
} else Messages.local.sendTranslation(p, "messages.not-enough-xp", true);
} }
else Messages.local.sendTranslation(p, "messages.not-enough-xp", true);
return false; return false;
} }
}); });