-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e2ae837
commit f247f66
Showing
8 changed files
with
186 additions
and
17 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
src/main/java/com/nickimpact/impactor/api/rewards/IdentifiableReward.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.nickimpact.impactor.api.rewards; | ||
|
||
public interface IdentifiableReward<T> extends Reward<T> { | ||
|
||
/** | ||
* Retrieves the ID for this reward. This will be the primary key for referencing | ||
* reward types. | ||
* | ||
* @return The ID of the reward. | ||
*/ | ||
String getID(); | ||
|
||
/** | ||
* Retrieves the name of the reward. This represents the actual display name for the reward. | ||
* | ||
* @return The name of the reward. | ||
*/ | ||
String getName(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/com/nickimpact/impactor/api/rewards/impl/CommandReward.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.nickimpact.impactor.api.rewards.impl; | ||
|
||
import com.nickimpact.impactor.api.rewards.Reward; | ||
import org.spongepowered.api.Sponge; | ||
import org.spongepowered.api.entity.living.player.Player; | ||
|
||
public class CommandReward implements Reward<String> { | ||
|
||
private String command; | ||
|
||
public CommandReward(String command) { | ||
this.command = command; | ||
} | ||
|
||
@Override | ||
public String getReward() { | ||
return this.command; | ||
} | ||
|
||
@Override | ||
public void give(Player player) throws Exception { | ||
Sponge.getCommandManager().process(Sponge.getServer().getConsole(), command); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/java/com/nickimpact/impactor/api/rewards/impl/CommandSeriesReward.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.nickimpact.impactor.api.rewards.impl; | ||
|
||
import com.nickimpact.impactor.api.rewards.Reward; | ||
import org.spongepowered.api.Sponge; | ||
import org.spongepowered.api.entity.living.player.Player; | ||
import scala.actors.threadpool.Arrays; | ||
|
||
import java.util.List; | ||
|
||
public class CommandSeriesReward implements Reward<List<String>> { | ||
|
||
private List<String> commands; | ||
|
||
public CommandSeriesReward(List<String> commands) { | ||
this.commands = commands; | ||
} | ||
|
||
public CommandSeriesReward(String... commands) { | ||
this.commands = Arrays.asList(commands); | ||
} | ||
|
||
@Override | ||
public List<String> getReward() { | ||
return this.commands; | ||
} | ||
|
||
@Override | ||
public void give(Player player) throws Exception { | ||
for(String cmd : this.commands) { | ||
Sponge.getCommandManager().process(Sponge.getServer().getConsole(), cmd); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/nickimpact/impactor/api/rewards/impl/IdentifiableCommandReward.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.nickimpact.impactor.api.rewards.impl; | ||
|
||
import com.nickimpact.impactor.api.rewards.IdentifiableReward; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class IdentifiableCommandReward extends CommandReward implements IdentifiableReward<String> { | ||
|
||
private String ID; | ||
private String name; | ||
|
||
public IdentifiableCommandReward(String ID, String name, String command) { | ||
super(command); | ||
this.ID = ID; | ||
this.name = name; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/nickimpact/impactor/api/rewards/impl/IdentifiableCommandSeriesReward.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.nickimpact.impactor.api.rewards.impl; | ||
|
||
import com.nickimpact.impactor.api.rewards.IdentifiableReward; | ||
import lombok.Getter; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
public class IdentifiableCommandSeriesReward extends CommandSeriesReward implements IdentifiableReward<List<String>> { | ||
|
||
private String ID; | ||
private String name; | ||
|
||
public IdentifiableCommandSeriesReward(String ID, String name, List<String> commands) { | ||
super(commands); | ||
this.ID = ID; | ||
this.name = name; | ||
} | ||
|
||
public IdentifiableCommandSeriesReward(String ID, String name, String... commands) { | ||
super(commands); | ||
this.ID = ID; | ||
this.name = name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters