Skip to content

Commit

Permalink
Merge pull request #11 from skylandnewmc/main
Browse files Browse the repository at this point in the history
skylandnewmc change
  • Loading branch information
staFF6773 committed Mar 31, 2024
2 parents dc77d21 + df5a61a commit 6b77012
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/main/java/io/github/sstudiosdev/BetterPvP.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.github.sstudiosdev.command.PvPWorldCommand;
import io.github.sstudiosdev.listener.AntiKillAbuseListener;
import io.github.sstudiosdev.listener.PlayerDeathListener;
import io.github.sstudiosdev.listener.RespawnProtectionListener;
import io.github.sstudiosdev.util.ChatColorUtil;
import io.github.sstudiosdev.util.CommandMapUtil;
import io.github.sstudiosdev.util.constructors.Config;
Expand Down Expand Up @@ -109,6 +110,7 @@ private void registerEvents() {
// Register event listeners
getServer().getPluginManager().registerEvents(new AntiKillAbuseListener(this), this);
getServer().getPluginManager().registerEvents(new PlayerDeathListener(this), this);
getServer().getPluginManager().registerEvents(new RespawnProtectionListener(this), this);

CommandMapUtil.registerCommand(this, new BetterPvPReloadCommand(this));
CommandMapUtil.registerCommand(this, new BetterPvPNoPvPCommand(this));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ public void onPlayerRespawn(PlayerRespawnEvent event) {
return;
}

playersWithRespawnProtection.add(player);
playersWithRespawnProtection.add(player); // Add player to set
int duration = config.getInt("respawn-protection.duration", 5); // Get duration from config, default to 5 seconds
Bukkit.getScheduler().runTaskLater(plugin, () -> {
playersWithRespawnProtection.remove(player);
String respawnMessage = ChatColorUtil.colorize(BetterPvP.prefix + " " + config.getString("respawn_message"));
player.sendMessage(respawnMessage);
}, 100); // 5 seconds (20 ticks per second, 100 ticks = 5 seconds)
}, duration * 20L); // Convert seconds to ticks
}

@EventHandler
Expand All @@ -60,4 +61,4 @@ public void onEntityDamage(EntityDamageEvent event) {
}
}
}
}
}
3 changes: 2 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ cooldown:

respawn-protection:
enabled: true
duration: 10

# End Config.yml
# Thank you pichema ❤
# Thank you pichema ❤

0 comments on commit 6b77012

Please sign in to comment.