mirror of
https://github.com/plexusorg/Module-TFMExtras.git
synced 2024-12-28 02:24:33 +00:00
Merge pull request #4 from notsceptor/master
Fixed stacking orbits & retained strength value
This commit is contained in:
commit
aa0938b869
3 changed files with 19 additions and 6 deletions
|
@ -95,6 +95,7 @@ public class TFMExtras extends PlexModule
|
||||||
|
|
||||||
addDefaultMessage("playerOrbited", "<aqua>{0} - Orbiting {1}", "0 - The command sender, 1 - The person being orbited");
|
addDefaultMessage("playerOrbited", "<aqua>{0} - Orbiting {1}", "0 - The command sender, 1 - The person being orbited");
|
||||||
addDefaultMessage("stoppedOrbiting", "<aqua>No longer orbiting {0}", "0 - The person no longer being orbited");
|
addDefaultMessage("stoppedOrbiting", "<aqua>No longer orbiting {0}", "0 - The person no longer being orbited");
|
||||||
|
addDefaultMessage("alreadyOrbited", "<red>{0} is already being orbited!", "0 - The person that is already orbited");
|
||||||
addDefaultMessage("emptyAdminInfo", "<red>The admin information section of the config.yml file has not been configured.");
|
addDefaultMessage("emptyAdminInfo", "<red>The admin information section of the config.yml file has not been configured.");
|
||||||
addDefaultMessage("cakeLyrics", "<rainbow>But there's no sense crying over every mistake. You just keep on trying till you run out of cake.");
|
addDefaultMessage("cakeLyrics", "<rainbow>But there's no sense crying over every mistake. You just keep on trying till you run out of cake.");
|
||||||
addDefaultMessage("areaEffectCloudClear", "<red>{0} - Removing all area effect clouds", "0 - The command sender");
|
addDefaultMessage("areaEffectCloudClear", "<red>{0} - Removing all area effect clouds", "0 - The command sender");
|
||||||
|
@ -170,4 +171,4 @@ public class TFMExtras extends PlexModule
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,14 +15,15 @@ import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ArrayList;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@CommandParameters(name = "orbit", description = "Accelerates the player at a super fast rate", usage = "/<command> <target> [<<power> | stop>]")
|
@CommandParameters(name = "orbit", description = "Accelerates the player at a super fast rate", usage = "/<command> <target> [<<power> | stop>]")
|
||||||
@CommandPermissions(permission = "plex.tfmextras.orbit")
|
@CommandPermissions(permission = "plex.tfmextras.orbit")
|
||||||
public class OrbitCommand extends PlexCommand
|
public class OrbitCommand extends PlexCommand
|
||||||
{
|
{
|
||||||
private static final List<UUID> isOrbited = new ArrayList<>();
|
private static final Map<UUID, Integer> isOrbited = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||||
|
@ -54,6 +55,11 @@ public class OrbitCommand extends PlexCommand
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isPlayerOrbited(targetPlayer.getUniqueId()))
|
||||||
|
{
|
||||||
|
return messageComponent("alreadyOrbited", targetPlayer.getName());
|
||||||
|
}
|
||||||
|
|
||||||
startOrbiting(targetPlayer, strength);
|
startOrbiting(targetPlayer, strength);
|
||||||
PlexUtils.broadcast(messageComponent("playerOrbited", sender.getName(), targetPlayer.getName()));
|
PlexUtils.broadcast(messageComponent("playerOrbited", sender.getName(), targetPlayer.getName()));
|
||||||
return null;
|
return null;
|
||||||
|
@ -77,7 +83,7 @@ public class OrbitCommand extends PlexCommand
|
||||||
{
|
{
|
||||||
player.setGameMode(org.bukkit.GameMode.SURVIVAL);
|
player.setGameMode(org.bukkit.GameMode.SURVIVAL);
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION, Integer.MAX_VALUE, strength, false, false));
|
player.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION, Integer.MAX_VALUE, strength, false, false));
|
||||||
isOrbited.add(player.getUniqueId());
|
isOrbited.put(player.getUniqueId(), strength);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stopOrbiting(Player player)
|
private void stopOrbiting(Player player)
|
||||||
|
@ -88,6 +94,11 @@ public class OrbitCommand extends PlexCommand
|
||||||
|
|
||||||
public static boolean isPlayerOrbited(UUID playerId)
|
public static boolean isPlayerOrbited(UUID playerId)
|
||||||
{
|
{
|
||||||
return isOrbited.contains(playerId);
|
return isOrbited.containsKey(playerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Integer getOrbitStrength(UUID playerId)
|
||||||
|
{
|
||||||
|
return isOrbited.get(playerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,8 @@ public class OrbitEffectListener extends PlexListener
|
||||||
{
|
{
|
||||||
if (OrbitCommand.isPlayerOrbited(player.getUniqueId()))
|
if (OrbitCommand.isPlayerOrbited(player.getUniqueId()))
|
||||||
{
|
{
|
||||||
player.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION, Integer.MAX_VALUE, 100, false, false));
|
Integer strength = OrbitCommand.getOrbitStrength(player.getUniqueId());
|
||||||
|
player.addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION, Integer.MAX_VALUE, strength, false, false));
|
||||||
}
|
}
|
||||||
}, 2);
|
}, 2);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue