Set writer to non-static

This commit is contained in:
alisolarflare 2017-04-02 04:35:30 -04:00
parent 12038a6158
commit 016aa2f857
5 changed files with 36 additions and 25 deletions

View file

@ -4,7 +4,7 @@ import java.util.logging.Logger;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.minecraft.place.Place;
import buttondevteam.minecraft.place.PlaceComponent;
@ -15,7 +15,7 @@ public class Main extends JavaPlugin{
Logger logger = getLogger();
logger.info(pdfFile.getName() + " has been started (V." + pdfFile.getVersion()+ ").");
new Place().register(this);
new PlaceComponent().register(this);
logger.info(pdfFile.getName() + " has fully registered (V." + pdfFile.getVersion()+ ").");

View file

@ -1,15 +0,0 @@
package buttondevteam.minecraft.place;
import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.architecture.Component;
import buttondevteam.minecraft.place.commands.Cube;
public class Place extends Component{
@Override
public void register(JavaPlugin plugin) {
this.registerCommand(plugin, new Cube());
}
}

View file

@ -0,0 +1,23 @@
package buttondevteam.minecraft.place;
import org.bukkit.plugin.java.JavaPlugin;
import buttondevteam.architecture.Component;
import buttondevteam.minecraft.place.commands.Cube;
public class PlaceComponent extends Component{
public Writer writer;
public Reader reader;
public Translator translator;
@Override
public void register(JavaPlugin plugin) {
this.registerCommand(plugin, new Cube(this));
this.writer = new Writer();
this.reader = new Reader();
this.translator = new Translator();
}
}

View file

@ -6,18 +6,18 @@ import org.bukkit.World;
public class Writer {
public static int cubeSize = 4;
public static void hardWrite(Location location, Material material){
public int cubeSize = 4;
public void hardWrite(Location location, Material material){
writeCube(
location.getBlockX() - location.getBlockX() % cubeSize,
location.getBlockX() - (location.getBlockX() % cubeSize),
location.getBlockY(),
location.getBlockZ() - location.getBlockZ() % cubeSize,
location.getBlockZ() - (location.getBlockZ() % cubeSize),
location.getWorld(),
material);
}
public static void writeCube(int x, int y, int z, World world, Material material){
public void writeCube(int x, int y, int z, World world, Material material){
for(int i = 0; i > cubeSize; i++){
for (int j = 0; j > cubeSize; j++){
for(int k = 0; k > cubeSize; k++){

View file

@ -4,16 +4,19 @@ import org.bukkit.Material;
import org.bukkit.entity.Player;
import buttondevteam.architecture.commands.ModCommand;
import buttondevteam.minecraft.place.Writer;
import buttondevteam.minecraft.place.PlaceComponent;
//Tests the Writer's hardWrite method
public class Cube extends ModCommand{
PlaceComponent place;
public Cube(PlaceComponent place){
this.place = place;
}
@Override
public boolean OnCommand(Player player, String alias, String[] args) {
player.sendMessage("Writing Cube...");
Writer.hardWrite(player.getLocation(), Material.LEAVES);
place.writer.hardWrite(player.getLocation(), Material.LEAVES);
player.sendMessage("Cube Written!");
return true;
}