mirror of
https://github.com/taoneill/war.git
synced 2024-11-27 20:59:39 +01:00
Added -p or print option to zonecfg and warcfg. Ex: /zonecfg test -p autoassign:true, /warcfg print autoassign:false, /zonecfg -p. Trying to nail down pvp issue and I was dying for this.
This commit is contained in:
parent
ec35b6088a
commit
5dcaac9351
@ -400,6 +400,54 @@ public class War extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String printConfig(Warzone zone) {
|
||||||
|
return "Warzone " + zone.getName() + " config - "
|
||||||
|
+ "lifepool:" + zone.getLifePool() + " "
|
||||||
|
+ "teamsize:" + zone.getTeamCap() + " "
|
||||||
|
+ "maxscore:" + zone.getScoreCap() + " "
|
||||||
|
+ "ff:" + onOffStr(zone.getFriendlyFire())
|
||||||
|
+ "autoassign:" + onOffStr(zone.getAutoAssignOnly())
|
||||||
|
+ "blockheads:" + onOffStr(zone.isBlockHeads())
|
||||||
|
+ "spawnstyle:" + zone.getSpawnStyle() + " "
|
||||||
|
+ "monumentheal:" + zone.getMonumentHeal() + " "
|
||||||
|
+ "unbreakable:" + onOffStr(zone.isUnbreakableZoneBlocks())
|
||||||
|
+ "disabled:" + onOffStr(zone.isDisabled())
|
||||||
|
+ "nocreatures:" + onOffStr(zone.isNoCreatures())
|
||||||
|
+ "resetonempty:" + onOffStr(zone.isResetOnEmpty())
|
||||||
|
+ "resetonload:" + onOffStr(zone.isResetOnLoad())
|
||||||
|
+ "resetonunload:" + onOffStr(zone.isResetOnUnload());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String printConfig() {
|
||||||
|
return "War config - "
|
||||||
|
+ "pvpinzonesonly:" + onOffStr(War.war.isPvpInZonesOnly())
|
||||||
|
+ "disablepvpmessage:" + onOffStr(War.war.isDisablePvpMessage())
|
||||||
|
+ "buildinzonesonly:" + onOffStr(War.war.isBuildInZonesOnly())
|
||||||
|
+ "- Warzone defaults - "
|
||||||
|
+ "lifepool:" + War.war.getDefaultLifepool() + " "
|
||||||
|
+ "teamsize:" + War.war.getDefaultTeamCap() + " "
|
||||||
|
+ "maxscore:" + War.war.getDefaultScoreCap() + " "
|
||||||
|
+ "ff:" + onOffStr(War.war.isDefaultFriendlyFire())
|
||||||
|
+ "autoassign:" + onOffStr(War.war.isDefaultAutoAssignOnly())
|
||||||
|
+ "blockheads:" + onOffStr(War.war.isDefaultBlockHeads())
|
||||||
|
+ "spawnstyle:" + War.war.getDefaultSpawnStyle() + " "
|
||||||
|
+ "monumentheal:" + War.war.getDefaultMonumentHeal() + " "
|
||||||
|
+ "unbreakable:" + onOffStr(War.war.isDefaultUnbreakableZoneBlocks())
|
||||||
|
+ "nocreatures:" + onOffStr(War.war.isDefaultNoCreatures())
|
||||||
|
+ "resetonempty:" + onOffStr(War.war.isDefaultResetOnEmpty())
|
||||||
|
+ "resetonload:" + onOffStr(War.war.isDefaultResetOnLoad())
|
||||||
|
+ "resetonunload:" + onOffStr(War.war.isDefaultResetOnUnload());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String onOffStr(boolean makeThisAString) {
|
||||||
|
if(makeThisAString) {
|
||||||
|
return "on ";
|
||||||
|
} else {
|
||||||
|
return "off ";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void setZoneRallyPoint(String warzoneName, Player player) {
|
private void setZoneRallyPoint(String warzoneName, Player player) {
|
||||||
Warzone zone = this.findWarzone(warzoneName);
|
Warzone zone = this.findWarzone(warzoneName);
|
||||||
if (zone == null) {
|
if (zone == null) {
|
||||||
@ -534,11 +582,13 @@ public class War extends JavaPlugin {
|
|||||||
public boolean canPvpOutsideZones(Player player) {
|
public boolean canPvpOutsideZones(Player player) {
|
||||||
if (this.isPvpInZonesOnly()) {
|
if (this.isPvpInZonesOnly()) {
|
||||||
if (War.permissionHandler != null && (War.permissionHandler.has(player, "war.pvp") || War.permissionHandler.has(player, "War.pvp"))) {
|
if (War.permissionHandler != null && (War.permissionHandler.has(player, "war.pvp") || War.permissionHandler.has(player, "War.pvp"))) {
|
||||||
|
War.war.log(player.getName() + " can pvp. Has war.pvp.", Level.INFO);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// w/o Permissions, if pvpInZoneOnly, no one can pvp outside the zone
|
// w/o Permissions, if pvpInZoneOnly, no one can pvp outside the zone
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
War.war.log(player.getName() + " can pvp. Not pvpinzonesonly.", Level.INFO);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,10 +86,12 @@ public class WarEntityListener extends EntityListener {
|
|||||||
}
|
}
|
||||||
} else if (attackerTeam == null && defenderTeam == null && War.war.canPvpOutsideZones(a)) {
|
} else if (attackerTeam == null && defenderTeam == null && War.war.canPvpOutsideZones(a)) {
|
||||||
// let normal PVP through is its not turned off or if you have perms
|
// let normal PVP through is its not turned off or if you have perms
|
||||||
|
War.war.log("Allowed " + a.getDisplayName() + " to hit " + d.getDisplayName() + " ouside zone.", Level.INFO);
|
||||||
} else if (attackerTeam == null && defenderTeam == null && !War.war.canPvpOutsideZones(a)) {
|
} else if (attackerTeam == null && defenderTeam == null && !War.war.canPvpOutsideZones(a)) {
|
||||||
if (!War.war.isDisablePvpMessage()) {
|
if (!War.war.isDisablePvpMessage()) {
|
||||||
War.war.badMsg(a, "You need the 'war.pvp' permission to attack players outside warzones.");
|
War.war.badMsg(a, "You need the 'war.pvp' permission to attack players outside warzones.");
|
||||||
}
|
}
|
||||||
|
War.war.log("Prevented " + a.getDisplayName() + " from hitting " + d.getDisplayName() + " ouside zone.", Level.INFO);
|
||||||
event.setCancelled(true); // global pvp is off
|
event.setCancelled(true); // global pvp is off
|
||||||
} else {
|
} else {
|
||||||
War.war.badMsg(a, "Your attack missed!");
|
War.war.badMsg(a, "Your attack missed!");
|
||||||
@ -104,6 +106,7 @@ public class WarEntityListener extends EntityListener {
|
|||||||
} else if (attackerWarzone != defenderWarzone) {
|
} else if (attackerWarzone != defenderWarzone) {
|
||||||
War.war.badMsg(a, "Your target is playing in another warzone.");
|
War.war.badMsg(a, "Your target is playing in another warzone.");
|
||||||
}
|
}
|
||||||
|
War.war.log("Prevented " + a.getDisplayName() + " from hitting " + d.getDisplayName() + " somehow.", Level.INFO);
|
||||||
event.setCancelled(true); // can't attack someone inside a warzone if you're not in a team
|
event.setCancelled(true); // can't attack someone inside a warzone if you're not in a team
|
||||||
}
|
}
|
||||||
} else if (defender instanceof Player) {
|
} else if (defender instanceof Player) {
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package bukkit.tommytony.war.command;
|
package bukkit.tommytony.war.command;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import bukkit.tommytony.war.War;
|
import bukkit.tommytony.war.War;
|
||||||
import bukkit.tommytony.war.WarCommandHandler;
|
import bukkit.tommytony.war.WarCommandHandler;
|
||||||
|
@ -3,14 +3,13 @@ package bukkit.tommytony.war.command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.tommytony.war.Warzone;
|
|
||||||
import com.tommytony.war.ZoneLobby;
|
|
||||||
import com.tommytony.war.mappers.WarMapper;
|
|
||||||
import com.tommytony.war.mappers.WarzoneMapper;
|
|
||||||
|
|
||||||
import bukkit.tommytony.war.War;
|
import bukkit.tommytony.war.War;
|
||||||
import bukkit.tommytony.war.WarCommandHandler;
|
import bukkit.tommytony.war.WarCommandHandler;
|
||||||
|
|
||||||
|
import com.tommytony.war.Warzone;
|
||||||
|
import com.tommytony.war.ZoneLobby;
|
||||||
|
import com.tommytony.war.mappers.WarzoneMapper;
|
||||||
|
|
||||||
public class SaveZoneCommand extends AbstractZoneMakerCommand {
|
public class SaveZoneCommand extends AbstractZoneMakerCommand {
|
||||||
|
|
||||||
public SaveZoneCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
|
public SaveZoneCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package bukkit.tommytony.war.command;
|
package bukkit.tommytony.war.command;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.tommytony.war.mappers.WarMapper;
|
|
||||||
|
|
||||||
import bukkit.tommytony.war.War;
|
import bukkit.tommytony.war.War;
|
||||||
import bukkit.tommytony.war.WarCommandHandler;
|
import bukkit.tommytony.war.WarCommandHandler;
|
||||||
|
|
||||||
|
import com.tommytony.war.mappers.WarMapper;
|
||||||
|
|
||||||
public class SetWarConfigCommand extends AbstractZoneMakerCommand {
|
public class SetWarConfigCommand extends AbstractZoneMakerCommand {
|
||||||
|
|
||||||
public SetWarConfigCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
|
public SetWarConfigCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
|
||||||
@ -16,13 +15,25 @@ public class SetWarConfigCommand extends AbstractZoneMakerCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handle() {
|
public boolean handle() {
|
||||||
|
boolean wantsToPrint = false;
|
||||||
if (this.args.length == 0) {
|
if (this.args.length == 0) {
|
||||||
return false;
|
return false;
|
||||||
|
} else if (this.args.length == 1 && (this.args[0].equals("-p") || this.args[0].equals("print"))) {
|
||||||
|
String config = War.war.printConfig();
|
||||||
|
this.msg(config);
|
||||||
|
return true;
|
||||||
|
} else if (this.args.length > 1 && (this.args[0].equals("-p") || this.args[0].equals("print"))) {
|
||||||
|
wantsToPrint = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (War.war.updateFromNamedParams(this.getSender(), this.args)) {
|
if (War.war.updateFromNamedParams(this.getSender(), this.args)) {
|
||||||
WarMapper.save();
|
WarMapper.save();
|
||||||
|
if (wantsToPrint) {
|
||||||
|
String config = War.war.printConfig();
|
||||||
|
this.msg("War config saved. " + config);
|
||||||
|
} else {
|
||||||
this.msg("War config saved.");
|
this.msg("War config saved.");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.msg("Failed to read named parameters.");
|
this.msg("Failed to read named parameters.");
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,13 @@ package bukkit.tommytony.war.command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.tommytony.war.Warzone;
|
|
||||||
import com.tommytony.war.ZoneLobby;
|
|
||||||
import com.tommytony.war.mappers.WarMapper;
|
|
||||||
import com.tommytony.war.mappers.WarzoneMapper;
|
|
||||||
|
|
||||||
import bukkit.tommytony.war.War;
|
import bukkit.tommytony.war.War;
|
||||||
import bukkit.tommytony.war.WarCommandHandler;
|
import bukkit.tommytony.war.WarCommandHandler;
|
||||||
|
|
||||||
|
import com.tommytony.war.Warzone;
|
||||||
|
import com.tommytony.war.ZoneLobby;
|
||||||
|
import com.tommytony.war.mappers.WarzoneMapper;
|
||||||
|
|
||||||
public class SetZoneConfigCommand extends AbstractZoneMakerCommand {
|
public class SetZoneConfigCommand extends AbstractZoneMakerCommand {
|
||||||
|
|
||||||
public SetZoneConfigCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
|
public SetZoneConfigCommand(WarCommandHandler handler, CommandSender sender, String[] args) throws NotZoneMakerException {
|
||||||
@ -23,16 +22,19 @@ public class SetZoneConfigCommand extends AbstractZoneMakerCommand {
|
|||||||
Player player = null;
|
Player player = null;
|
||||||
CommandSender commandSender = this.getSender();
|
CommandSender commandSender = this.getSender();
|
||||||
boolean isFirstParamWarzone = false;
|
boolean isFirstParamWarzone = false;
|
||||||
|
boolean wantsToPrint = false;
|
||||||
|
|
||||||
if (this.args.length == 0) {
|
if (this.args.length == 0) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if(!this.args[0].contains(":")) {
|
if (!this.args[0].contains(":")) {
|
||||||
// warzone name maybe in first place
|
// warzone name maybe in first place
|
||||||
Warzone zoneByName = Warzone.getZoneByName(this.args[0]);
|
Warzone zoneByName = Warzone.getZoneByName(this.args[0]);
|
||||||
if (zoneByName != null) {
|
if (zoneByName != null) {
|
||||||
zone = zoneByName;
|
zone = zoneByName;
|
||||||
isFirstParamWarzone = true;
|
isFirstParamWarzone = true;
|
||||||
|
} else if (this.args[0].equals("-p") || this.args[0].equals("print")){
|
||||||
|
wantsToPrint = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,6 +69,23 @@ public class SetZoneConfigCommand extends AbstractZoneMakerCommand {
|
|||||||
this.args = newargs;
|
this.args = newargs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// args have been shifted if needed
|
||||||
|
if(this.args.length > 0 && (this.args[0].equals("-p") || this.args[0].equals("print"))) {
|
||||||
|
// only printing
|
||||||
|
if(this.args.length == 1) {
|
||||||
|
this.msg(War.war.printConfig(zone));
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// first param was to print, shift again
|
||||||
|
String[] newargs = new String[this.args.length - 1];
|
||||||
|
for (int i = 1; i < this.args.length; i++) {
|
||||||
|
newargs[i-1] = args[i];
|
||||||
|
}
|
||||||
|
this.args = newargs;
|
||||||
|
}
|
||||||
|
wantsToPrint = true;
|
||||||
|
}
|
||||||
|
|
||||||
// We have a warzone and indexed-from-0 arguments, let's update
|
// We have a warzone and indexed-from-0 arguments, let's update
|
||||||
if (War.war.updateZoneFromNamedParams(zone, player, this.args)) {
|
if (War.war.updateZoneFromNamedParams(zone, player, this.args)) {
|
||||||
this.msg("Saving config and resetting warzone " + zone.getName() + ".");
|
this.msg("Saving config and resetting warzone " + zone.getName() + ".");
|
||||||
@ -76,7 +95,12 @@ public class SetZoneConfigCommand extends AbstractZoneMakerCommand {
|
|||||||
zone.getLobby().getVolume().resetBlocks();
|
zone.getLobby().getVolume().resetBlocks();
|
||||||
}
|
}
|
||||||
zone.initializeZone(); // bring back team spawns etc
|
zone.initializeZone(); // bring back team spawns etc
|
||||||
|
|
||||||
|
if (wantsToPrint) {
|
||||||
|
this.msg("Warzone config saved. Zone reset. " + War.war.printConfig(zone));
|
||||||
|
} else {
|
||||||
this.msg("Warzone config saved. Zone reset.");
|
this.msg("Warzone config saved. Zone reset.");
|
||||||
|
}
|
||||||
|
|
||||||
if (War.war.getWarHub() != null) { // maybe the zone was disabled/enabled
|
if (War.war.getWarHub() != null) { // maybe the zone was disabled/enabled
|
||||||
War.war.getWarHub().getVolume().resetBlocks();
|
War.war.getWarHub().getVolume().resetBlocks();
|
||||||
|
@ -940,12 +940,6 @@ public class Warzone {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String printConfig() {
|
|
||||||
String cfg = "Warzone " + this.getName() + " config: ";
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBlockHeads(boolean blockHeads) {
|
public void setBlockHeads(boolean blockHeads) {
|
||||||
this.blockHeads = blockHeads;
|
this.blockHeads = blockHeads;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user