Made booster command add booster and rewrote multiplier to be a double
This commit is contained in:
parent
3bcec7c482
commit
0408b34c1d
|
|
@ -12,9 +12,9 @@ public interface Booster {
|
|||
|
||||
void setType(BoosterType boosterType);
|
||||
|
||||
int getMultiplier();
|
||||
double getMultiplier();
|
||||
|
||||
void setMultiplier(int multiplier);
|
||||
void setMultiplier(double multiplier);
|
||||
|
||||
Long getStartingTime();
|
||||
|
||||
|
|
|
|||
|
|
@ -178,6 +178,11 @@ public final class Config {
|
|||
pluginMessageChannel = getString("settings.message-channel", pluginMessageChannel);
|
||||
}
|
||||
|
||||
public static long BOOST_ANNOUNCE_CHANNEL = -1;
|
||||
private static void announceChannels() {
|
||||
BOOST_ANNOUNCE_CHANNEL = getLong("settings.boost-announce-channel", BOOST_ANNOUNCE_CHANNEL);
|
||||
}
|
||||
|
||||
public static List<String> donorRanks = new ArrayList<>();
|
||||
private static void loadDonorStuff() {
|
||||
donorRanks = getList("donor.ranks", donorRanks);
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ public class Booster implements com.alttd.boosterapi.Booster {
|
|||
private Long startingTime;
|
||||
private long duration;
|
||||
private BoosterType boosterType;
|
||||
private Integer multiplier;
|
||||
private Double multiplier;
|
||||
private Boolean active;
|
||||
private Boolean finished;
|
||||
|
||||
public Booster(UUID uuid, BoosterType boosterType, String reason, long duration, int multiplier) {
|
||||
public Booster(UUID uuid, BoosterType boosterType, String reason, long duration, double multiplier) {
|
||||
this.uuid = uuid;
|
||||
this.boosterType = boosterType;
|
||||
this.activator = reason;
|
||||
|
|
@ -26,7 +26,7 @@ public class Booster implements com.alttd.boosterapi.Booster {
|
|||
saveBooster();
|
||||
}
|
||||
|
||||
public Booster(BoosterType type, String playerName, long duration, int multiplier) {
|
||||
public Booster(BoosterType type, String playerName, long duration, double multiplier) {
|
||||
this(UUID.randomUUID(), type, playerName, duration, multiplier);
|
||||
}
|
||||
|
||||
|
|
@ -51,12 +51,12 @@ public class Booster implements com.alttd.boosterapi.Booster {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getMultiplier() {
|
||||
public double getMultiplier() {
|
||||
return multiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMultiplier(int multiplier) {
|
||||
public void setMultiplier(double multiplier) {
|
||||
this.multiplier = multiplier;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,16 +15,16 @@ public class MCmmoListener implements Listener {
|
|||
BoosterManager bm = BoostersPlugin.getInstance().getBoosterManager();
|
||||
if (bm.isBoosted(BoosterType.MCMMO)) {
|
||||
Booster b = bm.getBooster(BoosterType.MCMMO);
|
||||
int multiplier = b.getMultiplier();
|
||||
event.setRawXpGained(event.getRawXpGained() * multiplier);
|
||||
double multiplier = b.getMultiplier();
|
||||
event.setRawXpGained(Math.round(event.getRawXpGained() * multiplier));
|
||||
return;
|
||||
}
|
||||
String skillName = event.getSkill().name();
|
||||
BoosterType type = BoosterType.getByName(skillName);
|
||||
if (bm.isBoosted(type)) {
|
||||
Booster b = bm.getBooster(type);
|
||||
int multiplier = b.getMultiplier();
|
||||
event.setRawXpGained(event.getRawXpGained() * multiplier);
|
||||
double multiplier = b.getMultiplier();
|
||||
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);
|
||||
int multiplier = b.getMultiplier();
|
||||
double multiplier = b.getMultiplier();
|
||||
event.setExp(event.getExp() * multiplier);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +1,80 @@
|
|||
package com.alttd.vboosters.commands;
|
||||
|
||||
import com.alttd.boosterapi.BoosterType;
|
||||
import com.alttd.boosterapi.config.Config;
|
||||
import com.alttd.boosterapi.util.Utils;
|
||||
import com.alttd.proxydiscordlink.bot.api.DiscordSendMessage;
|
||||
import com.alttd.vboosters.VelocityBoosters;
|
||||
import com.alttd.vboosters.data.VelocityBooster;
|
||||
import com.mojang.brigadier.arguments.DoubleArgumentType;
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
|
||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||
import com.velocitypowered.api.command.BrigadierCommand;
|
||||
import com.velocitypowered.api.command.CommandMeta;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.util.GameProfile;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BoosterCommand {
|
||||
|
||||
CompletableFuture<Suggestions> buildRemainingString(SuggestionsBuilder builder, Collection<String> possibleValues) {
|
||||
if (possibleValues.isEmpty())
|
||||
return Suggestions.empty();
|
||||
|
||||
String remaining = builder.getRemaining().toLowerCase();
|
||||
for (String str : possibleValues) {
|
||||
if (str.toLowerCase().startsWith(remaining)) {
|
||||
builder.suggest(StringArgumentType.escapeIfRequired(str));
|
||||
}
|
||||
}
|
||||
|
||||
return builder.buildFuture();
|
||||
}
|
||||
|
||||
public BoosterCommand(ProxyServer proxyServer) {
|
||||
LiteralCommandNode<CommandSource> command = LiteralArgumentBuilder
|
||||
.<CommandSource>literal("booster")
|
||||
.requires(ctx -> ctx.hasPermission("command.proxy.booster"))
|
||||
.executes(context -> {
|
||||
String channelid = "776590138296893483";
|
||||
String msg = "CONSOLEUSER activated booster of type BoosterType.MMMCALL for 48 hours.";
|
||||
DiscordSendMessage.sendEmbed(Long.parseLong(channelid),"Booster Activated" , msg);
|
||||
VelocityBoosters.getPlugin().getLogger().info(msg);
|
||||
return 1;
|
||||
})
|
||||
.then(RequiredArgumentBuilder.<CommandSource, String>argument("username", StringArgumentType.string())
|
||||
.suggests((context, builder) -> buildRemainingString(builder, proxyServer.getAllPlayers().stream()
|
||||
.map(Player::getGameProfile)
|
||||
.map(GameProfile::getName)
|
||||
.collect(Collectors.toList())))
|
||||
.then(RequiredArgumentBuilder.<CommandSource, String>argument("booster", StringArgumentType.string())
|
||||
.suggests((context, builder) -> buildRemainingString(builder, Arrays.stream(BoosterType.values())
|
||||
.map(BoosterType::getBoosterName)
|
||||
.collect(Collectors.toList())))
|
||||
.then(RequiredArgumentBuilder.<CommandSource, Integer>argument("time", IntegerArgumentType.integer(0, 525960))
|
||||
.then(RequiredArgumentBuilder.<CommandSource, Double>argument("multiplier", DoubleArgumentType.doubleArg(0, 10))
|
||||
.executes(context -> {
|
||||
String username = context.getArgument("username", String.class);
|
||||
BoosterType boosterType = BoosterType.getByName(context.getArgument("booster", String.class));
|
||||
long duration = context.getArgument("time", Integer.class) * 60;
|
||||
double multiplier = context.getArgument("multiplier", Double.class);
|
||||
VelocityBoosters.getPlugin().getBoosterManager().addBooster(new VelocityBooster(boosterType, username, duration, multiplier));
|
||||
String msg = "[" + username + "] activated booster of type [" + Utils.capitalize(boosterType.getBoosterName()) + "] until <t:"
|
||||
+ (new Date().getTime() + duration) + ":f>."; //TODO check if there was a booster active already and change message based on that
|
||||
DiscordSendMessage.sendEmbed(Config.BOOST_ANNOUNCE_CHANNEL, "Booster Activated", msg);
|
||||
VelocityBoosters.getPlugin().getLogger().info(msg);
|
||||
return 1;
|
||||
})
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
.executes(context -> 1)
|
||||
.build();
|
||||
|
||||
BrigadierCommand brigadierCommand = new BrigadierCommand(command);
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@ public class VelocityBooster implements Booster {
|
|||
private Long startingTime;
|
||||
private long duration;
|
||||
private BoosterType boosterType;
|
||||
private Integer multiplier;
|
||||
private Double multiplier;
|
||||
private Boolean active;
|
||||
private Boolean finished;
|
||||
|
||||
public VelocityBooster(UUID uuid, BoosterType boosterType, String reason, long duration, int multiplier) {
|
||||
public VelocityBooster(UUID uuid, BoosterType boosterType, String reason, long duration, double multiplier) {
|
||||
this.uuid = uuid;
|
||||
this.boosterType = boosterType;
|
||||
this.activator = reason;
|
||||
|
|
@ -27,7 +27,7 @@ public class VelocityBooster implements Booster {
|
|||
saveBooster();
|
||||
}
|
||||
|
||||
public VelocityBooster(BoosterType type, String playerName, long duration, int multiplier) {
|
||||
public VelocityBooster(BoosterType type, String playerName, long duration, double multiplier) {
|
||||
this(UUID.randomUUID(), type, playerName, duration, multiplier);
|
||||
}
|
||||
|
||||
|
|
@ -52,12 +52,12 @@ public class VelocityBooster implements Booster {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getMultiplier() {
|
||||
public double getMultiplier() {
|
||||
return multiplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMultiplier(int multiplier) {
|
||||
public void setMultiplier(double multiplier) {
|
||||
this.multiplier = multiplier;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user