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

Commit

Permalink
Improve parameters for gate edit
Browse files Browse the repository at this point in the history
  • Loading branch information
TheComputerGeek2 committed May 7, 2018
1 parent f1b9176 commit 31e9500
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
15 changes: 15 additions & 0 deletions src/com/massivecraft/massivegates/GateEdit.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.massivecraft.massivegates;

public enum GateEdit
{
// -------------------------------------------- //
// ENUM
// -------------------------------------------- //

CONTENT,
FRAME,
DELETE

// END OF LIST

}
16 changes: 9 additions & 7 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.GateEdit;
import com.massivecraft.massivegates.Perm;
import com.massivecraft.massivegates.cmd.type.TypeGateEdit;
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(TypeGateEdit.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,22 +55,22 @@ public void perform()
Location thatLoc = thatBlock.getLocation();
PS thatCoord = PS.valueOf(thatBlock);

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

// Apply
if (firstArgChar == 'f')
if (edit == GateEdit.FRAME)
{
gate.addFrame(thatCoord);
VisualizeUtil.addLocation(me, thatLoc, Const.visFrame);
SmokeUtil.spawnCloudSimple(thatLoc);
}
else if (firstArgChar == 'c')
else if (edit == GateEdit.CONTENT)
{
gate.addContent(thatCoord);
VisualizeUtil.addLocation(me, thatLoc, Const.visContent);
SmokeUtil.spawnCloudSimple(thatLoc);
}
else if (firstArgChar == 'd')
else if (edit == GateEdit.DELETE)
{
gate.delContent(thatCoord);
gate.delFrame(thatCoord);
Expand Down
16 changes: 16 additions & 0 deletions src/com/massivecraft/massivegates/cmd/type/TypeGateEdit.java
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.GateEdit;

public class TypeGateEdit extends TypeEnum<GateEdit>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //

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

}

0 comments on commit 31e9500

Please sign in to comment.