Fixed boosters not updating on galaxy and not being stored properly
This commit is contained in:
@@ -5,6 +5,7 @@ import com.alttd.boosterapi.BoosterType;
|
||||
import com.alttd.boosterapi.util.ALogger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ServerBooster implements Booster {
|
||||
@@ -50,6 +51,7 @@ public class ServerBooster implements Booster {
|
||||
|
||||
@Override
|
||||
public void setActive(Boolean active) {
|
||||
this.startingTime = new Date().getTime();
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
@@ -85,7 +87,7 @@ public class ServerBooster implements Booster {
|
||||
|
||||
@Override
|
||||
public Long getEndTime() {
|
||||
return startingTime = duration;
|
||||
return startingTime + duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,7 +15,7 @@ public class MCmmoListener implements Listener {
|
||||
BoosterManager bm = BoostersPlugin.getInstance().getBoosterManager();
|
||||
if (bm.isBoosted(BoosterType.MCMMO)) {
|
||||
Booster b = bm.getBooster(BoosterType.MCMMO);
|
||||
double multiplier = b.getMultiplier();
|
||||
double multiplier = b.getMultiplier() + 1;
|
||||
event.setRawXpGained(Math.round(event.getRawXpGained() * multiplier));
|
||||
return;
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class MCmmoListener implements Listener {
|
||||
BoosterType type = BoosterType.getByName(skillName);
|
||||
if (bm.isBoosted(type)) {
|
||||
Booster b = bm.getBooster(type);
|
||||
double multiplier = b.getMultiplier();
|
||||
double multiplier = b.getMultiplier() + 1;
|
||||
event.setRawXpGained(Math.round(event.getRawXpGained() * multiplier));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class MyPetListener implements Listener {
|
||||
BoosterManager bm = BoostersPlugin.getInstance().getBoosterManager();
|
||||
if(bm.isBoosted(BoosterType.MYPET)) {
|
||||
Booster b = bm.getBooster(BoosterType.MYPET);
|
||||
double multiplier = b.getMultiplier();
|
||||
double multiplier = b.getMultiplier() + 1;
|
||||
event.setExp(event.getExp() * multiplier);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ public class PluginMessage implements PluginMessageListener {
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] bytes) {
|
||||
if(!channel.equals(Config.pluginMessageChannel)) return;
|
||||
if (Config.DEBUG)
|
||||
ALogger.info("Received plugin message");
|
||||
ByteArrayDataInput in = ByteStreams.newDataInput(bytes);
|
||||
String subChannel = in.readUTF();
|
||||
switch (subChannel) {
|
||||
|
||||
@@ -2,13 +2,27 @@ package com.alttd.boosters.managers;
|
||||
|
||||
import com.alttd.boosterapi.Booster;
|
||||
import com.alttd.boosterapi.BoosterType;
|
||||
import com.alttd.boosterapi.config.BoosterStorage;
|
||||
import com.alttd.boosterapi.config.Config;
|
||||
import com.alttd.boosters.BoostersPlugin;
|
||||
import com.alttd.boosters.storage.ServerBoosterStorage;
|
||||
|
||||
import java.util.List;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class BoosterManager {
|
||||
|
||||
public BoosterManager() {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Booster booster: ServerBoosterStorage.getServerBoosterStorage().getBoosters().values()) {
|
||||
if (!booster.isActive())
|
||||
continue;
|
||||
if (booster.getTimeRemaining() > 0) continue;
|
||||
booster.finish();
|
||||
}
|
||||
}
|
||||
}.runTaskTimerAsynchronously(BoostersPlugin.getInstance(), 0, Config.activeTaskCheckFrequency * 20);
|
||||
}
|
||||
|
||||
public boolean isBoosted(BoosterType type) {
|
||||
for (Booster b : ServerBoosterStorage.getServerBoosterStorage().getBoosters().values()) {
|
||||
if (b.getType() == type && b.isActive()) {
|
||||
|
||||
Reference in New Issue
Block a user