Skip to content
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.

Improve parameters for gate edit #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 15 additions & 0 deletions src/com/massivecraft/massivegates/GateStructureChange.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.massivecraft.massivegates;

public enum GateStructureChange
{
// -------------------------------------------- //
// ENUM
// -------------------------------------------- //

CONTENT,
FRAME,
DELETE

// END OF LIST

}
21 changes: 9 additions & 12 deletions src/com/massivecraft/massivegates/cmd/CmdGateEditThat.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.massivecraft.massivegates.cmd;

import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
import com.massivecraft.massivecore.command.type.primitive.TypeString;
import com.massivecraft.massivecore.ps.PS;
import com.massivecraft.massivecore.util.SmokeUtil;
import com.massivecraft.massivegates.Const;
import com.massivecraft.massivegates.GateStructureChange;
import com.massivecraft.massivegates.Perm;
import com.massivecraft.massivegates.cmd.type.TypeGateStructureChange;
import com.massivecraft.massivegates.cmdreq.ReqGateSelected;
import com.massivecraft.massivegates.entity.Gate;
import com.massivecraft.massivegates.entity.MConf;
Expand All @@ -25,7 +27,7 @@ public class CmdGateEditThat extends GateCommand
public CmdGateEditThat()
{
// Parameters
this.addParameter(TypeString.get(), "frame|content|del");
this.addParameter(TypeGateStructureChange.get(), "frame|content|del");

// Requirements
this.addRequirements(RequirementIsPlayer.get(), ReqGateSelected.get());
Expand All @@ -43,7 +45,7 @@ public List<String> getAliases()
}

@Override
public void perform()
public void perform() throws MassiveException
{
// Args
Gate gate = gsender.getSelectedGate();
Expand All @@ -53,32 +55,27 @@ public void perform()
Location thatLoc = thatBlock.getLocation();
PS thatCoord = PS.valueOf(thatBlock);

char firstArgChar = this.argAt(0).toLowerCase().charAt(0);
GateStructureChange edit = this.readArg();

// Apply
if (firstArgChar == 'f')
if (edit == GateStructureChange.FRAME)
{
gate.addFrame(thatCoord);
VisualizeUtil.addLocation(me, thatLoc, Const.visFrame);
SmokeUtil.spawnCloudSimple(thatLoc);
}
else if (firstArgChar == 'c')
else if (edit == GateStructureChange.CONTENT)
{
gate.addContent(thatCoord);
VisualizeUtil.addLocation(me, thatLoc, Const.visContent);
SmokeUtil.spawnCloudSimple(thatLoc);
}
else if (firstArgChar == 'd')
else if (edit == GateStructureChange.DELETE)
{
gate.delContent(thatCoord);
gate.delFrame(thatCoord);
SmokeUtil.spawnCloudSimple(thatLoc);
}
else
{
// Inform
this.msg("<b>Arg must be frame|content|del .");
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.massivecraft.massivegates.cmd.type;

import com.massivecraft.massivecore.command.type.enumeration.TypeEnum;
import com.massivecraft.massivegates.GateStructureChange;

public class TypeGateStructureChange extends TypeEnum<GateStructureChange>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //

private static TypeGateStructureChange i = new TypeGateStructureChange();
public static TypeGateStructureChange get() { return i; }
public TypeGateStructureChange() { super(GateStructureChange.class); }

}