Resolves #6
This commit is contained in:
parent
03d384ec87
commit
1c69b1cc55
2
pom.xml
2
pom.xml
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>com.alttd</groupId>
|
||||
<artifactId>AltitudeTag</artifactId>
|
||||
<version>1.0.3</version>
|
||||
<version>1.0.5</version>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.alttd.altitudetag;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
|
@ -15,6 +16,7 @@ import org.bukkit.Bukkit;
|
|||
import org.bukkit.boss.BossBar;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public class AltitudeTag extends JavaPlugin
|
||||
{
|
||||
|
|
@ -25,6 +27,8 @@ public class AltitudeTag extends JavaPlugin
|
|||
|
||||
private BossBar bossBar;
|
||||
|
||||
private BukkitTask tagTimeLimitTask;
|
||||
|
||||
/**
|
||||
* Enable the plugin
|
||||
*/
|
||||
|
|
@ -122,8 +126,15 @@ public class AltitudeTag extends JavaPlugin
|
|||
if (tagger != null)
|
||||
{
|
||||
NotificationHandler.sendGlobalNotifications(previousPlayer != null ? previousPlayer.getName() : null,
|
||||
Bukkit.getPlayer(tagger).getName(),
|
||||
cause);
|
||||
Bukkit.getPlayer(tagger).getName(), cause);
|
||||
|
||||
if (Config.TIME_LIMIT_ENABLED.getValue())
|
||||
{
|
||||
if (instance.tagTimeLimitTask != null && !instance.tagTimeLimitTask.isCancelled()) {
|
||||
instance.tagTimeLimitTask.cancel();
|
||||
}
|
||||
instance.tagTimeLimitTask = Bukkit.getScheduler().runTaskLater(instance, () -> randomTagger(TagCause.TIMEOUT, Bukkit.getPlayer(tagger)), Config.TIME_LIMIT_DURATION.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
instance.prevTagger = instance.tagger;
|
||||
|
|
@ -155,6 +166,18 @@ public class AltitudeTag extends JavaPlugin
|
|||
Leaderboard.getTags(uuid, consumer);
|
||||
}
|
||||
|
||||
public static Player randomTagger(TagCause cause, Player filtered)
|
||||
{
|
||||
Optional<? extends Player> optional = Bukkit.getOnlinePlayers().stream().filter(p -> p != filtered).findAny();
|
||||
if (!optional.isPresent())
|
||||
{
|
||||
throw new IllegalStateException("Filtering failed. All players: " + filtered.getUniqueId());
|
||||
}
|
||||
Player player = optional.get();
|
||||
AltitudeTag.setTagger(player.getUniqueId(), cause);
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the singleton instance of this plugin.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -93,6 +93,11 @@ public final class Config
|
|||
public static final MutableValue<Integer> TAG_DELAY_DURATION = new MutableValue<>(60);
|
||||
public static final MutableValue<String> TAG_DELAY_MESSAGE = new MutableValue<>("&e* Can't tag anyone within 5 seconds of becoming 'it'!");
|
||||
|
||||
public static final MutableValue<Boolean> TIME_LIMIT_ENABLED = new MutableValue<>(true);
|
||||
public static final MutableValue<Integer> TIME_LIMIT_DURATION = new MutableValue<>(1200);
|
||||
public static final MutableValue<String> TIME_LIMIT_MESSAGE = new MutableValue<>(
|
||||
"&e* Transferring 'it' since you've had it for awhile.");
|
||||
|
||||
/**
|
||||
* Update the values from the config file.
|
||||
*/
|
||||
|
|
@ -153,6 +158,10 @@ public final class Config
|
|||
updateValue(config, save, "tag-delay.duration", TAG_DELAY_DURATION);
|
||||
updateValue(config, save, "tag-delay.message", TAG_DELAY_MESSAGE);
|
||||
|
||||
updateValue(config, save, "time-limit.enabled", TIME_LIMIT_ENABLED);
|
||||
updateValue(config, save, "time-limit.duration", TIME_LIMIT_DURATION);
|
||||
updateValue(config, save, "time-limit.message", TIME_LIMIT_MESSAGE);
|
||||
|
||||
if (save.getValue())
|
||||
{
|
||||
AltitudeTag.getInstance().saveConfig();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
package com.alttd.altitudetag.listeners;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.alttd.altitudetag.AltitudeTag;
|
||||
import com.alttd.altitudetag.NotificationHandler;
|
||||
import com.alttd.altitudetag.TagCause;
|
||||
|
|
@ -41,13 +39,8 @@ public class ConnectionListener implements Listener
|
|||
return;
|
||||
}
|
||||
|
||||
Optional<? extends Player> optional = Bukkit.getOnlinePlayers().stream().filter(p -> p != event.getPlayer()).findAny();
|
||||
if (!optional.isPresent())
|
||||
{
|
||||
throw new IllegalStateException("There is more than one player on but for some reason they are all: " + event.getPlayer().getUniqueId());
|
||||
}
|
||||
Player player = optional.get();
|
||||
AltitudeTag.setTagger(player.getUniqueId(), TagCause.DISCONNECT_TRANSFER);
|
||||
Player player = AltitudeTag.randomTagger(TagCause.DISCONNECT_TRANSFER, event.getPlayer());
|
||||
|
||||
NotificationHandler.sendVictimTitle(player, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,4 +57,8 @@ tag-backs:
|
|||
tag-delay:
|
||||
enabled: true
|
||||
duration: 60
|
||||
message: "&e* Can't tag anyone within 5 seconds of becoming 'it'!"
|
||||
message: "&e* Can't tag anyone within 5 seconds of becoming 'it'!"
|
||||
time-limit:
|
||||
enabled: true
|
||||
duration: 1200
|
||||
message: "&e* Transferring 'it' since you've had it for awhile."
|
||||
Loading…
Reference in New Issue
Block a user