-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reloading, a config, basically changed the whole command structure.
- Loading branch information
Xenoyia
committed
Apr 26, 2017
1 parent
5892c70
commit 3f6a25b
Showing
8 changed files
with
236 additions
and
18 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.xpgaming.xPBottles; | ||
|
||
import java.net.URL; | ||
import java.nio.file.Path; | ||
import java.util.Collection; | ||
import java.util.Optional; | ||
|
||
import org.spongepowered.api.Sponge; | ||
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.data.key.Keys; | ||
import org.spongepowered.api.data.manipulator.mutable.entity.GameModeData; | ||
import org.spongepowered.api.entity.Entity; | ||
import org.spongepowered.api.entity.EntityTypes; | ||
import org.spongepowered.api.entity.Item; | ||
import org.spongepowered.api.entity.living.player.Player; | ||
import org.spongepowered.api.entity.living.player.gamemode.GameModes; | ||
import org.spongepowered.api.event.cause.Cause; | ||
import org.spongepowered.api.event.cause.entity.spawn.EntitySpawnCause; | ||
import org.spongepowered.api.event.cause.entity.spawn.SpawnCause; | ||
import org.spongepowered.api.event.cause.entity.spawn.SpawnTypes; | ||
import org.spongepowered.api.item.ItemTypes; | ||
import org.spongepowered.api.item.inventory.ItemStack; | ||
import org.spongepowered.api.item.inventory.ItemStackSnapshot; | ||
import org.spongepowered.api.item.inventory.entity.Hotbar; | ||
import org.spongepowered.api.item.inventory.type.GridInventory; | ||
import org.spongepowered.api.text.Text; | ||
import org.spongepowered.api.text.format.TextColors; | ||
import org.spongepowered.api.world.Location; | ||
import org.spongepowered.api.world.World; | ||
import org.spongepowered.api.world.extent.Extent; | ||
|
||
import ninja.leaping.configurate.commented.CommentedConfigurationNode; | ||
import ninja.leaping.configurate.hocon.HoconConfigurationLoader; | ||
import ninja.leaping.configurate.loader.ConfigurationLoader; | ||
|
||
public class Bottle implements CommandExecutor { | ||
|
||
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException { | ||
if(src instanceof Player) { | ||
Player player = (Player) src; | ||
player.sendMessage(Text.of("§f[§bxP//§f] §b§l-- COMMANDS --")); | ||
if(player.hasPermission("xpgaming.bottles.use")) { | ||
player.sendMessage(Text.of(" §7> §b/bottle confirm §7- Convert your XP into bottles!")); | ||
} | ||
if(player.hasPermission("xpgaming.bottles.reload")) { | ||
player.sendMessage(Text.of(" §7> §b/bottle reload §7- Reload plugin configuration!")); | ||
} | ||
} else { | ||
src.sendMessage(Text.of("§f[§bxP//§f] §b§l-- COMMANDS --")); | ||
src.sendMessage(Text.of(" §7> §b/bottle confirm §7- Convert your XP into bottles!")); | ||
src.sendMessage(Text.of(" §7> §b/bottle reload §7- Reload plugin configuration!")); | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.xpgaming.xPBottles; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
import ninja.leaping.configurate.commented.CommentedConfigurationNode; | ||
import ninja.leaping.configurate.loader.ConfigurationLoader; | ||
|
||
public class Config { | ||
private static Config instance = new Config(); | ||
|
||
public static Config getInstance() { | ||
return instance; | ||
} | ||
|
||
private ConfigurationLoader<CommentedConfigurationNode> configLoader; | ||
private CommentedConfigurationNode config; | ||
private File configFile; | ||
|
||
public void configCreate() { | ||
try { | ||
configFile.createNewFile(); | ||
configLoad(); | ||
CommentedConfigurationNode bottles = config.getNode("bottles").setComment("xP// Bottles coded by Xenoyia! Check out mc.xpgaming.com!"); | ||
bottles.getNode("min_level").setComment("Do not set this to lower than 2, it's hardcoded to not give half a bottle.").setValue("30"); | ||
configSave(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public void setup(File configFile, ConfigurationLoader<CommentedConfigurationNode> configLoader) { | ||
this.configLoader = configLoader; | ||
this.configFile = configFile; | ||
if (!configFile.exists()) { | ||
configCreate(); | ||
} else | ||
configLoad(); | ||
} | ||
|
||
public CommentedConfigurationNode getConfig() { | ||
return config; | ||
} | ||
|
||
public void configLoad() { | ||
if (!configFile.exists()) { | ||
configCreate(); | ||
} else | ||
try { | ||
config = configLoader.load(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public void configSave() { | ||
try { | ||
configLoader.save(config); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public void saveAndLoadConfig() { | ||
configSave(); | ||
configLoad(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.xpgaming.xPBottles; | ||
|
||
import java.net.URL; | ||
import java.nio.file.Path; | ||
import java.util.Collection; | ||
import java.util.Optional; | ||
|
||
import org.spongepowered.api.Sponge; | ||
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.data.key.Keys; | ||
import org.spongepowered.api.data.manipulator.mutable.entity.GameModeData; | ||
import org.spongepowered.api.entity.Entity; | ||
import org.spongepowered.api.entity.EntityTypes; | ||
import org.spongepowered.api.entity.Item; | ||
import org.spongepowered.api.entity.living.player.Player; | ||
import org.spongepowered.api.entity.living.player.gamemode.GameModes; | ||
import org.spongepowered.api.event.cause.Cause; | ||
import org.spongepowered.api.event.cause.entity.spawn.EntitySpawnCause; | ||
import org.spongepowered.api.event.cause.entity.spawn.SpawnCause; | ||
import org.spongepowered.api.event.cause.entity.spawn.SpawnTypes; | ||
import org.spongepowered.api.item.ItemTypes; | ||
import org.spongepowered.api.item.inventory.ItemStack; | ||
import org.spongepowered.api.item.inventory.ItemStackSnapshot; | ||
import org.spongepowered.api.item.inventory.entity.Hotbar; | ||
import org.spongepowered.api.item.inventory.type.GridInventory; | ||
import org.spongepowered.api.text.Text; | ||
import org.spongepowered.api.text.format.TextColors; | ||
import org.spongepowered.api.world.Location; | ||
import org.spongepowered.api.world.World; | ||
import org.spongepowered.api.world.extent.Extent; | ||
|
||
import ninja.leaping.configurate.commented.CommentedConfigurationNode; | ||
import ninja.leaping.configurate.hocon.HoconConfigurationLoader; | ||
import ninja.leaping.configurate.loader.ConfigurationLoader; | ||
|
||
public class Reload implements CommandExecutor { | ||
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException { | ||
Config.getInstance().configLoad(); | ||
if(src instanceof Player) { | ||
Player player = (Player) src; | ||
player.sendMessage(Text.of("§f[§bxP//§f] §bSuccessfully reloaded xP// Bottles!")); | ||
} else { | ||
src.sendMessage(Text.of("§f[§bxP//§f] §bSuccessfully reloaded xP// Bottles!")); | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
abcde |