Multiple changes

This commit is contained in:
alisolarflare 2018-01-03 13:49:23 -05:00
parent e60af98c02
commit 8e0339cfaa
32 changed files with 188 additions and 180 deletions

View file

@ -1,4 +1,4 @@
main: buttondevteam.presents.Main
main: buttondevteam.presents.ButtonPresents
name: ButtonPresents
version: 0.0.1

View file

@ -5,18 +5,20 @@ import java.util.logging.Logger;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.presents.components.dictionary.DictionaryComponent;
import buttondevteam.presents.components.magic.MagicComponent;
import buttondevteam.presents.components.research.ResearchComponent;
import buttondevteam.presents.components.research.dictionary.DictionaryComponent;
import buttondevteam.presents.components.spawn.SpawnComponent;
public class Main extends JavaPlugin{
public class ButtonPresents extends JavaPlugin{
public void onEnable(){
PluginDescriptionFile pdfFile = getDescription();
Logger logger = getLogger();
logger.info(pdfFile.getName() + " has been started (V." + pdfFile.getVersion()+ ").");
new DictionaryComponent().register(this);
new SpawnComponent().register(this);
new MagicComponent().register(this);

View file

@ -1,51 +0,0 @@
package buttondevteam.presents.components.dictionary;
import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.presents.architecture.Component;
import buttondevteam.presents.components.dictionary.commands.SendJSON;
import buttondevteam.presents.components.dictionary.commands.SendMessage;
import buttondevteam.presents.components.dictionary.config.LoadConfig;
import buttondevteam.presents.components.dictionary.config.SaveConfig;
import buttondevteam.presents.components.dictionary.config.TimePersistence;
import buttondevteam.presents.components.dictionary.effects.Bedsplode;
import buttondevteam.presents.components.dictionary.pages.DataPage;
import buttondevteam.presents.components.dictionary.pages.HelloPage;
import buttondevteam.presents.components.dictionary.pages.JSONPage;
import buttondevteam.presents.components.dictionary.pages.LocationPage;
import buttondevteam.presents.components.dictionary.pages.POSTPage;
import buttondevteam.presents.components.dictionary.pages.PlayersOnlinePage;
import buttondevteam.presents.components.dictionary.spawning.PlaySound;
import buttondevteam.presents.components.dictionary.spawning.SetBlock;
import buttondevteam.presents.components.dictionary.spawning.SpawnCow;
import buttondevteam.presents.components.dictionary.spawning.SpawnItem;
import buttondevteam.presents.components.dictionary.spawning.SpawnMagicPotato;
import buttondevteam.presents.components.dictionary.spawning.SpawnParticle;
public class DictionaryComponent extends Component{
@Override
public void register(JavaPlugin plugin) {
this.registerCommand(plugin, new SendMessage());
this.registerCommand(plugin, new SendJSON());
this.registerCommand(plugin, new SaveConfig());
this.registerCommand(plugin, new LoadConfig());
this.registerCommand(plugin, new TimePersistence());
this.registerListener(plugin, new Bedsplode());
this.registerCommand(plugin, new SpawnCow());
this.registerCommand(plugin, new SpawnItem());
this.registerCommand(plugin, new SpawnMagicPotato());
this.registerCommand(plugin, new SetBlock());
this.registerCommand(plugin, new SpawnParticle());
this.registerCommand(plugin, new PlaySound());
this.addPage(plugin, new HelloPage());
this.addPage(plugin, new DataPage());
this.addPage(plugin, new PlayersOnlinePage(plugin));
this.addPage(plugin, new LocationPage(plugin));
this.addPage(plugin, new POSTPage(plugin));
this.addPage(plugin, new JSONPage());
}
}

View file

@ -1,51 +0,0 @@
package buttondevteam.presents.components.dictionary.copy;
import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.presents.architecture.Component;
import buttondevteam.presents.components.dictionary.commands.SendJSON;
import buttondevteam.presents.components.dictionary.commands.SendMessage;
import buttondevteam.presents.components.dictionary.config.LoadConfig;
import buttondevteam.presents.components.dictionary.config.SaveConfig;
import buttondevteam.presents.components.dictionary.config.TimePersistence;
import buttondevteam.presents.components.dictionary.effects.Bedsplode;
import buttondevteam.presents.components.dictionary.pages.DataPage;
import buttondevteam.presents.components.dictionary.pages.HelloPage;
import buttondevteam.presents.components.dictionary.pages.JSONPage;
import buttondevteam.presents.components.dictionary.pages.LocationPage;
import buttondevteam.presents.components.dictionary.pages.POSTPage;
import buttondevteam.presents.components.dictionary.pages.PlayersOnlinePage;
import buttondevteam.presents.components.dictionary.spawning.PlaySound;
import buttondevteam.presents.components.dictionary.spawning.SetBlock;
import buttondevteam.presents.components.dictionary.spawning.SpawnCow;
import buttondevteam.presents.components.dictionary.spawning.SpawnItem;
import buttondevteam.presents.components.dictionary.spawning.SpawnMagicPotato;
import buttondevteam.presents.components.dictionary.spawning.SpawnParticle;
public class DictionaryComponent extends Component{
@Override
public void register(JavaPlugin plugin) {
this.registerCommand(plugin, new SendMessage());
this.registerCommand(plugin, new SendJSON());
this.registerCommand(plugin, new SaveConfig());
this.registerCommand(plugin, new LoadConfig());
this.registerCommand(plugin, new TimePersistence());
this.registerListener(plugin, new Bedsplode());
this.registerCommand(plugin, new SpawnCow());
this.registerCommand(plugin, new SpawnItem());
this.registerCommand(plugin, new SpawnMagicPotato());
this.registerCommand(plugin, new SetBlock());
this.registerCommand(plugin, new SpawnParticle());
this.registerCommand(plugin, new PlaySound());
this.addPage(plugin, new HelloPage());
this.addPage(plugin, new DataPage());
this.addPage(plugin, new PlayersOnlinePage(plugin));
this.addPage(plugin, new LocationPage(plugin));
this.addPage(plugin, new POSTPage(plugin));
this.addPage(plugin, new JSONPage());
}
}

View file

@ -0,0 +1,30 @@
package buttondevteam.presents.components.dungeon;
import org.bukkit.configuration.file.FileConfiguration;
public class DungeonConfig {
private FileConfiguration config;
public enum SETTING {
NAME ("dungeon.name"),
OWNER ("dungeon.owner"),
SPAWN ("dungeon.spawn"),
STATE ("dungeon.state"),
CREATED("dungeon.created"); //creation date in miliseconds
public String path;
private SETTING(String path){
this.path = path;
}
}
public enum dungeonState {
INVALID, //something is wrong with the file
VALID
}
public DungeonConfig(FileConfiguration config){
this.config = config;
}
public void set(SETTING setting, Object value){
this.config.set(setting.path, value);
}
}

View file

@ -5,35 +5,40 @@ import org.bukkit.entity.Player;
import buttondevteam.lib.chat.CommandClass;
import buttondevteam.presents.architecture.commands.ModCommand;
import buttondevteam.presents.components.dungeon.DungeonConfig.SETTING;
@CommandClass(path="dungeon create")
public class DungeonCreate extends ModCommand{
@Override
public boolean OnCommand(Player player, String alias, String[] args) {
//Creates a new dungeon
if(args.length < 1) return false;
String dungeonName = args[0];
FileConfiguration config = this.getPlugin().getConfig();
FileConfiguration plugin_config = this.getPlugin().getConfig();
if (config.contains("dungeons." + dungeonName)){
if (plugin_config.contains("dungeons." + dungeonName)){
player.sendMessage("There already exists a dungeon named " + dungeonName);
player.sendMessage("Type /dungeon info [dungeonname] to get more information");
return true;
}
else{
config.set("dungeon." + dungeonName, true);
config.set("dungeon." + dungeonName + ".owner", player.getName());
config.set("dungeon." + dungeonName + ".spawn", player.getLocation().toString());
config.set("dungeon." + dungeonName + ".created", System.currentTimeMillis());
this.getPlugin().saveConfig();
assert(dungeonName ==
this.getPlugin()
.getConfig()
.getString("dungeon." + dungeonName));
player.sendMessage("New dungeon named " + dungeonName + " created.");
DungeonConfig config = new DungeonConfig(plugin_config);
config.set(SETTING.NAME, true);
config.set(SETTING.OWNER, player.getName());
config.set(SETTING.SPAWN, player.getLocation().toString());
config.set(SETTING.CREATED, System.currentTimeMillis());
this.getPlugin().saveConfig();
if (this.getPlugin().getConfig().contains("dungeon." + dungeonName)){
player.sendMessage("New dungeon named " + dungeonName + " saved.");
}else{
player.sendMessage("Error in saving the dungeon " + dungeonName);
player.sendMessage("Current Config does not contain a path named dungeon." + dungeonName );
}
return true;
}

View file

@ -5,8 +5,8 @@ import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.presents.architecture.Component;
import buttondevteam.presents.components.research.questions.OverflowCrash;
import buttondevteam.presents.components.research.questions.OverwhelmCrash;
import buttondevteam.presents.components.research.questions.PluginDataFolderInfo;
import buttondevteam.presents.components.research.questions.PluginConfigInfo;
import buttondevteam.presents.components.research.questions.PluginDataFolderInfo;
public class ResearchComponent extends Component {

View file

@ -0,0 +1,51 @@
package buttondevteam.presents.components.research.dictionary;
import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.presents.architecture.Component;
import buttondevteam.presents.components.research.dictionary.commands.SendJSON;
import buttondevteam.presents.components.research.dictionary.commands.SendMessage;
import buttondevteam.presents.components.research.dictionary.config.LoadConfig;
import buttondevteam.presents.components.research.dictionary.config.SaveConfig;
import buttondevteam.presents.components.research.dictionary.config.TimePersistence;
import buttondevteam.presents.components.research.dictionary.effects.Bedsplode;
import buttondevteam.presents.components.research.dictionary.pages.DataPage;
import buttondevteam.presents.components.research.dictionary.pages.HelloPage;
import buttondevteam.presents.components.research.dictionary.pages.JSONPage;
import buttondevteam.presents.components.research.dictionary.pages.LocationPage;
import buttondevteam.presents.components.research.dictionary.pages.POSTPage;
import buttondevteam.presents.components.research.dictionary.pages.PlayersOnlinePage;
import buttondevteam.presents.components.research.dictionary.spawning.PlaySound;
import buttondevteam.presents.components.research.dictionary.spawning.SetBlock;
import buttondevteam.presents.components.research.dictionary.spawning.SpawnCow;
import buttondevteam.presents.components.research.dictionary.spawning.SpawnItem;
import buttondevteam.presents.components.research.dictionary.spawning.SpawnMagicPotato;
import buttondevteam.presents.components.research.dictionary.spawning.SpawnParticle;
public class DictionaryComponent extends Component{
@Override
public void register(JavaPlugin plugin) {
this.registerCommand(plugin, new SendMessage());
this.registerCommand(plugin, new SendJSON());
this.registerCommand(plugin, new SaveConfig());
this.registerCommand(plugin, new LoadConfig());
this.registerCommand(plugin, new TimePersistence());
this.registerListener(plugin, new Bedsplode());
this.registerCommand(plugin, new SpawnCow());
this.registerCommand(plugin, new SpawnItem());
this.registerCommand(plugin, new SpawnMagicPotato());
this.registerCommand(plugin, new SetBlock());
this.registerCommand(plugin, new SpawnParticle());
this.registerCommand(plugin, new PlaySound());
this.addPage(plugin, new HelloPage());
this.addPage(plugin, new DataPage());
this.addPage(plugin, new PlayersOnlinePage(plugin));
this.addPage(plugin, new LocationPage(plugin));
this.addPage(plugin, new POSTPage(plugin));
this.addPage(plugin, new JSONPage());
}
}

View file

@ -1,4 +1,4 @@
package buttondevteam.presents.components.dictionary.commands;
package buttondevteam.presents.components.research.dictionary.commands;
import org.bukkit.entity.Player;

View file

@ -1,4 +1,4 @@
package buttondevteam.presents.components.dictionary.commands;
package buttondevteam.presents.components.research.dictionary.commands;
import org.bukkit.command.CommandSender;

View file

@ -1,4 +1,4 @@
package buttondevteam.presents.components.dictionary.config;
package buttondevteam.presents.components.research.dictionary.config;

View file

@ -1,4 +1,4 @@
package buttondevteam.presents.components.dictionary.config;
package buttondevteam.presents.components.research.dictionary.config;
import java.util.Arrays;

View file

@ -1,4 +1,4 @@
package buttondevteam.presents.components.dictionary.config;
package buttondevteam.presents.components.research.dictionary.config;
import java.text.SimpleDateFormat;
import java.util.Date;

View file

@ -1,4 +1,4 @@
package buttondevteam.presents.components.dictionary.effects;
package buttondevteam.presents.components.research.dictionary.effects;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;

View file

@ -1,4 +1,4 @@
package buttondevteam.presents.components.dictionary.pages;
package buttondevteam.presents.components.research.dictionary.pages;
import com.sun.net.httpserver.HttpExchange;

View file

@ -1,4 +1,4 @@
package buttondevteam.presents.components.dictionary.pages;
package buttondevteam.presents.components.research.dictionary.pages;
import com.sun.net.httpserver.HttpExchange;

View file

@ -1,4 +1,4 @@
package buttondevteam.presents.components.dictionary.pages;
package buttondevteam.presents.components.research.dictionary.pages;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

View file

@ -1,4 +1,4 @@
package buttondevteam.presents.components.dictionary.pages;
package buttondevteam.presents.components.research.dictionary.pages;
import org.bukkit.Location;
import org.bukkit.entity.Player;

View file

@ -1,4 +1,4 @@
package buttondevteam.presents.components.dictionary.pages;
package buttondevteam.presents.components.research.dictionary.pages;
import java.io.IOException;

View file

@ -1,4 +1,4 @@
package buttondevteam.presents.components.dictionary.pages;
package buttondevteam.presents.components.research.dictionary.pages;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

View file

@ -1,4 +1,4 @@
package buttondevteam.presents.components.dictionary.spawning;
package buttondevteam.presents.components.research.dictionary.spawning;
import org.bukkit.Sound;
import org.bukkit.entity.Player;

View file

@ -1,4 +1,4 @@
package buttondevteam.presents.components.dictionary.spawning;
package buttondevteam.presents.components.research.dictionary.spawning;
import org.bukkit.Material;
import org.bukkit.block.Block;

View file

@ -1,4 +1,4 @@
package buttondevteam.presents.components.dictionary.spawning;
package buttondevteam.presents.components.research.dictionary.spawning;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;

View file

@ -1,4 +1,4 @@
package buttondevteam.presents.components.dictionary.spawning;
package buttondevteam.presents.components.research.dictionary.spawning;
import org.bukkit.Material;
import org.bukkit.entity.Player;

View file

@ -1,4 +1,4 @@
package buttondevteam.presents.components.dictionary.spawning;
package buttondevteam.presents.components.research.dictionary.spawning;
import java.util.ArrayList;

View file

@ -1,4 +1,4 @@
package buttondevteam.presents.components.dictionary.spawning;
package buttondevteam.presents.components.research.dictionary.spawning;
import org.bukkit.Particle;
import org.bukkit.entity.Player;

View file

@ -23,12 +23,12 @@ public class OverflowCrash extends Question {
@Override
public boolean OnCommand(Player player, String alias, String[] args) {
// TODO Auto-generated method stub
player.sendMessage(question());
String overflowMessage = "";
for (int i = 0; i < 100; i++){
overflowMessage += "Did you ever hear the tragedy of Darth Plagueis The Wise? I thought not. Its not a story the Jedi would tell you. Its a Sith legend. Darth Plagueis was a Dark Lord of the Sith, so powerful and so wise he could use the Force to influence the midichlorians to create life… He had such a knowledge of the dark side that he could even keep the ones he cared about from dying. The dark side of the Force is a pathway to many abilities some consider to be unnatural. He became so powerful… the only thing he was afraid of was losing his power, which eventually, of course, he did. Unfortunately, he taught his apprentice everything he knew, then his apprentice killed him in his sleep. Ironic. He could save others from death, but not himself.";
}
player.sendMessage(overflowMessage);
player.sendMessage(question());
player.sendMessage(answer());
return false;
}

View file

@ -23,10 +23,10 @@ public class OverwhelmCrash extends Question {
@Override
public boolean OnCommand(Player player, String alias, String[] args) {
// TODO Auto-generated method stub
player.sendMessage(question());
for (int x = 0; x < 500; x++){
player.sendMessage("Hello World Motherfucker!");
}
player.sendMessage(question());
player.sendMessage(answer());
return false;
}

View file

@ -27,22 +27,47 @@ public class PluginConfigInfo extends Question {
player.sendMessage("---Plugin's Config Information---");
FileConfiguration config = this.getPlugin().getConfig();
player.sendMessage("Name:");
player.sendMessage(" - " + config.getName());
if (args.length >= 1){
switch(args[0].toLowerCase()){
case "name":
player.sendMessage("Name:");
player.sendMessage(" - " + config.getName());
break;
case "path":
player.sendMessage("Current Path:");
player.sendMessage(" - " + config.getCurrentPath());
break;
case "root_name":
player.sendMessage("Name of Root:");
player.sendMessage(" - " + config.getRoot().getName());
break;
player.sendMessage("Current Path:");
player.sendMessage(" - " + config.getCurrentPath());
case "root_path":
player.sendMessage("Path of Root:");
player.sendMessage(" - " + config.getRoot().getCurrentPath());
break;
case "root_key":
case "root_keys":
player.sendMessage("Keys of Root (Deep = true)");
player.sendMessage(" - " + config.getRoot().getKeys(true).toString());
break;
case "answer":
player.sendMessage("[A]:" + this.answer());
break;
default:
player.sendMessage("Usage: " + this.GetCommandPath() + "<subcommand>");
player.sendMessage("Subcommands = name, path, root_name, root_path, root_keys, answer");
}
}else{ //args.length <= 0
player.sendMessage("Usage: " + this.GetCommandPath() + "<subcommand>");
player.sendMessage("Subcommands = name, path, root_name, root_path, root_keys, answer");
}
player.sendMessage("Name of Root:");
player.sendMessage(" - " + config.getRoot().getName());
//player.sendMessage("Path of Root:");
//player.sendMessage(" - " + config.getRoot().getCurrentPath());
//player.sendMessage("Keys of Root (Deep = true)");
//player.sendMessage(" - " + config.getRoot().getKeys(true).toString());
player.sendMessage("[A]:" + this.answer());
return false;
}

View file

@ -1,37 +1,34 @@
package buttondevteam.presents.components.spawn;
import org.bukkit.Server;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import buttondevteam.lib.chat.CommandClass;
import buttondevteam.presents.architecture.commands.UniversalCommand;
import buttondevteam.presents.architecture.commands.PlayerCommand;
@CommandClass(modOnly = false, path="spawn choosecolor")
public class ChooseColor extends UniversalCommand {
@CommandClass(modOnly = true, path="spawn choosecolor")
public class ChooseColor extends PlayerCommand {
@Override
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
if (!(sender instanceof BlockCommandSender)){
sender.sendMessage("You must be a command block to use this command!");
return false;
}
public boolean OnCommand(Player player, String alias, String[] args) {
// //Code to make it so that command blocks can fire this command
//
// if (!(sender instanceof BlockCommandSender)){
// sender.sendMessage("You must be a command block to use this command!");
// return false;
// }
//
// Server server = sender.getServer();
// server.broadcastMessage("Arg 0:" + args[0]);
// server.broadcastMessage("Arg 1:" + args[1]);
Server server = sender.getServer();
server.broadcastMessage("Arg 0:" + args[0]);
server.broadcastMessage("Arg 1:" + args[1]);
Player player = server.getPlayer(args[0]);
if (player != null){
player.sendMessage("Attempting to change your name "+player.getName()+" to the color...");
player.sendMessage(args[1]);
player.sendMessage("Your new name: " +player.getName());
}else{
server.broadcastMessage("Error: Player is null");
}
player.sendMessage("Attempting to change your name "+player.getName()+" to the color..."+args[1]);
//TODO:INSERT NAME CHANGING CODE HERE
player.sendMessage("Your new name: " +player.getName());
server.broadcastMessage("ENDOFCOMMAND");
return true;
}

View file

@ -5,7 +5,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.presents.architecture.Component;
public class SpawnComponent extends Component{
@Override
public void register(JavaPlugin plugin) {
this.registerCommand(plugin, new ChooseColor());

View file

@ -1,4 +1,4 @@
main: buttondevteam.presents.Main
main: buttondevteam.presents.ButtonPresents
name: ButtonPresents
version: 0.0.1