2020-08-26 18:48:57 +02:00
|
|
|
/*
|
|
|
|
This file is a part of the SteamWar software.
|
|
|
|
|
|
|
|
Copyright (C) 2020 SteamWar.de-Serverteam
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-06-11 07:05:05 +02:00
|
|
|
package de.steamwar.bausystem.commands;
|
|
|
|
|
2021-01-25 14:32:52 +01:00
|
|
|
import de.steamwar.bausystem.world.Region;
|
2019-10-24 18:47:23 +02:00
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.block.BlockBurnEvent;
|
|
|
|
import org.bukkit.event.block.BlockSpreadEvent;
|
2019-06-11 07:05:05 +02:00
|
|
|
|
2021-01-25 14:32:52 +01:00
|
|
|
public class CommandFire extends RegionToggleCommand {
|
2019-06-11 07:05:05 +02:00
|
|
|
|
2021-01-25 14:32:52 +01:00
|
|
|
public CommandFire() {
|
|
|
|
super();
|
2019-10-24 18:47:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
String getNoPermMessage() {
|
|
|
|
return "§cDu darfst hier nicht Feuerschaden (de-)aktivieren";
|
|
|
|
}
|
2019-06-11 07:05:05 +02:00
|
|
|
@Override
|
2019-10-24 18:47:23 +02:00
|
|
|
String getEnableMessage(){
|
|
|
|
return "§cFeuerschaden deaktiviert";
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
String getDisableMessage(){
|
|
|
|
return "§aFeuerschaden aktiviert";
|
|
|
|
}
|
2021-01-25 14:32:52 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
boolean toggle(Region region) {
|
|
|
|
region.setFire(!region.isFire());
|
|
|
|
return region.isFire();
|
|
|
|
}
|
2019-06-11 07:05:05 +02:00
|
|
|
|
2021-01-25 17:10:45 +01:00
|
|
|
@Override
|
|
|
|
boolean toggleGlobal() {
|
|
|
|
Region.NoRegion.fire = !Region.NoRegion.fire;
|
|
|
|
return Region.NoRegion.fire;
|
|
|
|
}
|
|
|
|
|
2019-10-24 18:47:23 +02:00
|
|
|
@EventHandler
|
|
|
|
public void onFireDamage(BlockBurnEvent e) {
|
2021-01-25 14:32:52 +01:00
|
|
|
Region.getRegion(e.getBlock().getLocation(), region -> {
|
|
|
|
if (region.isFire()) e.setCancelled(true);
|
2021-01-25 17:10:45 +01:00
|
|
|
}, () -> {
|
|
|
|
if (Region.NoRegion.fire) e.setCancelled(true);
|
2021-01-25 14:32:52 +01:00
|
|
|
});
|
2019-06-11 07:05:05 +02:00
|
|
|
}
|
2019-10-24 18:47:23 +02:00
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void onFireSpread(BlockSpreadEvent e){
|
2021-01-25 14:32:52 +01:00
|
|
|
Region.getRegion(e.getBlock().getLocation(), region -> {
|
|
|
|
if (region.isFire()) e.setCancelled(true);
|
2021-01-25 17:10:45 +01:00
|
|
|
}, () -> {
|
|
|
|
if (Region.NoRegion.fire) e.setCancelled(true);
|
2021-01-25 14:32:52 +01:00
|
|
|
});
|
2019-10-24 18:47:23 +02:00
|
|
|
}
|
|
|
|
|
2019-06-11 07:05:05 +02:00
|
|
|
}
|