Working on auto claim
This commit is contained in:
parent
f6da2d397b
commit
aa989db8f7
@ -24,16 +24,16 @@ public class CmdFactionsAutoClaim extends FCommand
|
||||
public void perform()
|
||||
{
|
||||
Faction forFaction = this.arg(0, ARFaction.get(myFaction), myFaction);
|
||||
if (forFaction == null || forFaction == fme.getAutoClaimFor())
|
||||
if (forFaction == null || forFaction == fme.getAutoClaimFaction())
|
||||
{
|
||||
fme.setAutoClaimFor(null);
|
||||
fme.setAutoClaimFaction(null);
|
||||
msg("<i>Auto-claiming of land disabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! FPerm.TERRITORY.has(fme, forFaction, true)) return;
|
||||
if (forFaction.isNormal() && !FPerm.TERRITORY.has(fme, forFaction, true)) return;
|
||||
|
||||
fme.setAutoClaimFor(forFaction);
|
||||
fme.setAutoClaimFaction(forFaction);
|
||||
|
||||
msg("<i>Now auto-claiming land for <h>%s<i>.", forFaction.describeTo(fme));
|
||||
fme.tryClaim(forFaction, PS.valueOf(me), true, true);
|
||||
|
@ -28,11 +28,11 @@ public class CmdFactionsMap extends FCommand
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.arg(0, ARBoolean.get(), !fme.isMapAutoUpdating()))
|
||||
if (this.arg(0, ARBoolean.get(), !mme.isMapAutoUpdating()))
|
||||
{
|
||||
// Turn on
|
||||
|
||||
fme.setMapAutoUpdating(true);
|
||||
mme.setMapAutoUpdating(true);
|
||||
msg("<i>Map auto update <green>ENABLED.");
|
||||
|
||||
// And show the map once
|
||||
@ -41,7 +41,7 @@ public class CmdFactionsMap extends FCommand
|
||||
else
|
||||
{
|
||||
// Turn off
|
||||
fme.setMapAutoUpdating(false);
|
||||
mme.setMapAutoUpdating(false);
|
||||
msg("<i>Map auto update <red>DISABLED.");
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Rel;
|
||||
import com.massivecraft.factions.entity.MPlayer;
|
||||
import com.massivecraft.factions.entity.UPlayer;
|
||||
import com.massivecraft.factions.entity.Faction;
|
||||
import com.massivecraft.mcore.cmd.MCommand;
|
||||
@ -8,12 +9,14 @@ import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
public abstract class FCommand extends MCommand
|
||||
{
|
||||
public MPlayer mme;
|
||||
public UPlayer fme;
|
||||
public Faction myFaction;
|
||||
|
||||
@Override
|
||||
public void fixSenderVars()
|
||||
{
|
||||
this.mme = MPlayer.get(sender);
|
||||
this.fme = UPlayer.get(this.sender);
|
||||
this.myFaction = this.fme.getFaction();
|
||||
}
|
||||
|
@ -20,7 +20,8 @@ public class MPlayer extends SenderEntity<MPlayer>
|
||||
@Override
|
||||
public MPlayer load(MPlayer that)
|
||||
{
|
||||
// TODO
|
||||
this.mapAutoUpdating = that.mapAutoUpdating;
|
||||
this.usingAdminMode = that.usingAdminMode;
|
||||
|
||||
return this;
|
||||
}
|
||||
@ -28,8 +29,8 @@ public class MPlayer extends SenderEntity<MPlayer>
|
||||
@Override
|
||||
public boolean isDefault()
|
||||
{
|
||||
// TODO
|
||||
//return false;
|
||||
if (this.isMapAutoUpdating()) return false;
|
||||
if (this.isUsingAdminMode()) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -38,5 +39,12 @@ public class MPlayer extends SenderEntity<MPlayer>
|
||||
// FIELDS
|
||||
// -------------------------------------------- //
|
||||
|
||||
private boolean mapAutoUpdating = false;
|
||||
public boolean isMapAutoUpdating() { return this.mapAutoUpdating; }
|
||||
public void setMapAutoUpdating(boolean mapAutoUpdating) { this.mapAutoUpdating = mapAutoUpdating; this.changed(); }
|
||||
|
||||
private boolean usingAdminMode = false;
|
||||
public boolean isUsingAdminMode() { return this.usingAdminMode; }
|
||||
public void setUsingAdminMode(boolean usingAdminMode) { this.usingAdminMode = usingAdminMode; this.changed(); }
|
||||
|
||||
}
|
||||
|
@ -93,27 +93,22 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
|
||||
// Null means default for the universe.
|
||||
private Double power = null;
|
||||
|
||||
// The id for the faction this uplayer is currently autoclaiming for.
|
||||
// NOTE: This field will not be saved to the database ever.
|
||||
// Null means the player isn't auto claiming.
|
||||
private transient Faction autoClaimFaction = null;
|
||||
public Faction getAutoClaimFaction() { return this.autoClaimFaction; }
|
||||
public void setAutoClaimFaction(Faction autoClaimFaction) { this.autoClaimFaction = autoClaimFaction; }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// FIELDS: RAW TRANSIENT
|
||||
// FIELDS: MULTIVERSE PROXY
|
||||
// -------------------------------------------- //
|
||||
|
||||
// FIELD: mapAutoUpdating
|
||||
// TODO: Move this to the MPlayer
|
||||
private transient boolean mapAutoUpdating = false;
|
||||
public void setMapAutoUpdating(boolean mapAutoUpdating) { this.mapAutoUpdating = mapAutoUpdating; }
|
||||
public boolean isMapAutoUpdating() { return mapAutoUpdating; }
|
||||
public boolean isMapAutoUpdating() { return MPlayer.get(this).isMapAutoUpdating(); }
|
||||
public void setMapAutoUpdating(boolean mapAutoUpdating) { MPlayer.get(this).setMapAutoUpdating(mapAutoUpdating); }
|
||||
|
||||
// FIELD: autoClaimEnabled
|
||||
private transient Faction autoClaimFor = null;
|
||||
public Faction getAutoClaimFor() { return autoClaimFor; }
|
||||
public void setAutoClaimFor(Faction faction) { this.autoClaimFor = faction; }
|
||||
|
||||
private transient boolean usingAdminMode = false;
|
||||
public boolean isUsingAdminMode() { return this.usingAdminMode; }
|
||||
public void setUsingAdminMode(boolean val) { this.usingAdminMode = val; }
|
||||
|
||||
// FIELD: loginPvpDisabled
|
||||
//private transient boolean loginPvpDisabled;
|
||||
public boolean isUsingAdminMode() { return MPlayer.get(this).isUsingAdminMode(); }
|
||||
public void setUsingAdminMode(boolean usingAdminMode) { MPlayer.get(this).setUsingAdminMode(usingAdminMode); }
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CORE UTILITIES
|
||||
@ -125,8 +120,7 @@ public class UPlayer extends SenderEntity<UPlayer> implements EconomyParticipato
|
||||
this.setFactionId(null);
|
||||
this.setRole(null);
|
||||
this.setTitle(null);
|
||||
|
||||
this.autoClaimFor = null;
|
||||
this.setAutoClaimFaction(null);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -28,18 +28,18 @@ import com.massivecraft.mcore.util.Txt;
|
||||
public class TodoFactionsPlayerListener implements Listener
|
||||
{
|
||||
// -------------------------------------------- //
|
||||
// TERRITORY INFO MESSAGES
|
||||
// CHUNK CHANGE: DETECT
|
||||
// -------------------------------------------- //
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerMove(PlayerMoveEvent event)
|
||||
public void chunkChangeDetect(PlayerMoveEvent event)
|
||||
{
|
||||
// If the player is moving from one chunk to another ...
|
||||
if (MUtil.isSameChunk(event)) return;
|
||||
|
||||
// ... gather info on the player and the move ...
|
||||
Player player = event.getPlayer();
|
||||
UPlayer uplayerTo = UPlayerColls.get().get(event.getTo()).get(player);
|
||||
UPlayer uplayer = UPlayerColls.get().get(event.getTo()).get(player);
|
||||
|
||||
PS chunkFrom = PS.valueOf(event.getFrom()).getChunk(true);
|
||||
PS chunkTo = PS.valueOf(event.getTo()).getChunk(true);
|
||||
@ -47,14 +47,25 @@ public class TodoFactionsPlayerListener implements Listener
|
||||
Faction factionFrom = BoardColls.get().getFactionAt(chunkFrom);
|
||||
Faction factionTo = BoardColls.get().getFactionAt(chunkTo);
|
||||
|
||||
// ... send host faction info updates ...
|
||||
if (uplayerTo.isMapAutoUpdating())
|
||||
// ... and send info onwards.
|
||||
this.chunkChangeTerritoryInfo(uplayer, player, chunkFrom, chunkTo, factionFrom, factionTo);
|
||||
this.chunkChangeAutoClaim(uplayer, chunkTo);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// CHUNK CHANGE: TERRITORY INFO
|
||||
// -------------------------------------------- //
|
||||
|
||||
public void chunkChangeTerritoryInfo(UPlayer uplayer, Player player, PS chunkFrom, PS chunkTo, Faction factionFrom, Faction factionTo)
|
||||
{
|
||||
uplayerTo.sendMessage(BoardColls.get().getMap(uplayerTo.getFaction(), chunkTo, player.getLocation().getYaw()));
|
||||
// send host faction info updates
|
||||
if (uplayer.isMapAutoUpdating())
|
||||
{
|
||||
uplayer.sendMessage(BoardColls.get().getMap(uplayer, chunkTo, player.getLocation().getYaw()));
|
||||
}
|
||||
else if (factionFrom != factionTo)
|
||||
{
|
||||
String msg = Txt.parse("<i>") + " ~ " + factionTo.getTag(uplayerTo);
|
||||
String msg = Txt.parse("<i>") + " ~ " + factionTo.getTag(uplayer);
|
||||
if (factionTo.hasDescription())
|
||||
{
|
||||
msg += " - " + factionTo.getDescription();
|
||||
@ -66,20 +77,29 @@ public class TodoFactionsPlayerListener implements Listener
|
||||
TerritoryAccess accessTo = BoardColls.get().getTerritoryAccessAt(chunkTo);
|
||||
if (!accessTo.isDefault())
|
||||
{
|
||||
if (accessTo.subjectHasAccess(uplayerTo))
|
||||
if (accessTo.subjectHasAccess(uplayer))
|
||||
{
|
||||
uplayerTo.msg("<g>You have access to this area.");
|
||||
uplayer.msg("<g>You have access to this area.");
|
||||
}
|
||||
else if (accessTo.subjectAccessIsRestricted(uplayerTo))
|
||||
else if (accessTo.subjectAccessIsRestricted(uplayer))
|
||||
{
|
||||
uplayerTo.msg("<b>This area has restricted access.");
|
||||
uplayer.msg("<b>This area has restricted access.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (uplayerTo.getAutoClaimFor() != null)
|
||||
// -------------------------------------------- //
|
||||
// CHUNK CHANGE: AUTO CLAIM
|
||||
// -------------------------------------------- //
|
||||
|
||||
public void chunkChangeAutoClaim(UPlayer uplayer, PS chunkTo)
|
||||
{
|
||||
uplayerTo.tryClaim(uplayerTo.getAutoClaimFor(), PS.valueOf(event.getTo()), true, true);
|
||||
}
|
||||
// If the player is auto claiming ...
|
||||
Faction autoClaimFaction = uplayer.getAutoClaimFaction();
|
||||
if (autoClaimFaction == null) return;
|
||||
|
||||
// ... try claim.
|
||||
uplayer.tryClaim(autoClaimFaction, chunkTo, true, true);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
|
Loading…
Reference in New Issue
Block a user