Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Healing Pool Improvement #827

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,11 @@ public class ConfigPath {

public static final String GENERAL_CONFIGURATION_PERFORMANCE_PAPER_FEATURES = GENERAL_CONFIGURATION_PERFORMANCE_PATH + ".paper-features";

private static final String GENERAL_CONFIGURATION_HEAL_POOL = GENERAL_CONFIGURATION_PERFORMANCE_PATH+".heal-pool";
public static final String GENERAL_CONFIGURATION_HEAL_POOL_ENABLE = GENERAL_CONFIGURATION_HEAL_POOL+".enable";
public static final String GENERAL_CONFIGURATION_HEAL_POOL_SEEN_TEAM_ONLY = GENERAL_CONFIGURATION_HEAL_POOL_ENABLE+".seen-by-team-only";
private static final String GENERAL_CONFIGURATION_HEAL_POOL = GENERAL_CONFIGURATION_PERFORMANCE_PATH + ".heal-pool";
public static final String GENERAL_CONFIGURATION_HEAL_POOL_ENABLE = GENERAL_CONFIGURATION_HEAL_POOL + ".enable";
public static final String GENERAL_CONFIGURATION_HEAL_POOL_SEEN_TEAM_ONLY = GENERAL_CONFIGURATION_HEAL_POOL + ".seen-by-team-only";
public static final String GENERAL_CONFIGURATION_HEAL_POOL_PARTICLE_REFRESH_INTERVAL = GENERAL_CONFIGURATION_HEAL_POOL + ".particle-refresh-interval";
public static final String GENERAL_CONFIGURATION_HEAL_POOL_PARTICLE_SPARSITY = GENERAL_CONFIGURATION_HEAL_POOL + ".particle-sparsity";
public static final String SHOP_SETTINGS_PATH = "shop-settings";
public static final String SHOP_SPECIALS_PATH = "shop-specials";
public static final String SHOP_QUICK_DEFAULTS_PATH = "quick-buy-defaults";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,8 @@ public void addTeamEffect(PotionEffectType pef, int amp, int duration) {
public void addBaseEffect(PotionEffectType pef, int amp, int duration) {
getBaseEffects().add(new PotionEffect(pef, duration, amp));
for (Player p : new ArrayList<>(getMembers())) {
if (p.getLocation().distance(getBed()) <= getArena().getIslandRadius()) {
// Give team effects centered around the spawn
if (p.getLocation().distance(getSpawn()) <= getArena().getIslandRadius()) {
for (PotionEffect e : getBaseEffects()) {
p.addPotionEffect(e, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ private static void checkEvents(Player p, IArena a) {
boolean notOnBase = true;
for (ITeam bwt : a.getTeams()) {
/* BaseEnterEvent */
if (p.getLocation().distance(bwt.getBed()) <= a.getIslandRadius()) {
// Using the spawn location of the team as the trap detection center
if (p.getLocation().distance(bwt.getSpawn()) <= a.getIslandRadius()) {
notOnBase = false;
if (isOnABase.containsKey(p)) {
if (isOnABase.get(p) != bwt) {
Expand Down Expand Up @@ -123,10 +124,8 @@ public void onBaseEnter(PlayerBaseEnterEvent e) {
} else {
// Trigger trap
if (!team.getActiveTraps().isEmpty()) {
if (!team.isBedDestroyed()) {
team.getActiveTraps().get(0).trigger(team, e.getPlayer());
team.getActiveTraps().remove(0);
}
team.getActiveTraps().get(0).trigger(team, e.getPlayer());
team.getActiveTraps().remove(0);
}

/* Manage trap */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public HealPoolTask(ITeam bwt){
this.maxZ = (teamspawn.getBlockZ() + radius);
this.minZ = (teamspawn.getBlockZ() - radius);
this.arena = bwt.getArena();
this.runTaskTimerAsynchronously(plugin, 0, 80L);
// N ticks refresh particle effects for cycles
this.runTaskTimerAsynchronously(plugin, 0, config.getInt(ConfigPath.GENERAL_CONFIGURATION_HEAL_POOL_PARTICLE_REFRESH_INTERVAL));
healPoolTasks.add(this);
}

Expand All @@ -59,7 +60,8 @@ public void run(){
for (int z = minZ; z <= maxZ; z++) {
l = new Location(arena.getWorld(), x + .5, y + .5, z +.5);
if (l.getBlock().getType() != Material.AIR) continue;
int chance = r.nextInt(9);
// Randomly determine whether to generate particle effects
int chance = r.nextInt(config.getInt(ConfigPath.GENERAL_CONFIGURATION_HEAL_POOL_PARTICLE_SPARSITY));
if (chance == 0) {
if (config.getBoolean(ConfigPath.GENERAL_CONFIGURATION_HEAL_POOL_SEEN_TEAM_ONLY)) {
for (Player p : bwt.getMembers()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public MainConfig(Plugin plugin, String name) {
//heal pool category
yml.addDefault(ConfigPath.GENERAL_CONFIGURATION_HEAL_POOL_ENABLE, true);
yml.addDefault(ConfigPath.GENERAL_CONFIGURATION_HEAL_POOL_SEEN_TEAM_ONLY, true);
yml.addDefault(ConfigPath.GENERAL_CONFIGURATION_HEAL_POOL_PARTICLE_REFRESH_INTERVAL, 40);
yml.addDefault(ConfigPath.GENERAL_CONFIGURATION_HEAL_POOL_PARTICLE_SPARSITY, 100);

// tnt jump category
yml.addDefault(ConfigPath.GENERAL_TNT_JUMP_BARYCENTER_IN_Y, 0.5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public void onClick(Player player, ClickType clickType, ITeam team) {
for (Player arenaPlayer : team.getArena().getPlayers()) {
if (team.isMember(arenaPlayer)) continue;
if (team.getArena().isReSpawning(arenaPlayer)) continue;
if (arenaPlayer.getLocation().distance(team.getBed()) <= team.getArena().getIslandRadius()) {
if (arenaPlayer.getLocation().distance(team.getSpawn()) <= team.getArena().getIslandRadius()) {
team.getActiveTraps().remove(0).trigger(team, arenaPlayer);
break;
}
Expand Down
Loading