Skip to content

Commit

Permalink
Merge pull request #34 from TownyAdvanced/onPlotTogglePVP_todo
Browse files Browse the repository at this point in the history
Finish TODO regarding using new setCancellationMsg()
  • Loading branch information
LlmDl authored Jan 15, 2021
2 parents 2400d3b + abcc93c commit 8bca9c1
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

import com.gmail.goosius.siegewar.Messaging;
import com.gmail.goosius.siegewar.SiegeController;
import com.gmail.goosius.siegewar.SiegeWar;
import com.gmail.goosius.siegewar.settings.SiegeWarSettings;
Expand All @@ -25,16 +24,16 @@ public SiegeWarPlotEventListener(SiegeWar instance) {
* SW will stop plot pvp being toggled in besieged or peaceful towns.
*/
@EventHandler
public void onPlotTogglePVP(PlotTogglePvpEvent event) { //TODO: Change Messaging.sendErrorMsg() to event.setCancelledMsg() later on.
public void onPlotTogglePVP(PlotTogglePvpEvent event) {
if (SiegeWarSettings.getWarSiegeEnabled()) {
if (SiegeWarSettings.getWarSiegePvpAlwaysOnInBesiegedTowns() && SiegeController.hasActiveSiege(event.getTown())) {
Messaging.sendErrorMsg(event.getPlayer(), Translation.of("msg_err_siege_besieged_town_cannot_toggle_pvp"));
event.setCancellationMsg(Translation.of("msg_err_siege_besieged_town_cannot_toggle_pvp"));
event.setCancelled(true);
}
if (SiegeWarSettings.getWarCommonPeacefulTownsEnabled()
&& !SiegeWarSettings.getWarCommonPeacefulTownsAllowedToTogglePVP()
&& event.getTown().isNeutral()) {
Messaging.sendErrorMsg(event.getPlayer(), Translation.of("msg_err_peaceful_town_pvp_forced_off"));
event.setCancellationMsg(Translation.of("msg_err_peaceful_town_pvp_forced_off"));
event.setCancelled(true);
}
}
Expand Down

0 comments on commit 8bca9c1

Please sign in to comment.