-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added title message capabilities. Re-organized command files Added updateChatSettings command to configure message structure. Removed SetSpawn command. Added system for per mine spawns. Added AddSpawn command. Added RemoveSpawn command. Added UpdateSpawn command. Added ChangeSpawn command. Improved command filling of mines to include error message returns. Improved details / info command.
- Loading branch information
1 parent
2fe8a24
commit 1a451aa
Showing
36 changed files
with
931 additions
and
308 deletions.
There are no files selected for viewing
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
322 changes: 187 additions & 135 deletions
322
src/main/java/com/github/jamies1211/minereset/Actions/FillMineAction.java
Large diffs are not rendered by default.
Oops, something went wrong.
108 changes: 108 additions & 0 deletions
108
src/main/java/com/github/jamies1211/minereset/Actions/SendMessages.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,108 @@ | ||
package com.github.jamies1211.minereset.Actions; | ||
|
||
import com.github.jamies1211.minereset.Messages; | ||
import org.spongepowered.api.Sponge; | ||
import org.spongepowered.api.entity.living.player.Player; | ||
import org.spongepowered.api.text.Text; | ||
import org.spongepowered.api.text.chat.ChatTypes; | ||
import org.spongepowered.api.text.serializer.TextSerializers; | ||
import org.spongepowered.api.text.title.Title; | ||
|
||
/** | ||
* Created by Jamie on 07-Jul-16. | ||
*/ | ||
public class SendMessages { | ||
public static boolean messageToPlayer (Player player, int messageType, String message) { | ||
|
||
/** Title */ | ||
if (messageType >= 4) { | ||
messageType -= 4; | ||
// Send title message; | ||
if (message != null) { | ||
String titleMessage = Messages.MinePrefix; | ||
String subtitleMessage = message.replace(Messages.MinePrefix, "&e"); | ||
sendTitleMessage(player, titleMessage, subtitleMessage); | ||
} | ||
} | ||
|
||
|
||
/** Action Bar */ | ||
if (messageType >= 2) { | ||
messageType -= 2; | ||
if (message != null) { | ||
// Send actionBar message; | ||
player.sendMessage(ChatTypes.ACTION_BAR, TextSerializers.FORMATTING_CODE.deserialize(message)); | ||
} | ||
} | ||
|
||
|
||
/** Chat */ | ||
if (messageType >= 1) { | ||
messageType -= 1; | ||
if (message != null) { | ||
// Send chat message; | ||
player.sendMessage(ChatTypes.CHAT, TextSerializers.FORMATTING_CODE.deserialize(message)); | ||
} | ||
} | ||
|
||
return (messageType == 0); | ||
} | ||
|
||
public static boolean messageToAllPlayers (int messageType, String message) { | ||
|
||
/** Title */ | ||
if (messageType >= 4) { | ||
messageType -= 4; | ||
// Send title message; | ||
for (Player player : Sponge.getServer().getOnlinePlayers()) { | ||
if (message != null) { | ||
String titleMessage = Messages.MinePrefix; | ||
String subtitleMessage = message.replace(Messages.MinePrefix, "&e"); | ||
sendTitleMessage(player, titleMessage, subtitleMessage); | ||
} | ||
} | ||
} | ||
|
||
|
||
/** Action Bar */ | ||
if (messageType >= 2) { | ||
messageType -= 2; | ||
for (Player player : Sponge.getServer().getOnlinePlayers()) { | ||
if (message != null) { | ||
// Send actionBar message; | ||
player.sendMessage(ChatTypes.ACTION_BAR, TextSerializers.FORMATTING_CODE.deserialize(message)); | ||
} | ||
} | ||
} | ||
|
||
|
||
/** Chat */ | ||
if (messageType >= 1) { | ||
messageType -= 1; | ||
for (Player player : Sponge.getServer().getOnlinePlayers()) { | ||
if (message != null) { | ||
// Send chat message; | ||
player.sendMessage(ChatTypes.CHAT, TextSerializers.FORMATTING_CODE.deserialize(message)); | ||
} | ||
} | ||
} | ||
|
||
return (messageType == 0); | ||
} | ||
|
||
public static void sendTitleMessage (Player player, String titleString, String subTitleString) { | ||
|
||
if (titleString == null) { | ||
titleString = ""; | ||
} | ||
|
||
if (subTitleString == null) { | ||
subTitleString = ""; | ||
} | ||
|
||
Text title = TextSerializers.FORMATTING_CODE.deserialize(titleString); | ||
Text subTitle = TextSerializers.FORMATTING_CODE.deserialize(subTitleString); | ||
|
||
player.sendTitle(Title.of(title, subTitle)); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
src/main/java/com/github/jamies1211/minereset/Actions/UpdateConfig.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,70 @@ | ||
package com.github.jamies1211.minereset.Actions; | ||
|
||
import com.github.jamies1211.minereset.MineReset; | ||
import ninja.leaping.configurate.ConfigurationNode; | ||
import org.spongepowered.api.Sponge; | ||
|
||
/** | ||
* Created by Jamie on 06-Jul-16. | ||
*/ | ||
public class UpdateConfig { | ||
|
||
public static void update1to2 () { | ||
|
||
ConfigurationNode config = MineReset.plugin.getConfig(); | ||
|
||
if (config.getNode("1 - ConfigMode").getInt() == 1) { | ||
config.getNode("1 - ConfigMode").setValue("2"); | ||
|
||
if (config.getNode("3 - Spawn", "SpawnX").getValue() == null) { | ||
config.getNode("3 - Spawn", "SpawnDefault", "SpawnX").setValue(0.5); | ||
config.getNode("3 - Spawn", "SpawnDefault", "SpawnY").setValue(85.0); | ||
config.getNode("3 - Spawn", "SpawnDefault", "SpawnZ").setValue(0.5); | ||
config.getNode("3 - Spawn", "SpawnDefault", "SpawnDirection").setValue("West"); | ||
config.getNode("3 - Spawn", "SpawnDefault", "SpawnWorld").setValue(Sponge.getServer().getDefaultWorld().get().getUniqueId().toString()); | ||
} else { | ||
config.getNode("3 - Spawn", "SpawnDefault", "SpawnX").setValue(config.getNode("3 - Spawn", "SpawnX").getDouble()); | ||
config.getNode("3 - Spawn", "SpawnDefault", "SpawnY").setValue(config.getNode("3 - Spawn", "SpawnY").getDouble()); | ||
config.getNode("3 - Spawn", "SpawnDefault", "SpawnZ").setValue(config.getNode("3 - Spawn", "SpawnS").getDouble()); | ||
config.getNode("3 - Spawn", "SpawnDefault", "SpawnDirection").setValue(config.getNode("3 - Spawn", "SpawnX").getDouble()); | ||
config.getNode("3 - Spawn", "SpawnDefault", "SpawnWorld").setValue(config.getNode("3 - Spawn", "SpawnWorld").getString()); | ||
|
||
|
||
config.getNode("3 - Spawn").removeChild("SpawnX"); | ||
config.getNode("3 - Spawn").removeChild("SpawnY"); | ||
config.getNode("3 - Spawn").removeChild("SpawnZ"); | ||
config.getNode("3 - Spawn").removeChild("SpawnDirection"); | ||
config.getNode("3 - Spawn").removeChild("SpawnWorld"); | ||
} | ||
|
||
for (Object groupObject : config.getNode("4 - MineGroups").getChildrenMap().keySet()) { | ||
String group = groupObject.toString(); | ||
for (Object objects : config.getNode("4 - MineGroups", group).getChildrenMap().keySet()) { | ||
if (!objects.toString().equalsIgnoreCase("InitialDelay") && !objects.toString().equalsIgnoreCase("ResetTime")) { | ||
String mine = objects.toString(); | ||
if (config.getNode("4 - MineGroups", group, mine, "SpawnPoint").getValue() == null) { | ||
config.getNode("4 - MineGroups", group, mine, "SpawnPoint").setValue("Default"); | ||
} | ||
} | ||
} | ||
} | ||
|
||
config.getNode("5 - Lists", "AirBlocks").setValue( | ||
"\"minecraft:torch\", \"minecraft:redstone_torch\", \"minecraft:redstone_wire\", \"minecraft:powered_repeater\", \"minecraft:unpowered_repeater\", \"minecraft:powered_comparator\",\n" + | ||
"\"minecraft:unpowered_comparator\", \"minecraft:wooden_button\", \"minecraft:stone_button\", \"minecraft:lever\", \"minecraft:tripwire_hook\", \"minecraft:stone_pressure_plate\",\n" + | ||
"\"minecraft:wooden_pressure_plate\", \"minecraft:light_weighted_pressure_plate\", \"minecraft:heavy_weighted_pressure_plate\", \"minecraft:trapdoor\", \"minecraft:iron_trapdoor\",\n" + | ||
"\"minecraft:fence_gate\", \"minecraft:spruce_fence_gate\", \"minecraft:birch_fence_gate\", \"minecraft:jungle_fence_gate\", \"minecraft:dark_oak_fence_gate\", \"minecraft:acacia_fence_gate\",\n" + | ||
"\"minecraft:wooden_door\", \"minecraft:iron_door\", \"minecraft:spruce_door\", \"minecraft:birch_door\", \"minecraft:jungle_door\", \"minecraft:acacia_door\", \"minecraft:dark_oak_door\", \n" + | ||
"\"minecraft:rail\", \"minecraft:golden_rail\", \"minecraft:detector_rail\", \"minecraft:activator_rail\", \"minecraft:tallgrass\", \"minecraft:sapling\", \"minecraft:deadbush\",\n" + | ||
"\"minecraft:yellow_flower\", \"minecraft:red_flower\", \"minecraft:brown_mushroom\", \"minecraft:red_mushroom\", \"minecraft:ladder\", \"minecraft:snow_layer\", \"minecraft:fence\",\n" + | ||
"\"minecraft:nether_brick_fence\", \"minecraft:iron_bars\", \"minecraft:glass_pane\", \"minecraft:vine\", \"minecraft:waterlily\", \"minecraft:cobblestone_wall\", \"minecraft:anvil\",\n" + | ||
"\"minecraft:stained_glass_pane\", \"minecraft:carpet\", \"minecraft:double_plant\", \"minecraft:wall_sign\", \"minecraft:standing_sign\", \"minecraft:skull\", \"minecraft:brewing_stand\",\n" + | ||
"\"minecraft:skull\", \"minecraft:standing_banner\""); | ||
|
||
config.getNode("6 - ChatSettings", "FillingText").setValue("1"); | ||
config.getNode("6 - ChatSettings", "ReminderText").setValue("2"); | ||
MineReset.plugin.save(); | ||
} | ||
} | ||
|
||
} |
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
2 changes: 1 addition & 1 deletion
2
...211/minereset/Commands/AddRemindTime.java → ...ommands/ConfigCommands/AddRemindTime.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
2 changes: 1 addition & 1 deletion
2
...1211/minereset/Commands/ConfigReload.java → ...Commands/ConfigCommands/ConfigReload.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
2 changes: 1 addition & 1 deletion
2
...es1211/minereset/Commands/ConfigSave.java → ...t/Commands/ConfigCommands/ConfigSave.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
2 changes: 1 addition & 1 deletion
2
...11/minereset/Commands/RemoveAirBlock.java → ...mmands/ConfigCommands/RemoveAirBlock.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
2 changes: 1 addition & 1 deletion
2
.../minereset/Commands/RemoveRemindTime.java → ...ands/ConfigCommands/RemoveRemindTime.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
58 changes: 58 additions & 0 deletions
58
...main/java/com/github/jamies1211/minereset/Commands/ConfigCommands/UpdateChatSettings.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,58 @@ | ||
package com.github.jamies1211.minereset.Commands.ConfigCommands; | ||
|
||
import com.github.jamies1211.minereset.Actions.SendMessages; | ||
import com.github.jamies1211.minereset.Messages; | ||
import com.github.jamies1211.minereset.MineReset; | ||
import ninja.leaping.configurate.ConfigurationNode; | ||
import org.spongepowered.api.command.CommandException; | ||
import org.spongepowered.api.command.CommandResult; | ||
import org.spongepowered.api.command.CommandSource; | ||
import org.spongepowered.api.command.args.CommandContext; | ||
import org.spongepowered.api.command.spec.CommandExecutor; | ||
import org.spongepowered.api.text.serializer.TextSerializers; | ||
|
||
/** | ||
* Created by Jamie on 07-Jul-16. | ||
*/ | ||
public class UpdateChatSettings implements CommandExecutor { | ||
|
||
@Override | ||
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException { | ||
|
||
ConfigurationNode config = MineReset.plugin.getConfig(); | ||
|
||
String type = args.<String>getOne("type").get(); | ||
int option = args.<Integer>getOne("option").get(); | ||
|
||
if (type.equalsIgnoreCase("FillingText")) { | ||
type = "FillingText"; | ||
} else if (type.equalsIgnoreCase("ReminderText")) { | ||
type = "ReminderText"; | ||
} else { | ||
type = null; | ||
} | ||
|
||
int oldOption = config.getNode("6 - ChatSettings", type).getInt(); | ||
|
||
if (type != null) { | ||
if (option != oldOption) { | ||
if (SendMessages.messageToAllPlayers(option, null)) { | ||
config.getNode("6 - ChatSettings", type).setValue(option); // Wright changes to file. | ||
MineReset.plugin.save(); | ||
src.sendMessage(TextSerializers.FORMATTING_CODE.deserialize(Messages.MinePrefix + Messages.ChatSettingChanged + | ||
" " + type + " " + "to" + " " + option)); | ||
} else { | ||
src.sendMessage(TextSerializers.FORMATTING_CODE.deserialize(Messages.MinePrefix + Messages.InvalidChatSetting)); | ||
} | ||
} else { | ||
src.sendMessage(TextSerializers.FORMATTING_CODE.deserialize(Messages.MinePrefix + Messages.ChatSettingAlreadySet1 + | ||
" " + type + " " + Messages.ChatSettingAlreadySet2 + " " + option)); | ||
} | ||
} else { | ||
src.sendMessage(TextSerializers.FORMATTING_CODE.deserialize(Messages.MinePrefix + Messages.InvalidChatType)); | ||
} | ||
|
||
|
||
return CommandResult.success(); | ||
} | ||
} |
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
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
2 changes: 1 addition & 1 deletion
2
...s1211/minereset/Commands/DefineGroup.java → ...t/Commands/GroupCommands/DefineGroup.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
2 changes: 1 addition & 1 deletion
2
...s1211/minereset/Commands/DeleteGroup.java → ...t/Commands/GroupCommands/DeleteGroup.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
2 changes: 1 addition & 1 deletion
2
...s1211/minereset/Commands/UpdateGroup.java → ...t/Commands/GroupCommands/UpdateGroup.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
2 changes: 1 addition & 1 deletion
2
...ies1211/minereset/Commands/CheckTime.java → ...eset/Commands/InfoCommands/CheckTime.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
Oops, something went wrong.