parent
af62da603b
commit
dbbb976239
2
pom.xml
2
pom.xml
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>com.alttd</groupId>
|
||||
<artifactId>AltitudeTag</artifactId>
|
||||
<version>1.0.2</version>
|
||||
<version>1.0.3</version>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ public class AltitudeTag extends JavaPlugin
|
|||
private static AltitudeTag instance;
|
||||
|
||||
private UUID tagger;
|
||||
private UUID prevTagger;
|
||||
|
||||
private BossBar bossBar;
|
||||
|
||||
|
|
@ -124,10 +125,21 @@ public class AltitudeTag extends JavaPlugin
|
|||
Bukkit.getPlayer(tagger).getName(),
|
||||
cause);
|
||||
}
|
||||
|
||||
|
||||
instance.prevTagger = instance.tagger;
|
||||
instance.tagger = tagger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the previous tagger.
|
||||
*
|
||||
* @return the previous tagger.
|
||||
*/
|
||||
public static UUID getPreviousTagger()
|
||||
{
|
||||
return instance.prevTagger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a tag for the given player.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ public class Leaderboard
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Objects.requireNonNull(hologram);
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(AltitudeTag.getInstance(), () ->
|
||||
|
|
|
|||
|
|
@ -86,6 +86,12 @@ public final class Config
|
|||
public static final MutableValue<Integer> NOTIFICATION_GLOBAL_BOSS_BAR_PERCENT = new MutableValue<>(0);
|
||||
public static final MutableValue<String> NOTIFICATION_GLOBAL_BOSS_BAR_MESSAGE = new MutableValue<>("&e{player} is 'it'! Don't let them tag you!");
|
||||
|
||||
public static final MutableValue<Boolean> TAG_BACKS_TRACK_LEADERBOARD = new MutableValue<>(false);
|
||||
public static final MutableValue<String> TAG_BACKS_MESSAGE = new MutableValue<>("&e* Have fun, but tag-backs aren't regarded toward the leaderboard.");
|
||||
|
||||
public static final MutableValue<Boolean> TAG_DELAY_ENABLED = new MutableValue<>(true);
|
||||
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'!");
|
||||
|
||||
/**
|
||||
* Update the values from the config file.
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.alttd.altitudetag.listeners;
|
|||
import com.alttd.altitudetag.AltitudeTag;
|
||||
import com.alttd.altitudetag.NotificationHandler;
|
||||
import com.alttd.altitudetag.TagCause;
|
||||
import com.alttd.altitudetag.configuration.Config;
|
||||
import com.alttd.altitudetag.configuration.Lang;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
|
@ -10,6 +12,8 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|||
|
||||
public class InteractListener implements Listener
|
||||
{
|
||||
private static long lastTagTime = -1;
|
||||
|
||||
@EventHandler
|
||||
public void onHit(EntityDamageByEntityEvent event)
|
||||
{
|
||||
|
|
@ -26,17 +30,32 @@ public class InteractListener implements Listener
|
|||
|
||||
final Player tagged = (Player) event.getEntity();
|
||||
|
||||
// add the new tag
|
||||
AltitudeTag.addTag(tagger.getUniqueId(), () ->
|
||||
{
|
||||
// if they left, we can stop
|
||||
if (!tagger.isOnline())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NotificationHandler.sendTaggerNotifications(tagger, tagged.getName());
|
||||
});
|
||||
// check for time since last tag
|
||||
if (lastTagTime != -1 && Config.TAG_DELAY_ENABLED.getValue() && (System.currentTimeMillis() - lastTagTime) / 50 < Config.TAG_DELAY_DURATION.getValue())
|
||||
{
|
||||
tagger.sendMessage(Lang.renderString(Config.TAG_DELAY_MESSAGE.getValue()));
|
||||
return;
|
||||
}
|
||||
|
||||
// add the new tag
|
||||
if (!Config.TAG_BACKS_TRACK_LEADERBOARD.getValue() && AltitudeTag.getPreviousTagger().equals(tagged.getUniqueId()))
|
||||
{
|
||||
tagger.sendMessage(Lang.renderString(Config.TAG_BACKS_MESSAGE.getValue()));
|
||||
}
|
||||
else
|
||||
{
|
||||
AltitudeTag.addTag(tagger.getUniqueId(), () ->
|
||||
{
|
||||
// if they left, we can stop
|
||||
if (!tagger.isOnline())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
NotificationHandler.sendTaggerNotifications(tagger, tagged.getName());
|
||||
});
|
||||
}
|
||||
|
||||
AltitudeTag.setTagger(tagged.getUniqueId(), TagCause.NORMAL);
|
||||
|
||||
|
|
|
|||
|
|
@ -50,4 +50,11 @@ notification:
|
|||
color: YELLOW
|
||||
# 0-100
|
||||
percent: 0
|
||||
message: "&e{player} is 'it'! Don't let them tag you!"
|
||||
message: "&e{player} is 'it'! Don't let them tag you!"
|
||||
tag-backs:
|
||||
track-leaderboard: false
|
||||
message: "&e* Have fun, but tag-backs aren't regarded toward the leaderboard."
|
||||
tag-delay:
|
||||
enabled: true
|
||||
duration: 60
|
||||
message: "&e* Can't tag anyone within 5 seconds of becoming 'it'!"
|
||||
Loading…
Reference in New Issue
Block a user