mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-12 03:59:06 +00:00
Allow RPG WorldEvents to work
This commit is contained in:
parent
1d451cbb50
commit
3e737d705c
2 changed files with 146 additions and 96 deletions
|
@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
||||||
import com.projectkorra.ProjectKorra.chiblocking.RapidPunch;
|
import com.projectkorra.ProjectKorra.chiblocking.RapidPunch;
|
||||||
|
import com.projectkorra.rpg.RPGMethods;
|
||||||
|
|
||||||
public class BendingManager implements Runnable {
|
public class BendingManager implements Runnable {
|
||||||
|
|
||||||
|
@ -18,10 +19,13 @@ public class BendingManager implements Runnable {
|
||||||
|
|
||||||
private final HashMap<World, Boolean> times = new HashMap<World, Boolean>(); // true if day time
|
private final HashMap<World, Boolean> times = new HashMap<World, Boolean>(); // true if day time
|
||||||
|
|
||||||
|
static final String defaultsozinscometmessage = "Sozin's Comet is passing overhead! Firebending is now at its most powerful.";
|
||||||
|
static final String defaultsolareclipsemessage = "A solar eclipse is out! Firebenders are temporarily powerless.";
|
||||||
static final String defaultsunrisemessage = "You feel the strength of the rising sun empowering your firebending.";
|
static final String defaultsunrisemessage = "You feel the strength of the rising sun empowering your firebending.";
|
||||||
static final String defaultsunsetmessage = "You feel the empowering of your firebending subside as the sun sets.";
|
static final String defaultsunsetmessage = "You feel the empowering of your firebending subside as the sun sets.";
|
||||||
static final String defaultmoonrisemessage = "You feel the strength of the rising moon empowering your waterbending.";
|
static final String defaultmoonrisemessage = "You feel the strength of the rising moon empowering your waterbending.";
|
||||||
static final String defaultfullmoonrisemessage = "A full moon is rising, empowering your waterbending like never before.";
|
static final String defaultfullmoonrisemessage = "A full moon is rising, empowering your waterbending like never before.";
|
||||||
|
static final String defaultlunareclipsemessage = "A lunar eclipse is out! Waterbenders are temporarily powerless.";
|
||||||
static final String defaultmoonsetmessage = "You feel the empowering of your waterbending subside as the moon sets.";
|
static final String defaultmoonsetmessage = "You feel the empowering of your waterbending subside as the moon sets.";
|
||||||
|
|
||||||
public BendingManager(ProjectKorra plugin) {
|
public BendingManager(ProjectKorra plugin) {
|
||||||
|
@ -73,12 +77,22 @@ public class BendingManager implements Runnable {
|
||||||
times.put(world, false); // Sets time to night.
|
times.put(world, false); // Sets time to night.
|
||||||
for (Player player: world.getPlayers()) {
|
for (Player player: world.getPlayers()) {
|
||||||
if (Methods.isBender(player.getName(), Element.Water)) {
|
if (Methods.isBender(player.getName(), Element.Water)) {
|
||||||
|
if (Methods.hasRPG()) {
|
||||||
|
if (RPGMethods.isLunarEclipse(world)) {
|
||||||
|
player.sendMessage(Methods.getWaterColor() + defaultlunareclipsemessage);
|
||||||
|
} else if (Methods.isFullMoon(world)) {
|
||||||
|
player.sendMessage(Methods.getWaterColor() + defaultfullmoonrisemessage);
|
||||||
|
} else {
|
||||||
|
player.sendMessage(Methods.getWaterColor() + defaultmoonrisemessage);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (Methods.isFullMoon(world)) {
|
if (Methods.isFullMoon(world)) {
|
||||||
player.sendMessage(Methods.getWaterColor() + defaultfullmoonrisemessage);
|
player.sendMessage(Methods.getWaterColor() + defaultfullmoonrisemessage);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(Methods.getWaterColor() + defaultmoonrisemessage);
|
player.sendMessage(Methods.getWaterColor() + defaultmoonrisemessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (Methods.isBender(player.getName(), Element.Fire)) {
|
if (Methods.isBender(player.getName(), Element.Fire)) {
|
||||||
player.sendMessage(Methods.getFireColor() + defaultsunsetmessage);
|
player.sendMessage(Methods.getFireColor() + defaultsunsetmessage);
|
||||||
}
|
}
|
||||||
|
@ -93,6 +107,15 @@ public class BendingManager implements Runnable {
|
||||||
player.sendMessage(Methods.getWaterColor() + defaultmoonsetmessage);
|
player.sendMessage(Methods.getWaterColor() + defaultmoonsetmessage);
|
||||||
}
|
}
|
||||||
if (Methods.isBender(player.getName(), Element.Fire) && player.hasPermission("bending.message.daymessage")) {
|
if (Methods.isBender(player.getName(), Element.Fire) && player.hasPermission("bending.message.daymessage")) {
|
||||||
|
if (Methods.hasRPG()) {
|
||||||
|
if (RPGMethods.isSozinsComet(world)) {
|
||||||
|
player.sendMessage(Methods.getFireColor() + defaultsozinscometmessage);
|
||||||
|
} else if (RPGMethods.isSolarEclipse(world) && !RPGMethods.isLunarEclipse(world)) {
|
||||||
|
player.sendMessage(Methods.getFireColor() + defaultsolareclipsemessage);
|
||||||
|
} else {
|
||||||
|
player.sendMessage(Methods.getFireColor() + defaultsunrisemessage);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
player.sendMessage(Methods.getFireColor() + defaultsunrisemessage);
|
player.sendMessage(Methods.getFireColor() + defaultsunrisemessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,4 +123,5 @@ public class BendingManager implements Runnable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,6 +118,8 @@ import com.projectkorra.ProjectKorra.waterbending.WaterReturn;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.WaterSpout;
|
import com.projectkorra.ProjectKorra.waterbending.WaterSpout;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.WaterWall;
|
import com.projectkorra.ProjectKorra.waterbending.WaterWall;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.Wave;
|
import com.projectkorra.ProjectKorra.waterbending.Wave;
|
||||||
|
import com.projectkorra.rpg.RPGMethods;
|
||||||
|
import com.projectkorra.rpg.WorldEvents;
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||||
|
@ -742,7 +744,17 @@ public class Methods {
|
||||||
*/
|
*/
|
||||||
public static double getFirebendingDayAugment(double value, World world) {
|
public static double getFirebendingDayAugment(double value, World world) {
|
||||||
if (isDay(world)) {
|
if (isDay(world)) {
|
||||||
return plugin.getConfig().getDouble("Properties.Fire.DayFactor") * value;
|
if (Methods.hasRPG()) {
|
||||||
|
if (RPGMethods.isSozinsComet(world)) {
|
||||||
|
return RPGMethods.getFactor(WorldEvents.SozinsComet) * value;
|
||||||
|
} else if (RPGMethods.isSolarEclipse(world) && !RPGMethods.isLunarEclipse(world)) {
|
||||||
|
return RPGMethods.getFactor(WorldEvents.SolarEclipse) * value;
|
||||||
|
} else {
|
||||||
|
return value * plugin.getConfig().getDouble("Properties.Fire.DayFactor");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return plugin.getConfig().getDouble("Properties.Fire.DayFactor");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -877,10 +889,24 @@ public class Methods {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double getWaterbendingNightAugment(World world) {
|
public static double getWaterbendingNightAugment(World world) {
|
||||||
|
if (hasRPG()) {
|
||||||
|
if (isNight(world)) {
|
||||||
|
if (RPGMethods.isLunarEclipse(world)) {
|
||||||
|
return RPGMethods.getFactor(WorldEvents.LunarEclipse);
|
||||||
|
}
|
||||||
|
if (isFullMoon(world)) {
|
||||||
|
return plugin.getConfig().getDouble("Properties.Water.FullMoonFactor");
|
||||||
|
}
|
||||||
|
return plugin.getConfig().getDouble("Properties.Water.NightFactor");
|
||||||
|
} else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (isNight(world) && isFullMoon(world)) return plugin.getConfig().getDouble("Properties.Water.FullMoonFactor");
|
if (isNight(world) && isFullMoon(world)) return plugin.getConfig().getDouble("Properties.Water.FullMoonFactor");
|
||||||
if (isNight(world)) return plugin.getConfig().getDouble("Properties.Water.NightFactor");
|
if (isNight(world)) return plugin.getConfig().getDouble("Properties.Water.NightFactor");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the WaterColor from the config.
|
* Gets the WaterColor from the config.
|
||||||
|
@ -1203,13 +1229,13 @@ public class Methods {
|
||||||
if (!wg.hasPermission(player, "worldguard.override.lighter")) {
|
if (!wg.hasPermission(player, "worldguard.override.lighter")) {
|
||||||
if (wg.getGlobalStateManager().get(world).blockLighter)
|
if (wg.getGlobalStateManager().get(world).blockLighter)
|
||||||
return true;
|
return true;
|
||||||
// if (player.hasPermission("worldguard.region.bypass." + world.getName())
|
// if (player.hasPermission("worldguard.region.bypass." + world.getName())
|
||||||
// && wg.getRegionContainer()
|
// && wg.getRegionContainer()
|
||||||
// .get(world)
|
// .get(world)
|
||||||
// .getApplicableRegions(location)
|
// .getApplicableRegions(location)
|
||||||
// .queryState(wg.wrapPlayer(player), DefaultFlag.LIGHTER)
|
// .queryState(wg.wrapPlayer(player), DefaultFlag.LIGHTER)
|
||||||
// .equals(State.DENY))
|
// .equals(State.DENY))
|
||||||
// return true;
|
// return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (explode.contains(ability)) {
|
if (explode.contains(ability)) {
|
||||||
|
@ -1218,17 +1244,17 @@ public class Methods {
|
||||||
if (!wg.getRegionManager(world).getApplicableRegions(location).allows(DefaultFlag.TNT)){
|
if (!wg.getRegionManager(world).getApplicableRegions(location).allows(DefaultFlag.TNT)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// if (wg.getRegionContainer().get(world).getApplicableRegions(location) == null) return false;
|
// if (wg.getRegionContainer().get(world).getApplicableRegions(location) == null) return false;
|
||||||
// if (wg.getRegionContainer().get(world).getApplicableRegions(location).queryState(null, DefaultFlag.TNT).equals(State.DENY))
|
// if (wg.getRegionContainer().get(world).getApplicableRegions(location).queryState(null, DefaultFlag.TNT).equals(State.DENY))
|
||||||
// return true;
|
// return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wg.canBuild(player, location.getBlock())) {
|
if (!wg.canBuild(player, location.getBlock())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// if (wg.getRegionContainer().get(world).getApplicableRegions(location).queryState(null, DefaultFlag.BUILD).equals(State.DENY))
|
// if (wg.getRegionContainer().get(world).getApplicableRegions(location).queryState(null, DefaultFlag.BUILD).equals(State.DENY))
|
||||||
// return true;
|
// return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (psp != null && respectPreciousStones) {
|
if (psp != null && respectPreciousStones) {
|
||||||
|
@ -1627,9 +1653,9 @@ public class Methods {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reloadPlugin() {
|
public static void reloadPlugin() {
|
||||||
// for (Player player: Bukkit.getOnlinePlayers()) {
|
// for (Player player: Bukkit.getOnlinePlayers()) {
|
||||||
// Methods.saveBendingPlayer(player.getName());
|
// Methods.saveBendingPlayer(player.getName());
|
||||||
// }
|
// }
|
||||||
DBConnection.sql.close();
|
DBConnection.sql.close();
|
||||||
plugin.reloadConfig();
|
plugin.reloadConfig();
|
||||||
Methods.stopBending();
|
Methods.stopBending();
|
||||||
|
|
Loading…
Reference in a new issue