Set writer to non-static
This commit is contained in:
parent
12038a6158
commit
016aa2f857
5 changed files with 36 additions and 25 deletions
|
@ -4,7 +4,7 @@ import java.util.logging.Logger;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
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 logger = getLogger();
|
||||||
logger.info(pdfFile.getName() + " has been started (V." + pdfFile.getVersion()+ ").");
|
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()+ ").");
|
logger.info(pdfFile.getName() + " has fully registered (V." + pdfFile.getVersion()+ ").");
|
||||||
|
|
||||||
|
|
|
@ -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());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -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();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -6,18 +6,18 @@ import org.bukkit.World;
|
||||||
|
|
||||||
public class Writer {
|
public class Writer {
|
||||||
|
|
||||||
public static int cubeSize = 4;
|
public int cubeSize = 4;
|
||||||
public static void hardWrite(Location location, Material material){
|
public void hardWrite(Location location, Material material){
|
||||||
writeCube(
|
writeCube(
|
||||||
location.getBlockX() - location.getBlockX() % cubeSize,
|
location.getBlockX() - (location.getBlockX() % cubeSize),
|
||||||
location.getBlockY(),
|
location.getBlockY(),
|
||||||
location.getBlockZ() - location.getBlockZ() % cubeSize,
|
location.getBlockZ() - (location.getBlockZ() % cubeSize),
|
||||||
location.getWorld(),
|
location.getWorld(),
|
||||||
material);
|
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 i = 0; i > cubeSize; i++){
|
||||||
for (int j = 0; j > cubeSize; j++){
|
for (int j = 0; j > cubeSize; j++){
|
||||||
for(int k = 0; k > cubeSize; k++){
|
for(int k = 0; k > cubeSize; k++){
|
||||||
|
|
|
@ -4,16 +4,19 @@ import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import buttondevteam.architecture.commands.ModCommand;
|
import buttondevteam.architecture.commands.ModCommand;
|
||||||
import buttondevteam.minecraft.place.Writer;
|
import buttondevteam.minecraft.place.PlaceComponent;
|
||||||
|
|
||||||
|
|
||||||
//Tests the Writer's hardWrite method
|
//Tests the Writer's hardWrite method
|
||||||
public class Cube extends ModCommand{
|
public class Cube extends ModCommand{
|
||||||
|
PlaceComponent place;
|
||||||
|
public Cube(PlaceComponent place){
|
||||||
|
this.place = place;
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean OnCommand(Player player, String alias, String[] args) {
|
public boolean OnCommand(Player player, String alias, String[] args) {
|
||||||
player.sendMessage("Writing Cube...");
|
player.sendMessage("Writing Cube...");
|
||||||
Writer.hardWrite(player.getLocation(), Material.LEAVES);
|
place.writer.hardWrite(player.getLocation(), Material.LEAVES);
|
||||||
player.sendMessage("Cube Written!");
|
player.sendMessage("Cube Written!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue