Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion core/src/main/java/tc/oc/pgm/flag/FlagDefinition.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ private static String makeName(@Nullable String name, @Nullable DyeColor color)
private final boolean showBeam;
private final boolean
showRespawnOnPickup; // Display where the flag will respawn when it is picked up.
private final boolean lockFlag; // Lock the flag to prevent it being dropped

public FlagDefinition(
@Nullable String id,
Expand All @@ -71,7 +72,8 @@ public FlagDefinition(
boolean showBeam,
@Nullable ProximityMetric flagProximityMetric,
@Nullable ProximityMetric netProximityMetric,
boolean showRespawnOnPickup) {
boolean showRespawnOnPickup,
boolean lockFlag) {

// We can't use the owner field in OwnedGoal because our owner
// is a reference that can't be resolved until after parsing.
Expand Down Expand Up @@ -100,6 +102,7 @@ public FlagDefinition(
this.dropOnWater = dropOnWater;
this.showBeam = showBeam;
this.showRespawnOnPickup = showRespawnOnPickup;
this.lockFlag = lockFlag;
}

public @Nullable DyeColor getColor() {
Expand Down Expand Up @@ -183,6 +186,10 @@ public boolean willShowRespawnOnPickup() {
return showRespawnOnPickup;
}

public boolean lockFlag() {
return lockFlag;
}

@Override
public Flag getGoal(Match match) {
return (Flag) super.getGoal(match);
Expand Down
95 changes: 46 additions & 49 deletions core/src/main/java/tc/oc/pgm/flag/FlagParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,8 @@ private SinglePost parseSinglePost(Element el) throws InvalidXMLException {
Filter respawnFilter =
filterParser.parseFilterProperty(el, "respawn-filter", StaticFilter.ALLOW);

Duration recoverTime =
XMLUtils.parseDuration(
Node.fromAttr(el, "recover-time", "return-time"), PostDefinition.DEFAULT_RETURN_TIME);
Duration recoverTime = XMLUtils.parseDuration(
Node.fromAttr(el, "recover-time", "return-time"), PostDefinition.DEFAULT_RETURN_TIME);
Duration respawnTime = XMLUtils.parseDuration(el.getAttribute("respawn-time"), null);
Double respawnSpeed =
XMLUtils.parseNumber(el.getAttribute("respawn-speed"), Double.class, (Double) null);
Expand Down Expand Up @@ -220,22 +219,21 @@ public NetDefinition parseNet(Element el, @Nullable FlagDefinition parentFlag)
returnableFlags = ImmutableSet.of();
}

NetDefinition net =
new NetDefinition(
id,
region,
captureFilter,
respawnFilter,
owner,
pointsPerCapture,
sticky,
denyMessage,
respawnMessage,
returnPost,
capturableFlags,
returnableFlags,
respawnTogether,
proximityLocation);
NetDefinition net = new NetDefinition(
id,
region,
captureFilter,
respawnFilter,
owner,
pointsPerCapture,
sticky,
denyMessage,
respawnMessage,
returnPost,
capturableFlags,
returnableFlags,
respawnTogether,
proximityLocation);
nets.add(net);
factory.getFeatures().addFeature(el, net);

Expand Down Expand Up @@ -268,14 +266,13 @@ public FlagDefinition parseFlag(Element el) throws InvalidXMLException {
Component carryMessage = XMLUtils.parseFormattedText(el, "carry-message");
boolean showRespawnOnPickup =
XMLUtils.parseBoolean(el.getAttribute("show-respawn-on-pickup"), false);
boolean lockFlag = XMLUtils.parseBoolean(el.getAttribute("locked"), false);
boolean dropOnWater = XMLUtils.parseBoolean(el.getAttribute("drop-on-water"), true);
boolean showBeam = XMLUtils.parseBoolean(el.getAttribute("beam"), true);
ProximityMetric flagProximityMetric =
ProximityMetric.parse(
el, "flag", new ProximityMetric(ProximityMetric.Type.CLOSEST_KILL, false));
ProximityMetric netProximityMetric =
ProximityMetric.parse(
el, "net", new ProximityMetric(ProximityMetric.Type.CLOSEST_PLAYER, false));
ProximityMetric flagProximityMetric = ProximityMetric.parse(
el, "flag", new ProximityMetric(ProximityMetric.Type.CLOSEST_KILL, false));
ProximityMetric netProximityMetric = ProximityMetric.parse(
el, "net", new ProximityMetric(ProximityMetric.Type.CLOSEST_PLAYER, false));

PostDefinition defaultPost;
Element elPost = XMLUtils.getUniqueChild(el, "post", "posts");
Expand All @@ -289,30 +286,30 @@ public FlagDefinition parseFlag(Element el) throws InvalidXMLException {
}
}

FlagDefinition flag =
new FlagDefinition(
id,
name,
required,
options,
color,
defaultPost,
owner,
pointsPerCapture,
pointsPerSecond,
pickupFilter,
captureFilter,
dropFilter,
pickupKit,
dropKit,
carryKit,
multiCarrier,
carryMessage,
dropOnWater,
showBeam,
flagProximityMetric,
netProximityMetric,
showRespawnOnPickup);
FlagDefinition flag = new FlagDefinition(
id,
name,
required,
options,
color,
defaultPost,
owner,
pointsPerCapture,
pointsPerSecond,
pickupFilter,
captureFilter,
dropFilter,
pickupKit,
dropKit,
carryKit,
multiCarrier,
carryMessage,
dropOnWater,
showBeam,
flagProximityMetric,
netProximityMetric,
showRespawnOnPickup,
lockFlag);
flags.add(flag);
factory.getFeatures().addFeature(el, flag);

Expand Down
9 changes: 8 additions & 1 deletion core/src/main/java/tc/oc/pgm/flag/state/Carried.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import tc.oc.pgm.flag.event.FlagStateChangeEvent;
import tc.oc.pgm.goals.events.GoalEvent;
import tc.oc.pgm.kits.Kit;
import tc.oc.pgm.kits.tag.ItemTags;
import tc.oc.pgm.score.ScoreCause;
import tc.oc.pgm.score.ScoreMatchModule;
import tc.oc.pgm.scoreboard.SidebarMatchModule;
Expand Down Expand Up @@ -110,7 +111,13 @@ public void enterState() {
if (kit != null) carrier.applyKit(kit, false);

this.helmetItem = this.carrier.getBukkit().getInventory().getHelmet();
this.carrier.getBukkit().getInventory().setHelmet(this.flag.getBannerItem().clone());
ItemStack bannerItem = this.flag.getBannerItem().clone();

if (this.flag.getDefinition().lockFlag()) {
ItemTags.LOCKED.set(bannerItem, true);
}

this.carrier.getBukkit().getInventory().setHelmet(bannerItem);

PGM.get()
.getExecutor()
Expand Down