Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ly-nxs committed Mar 1, 2024
1 parent de5ce2a commit da147d6
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 32 deletions.
1 change: 1 addition & 0 deletions .idea/artifacts/skyblockplugin_jar.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed builds/skyblockplugin.jar
Binary file not shown.
32 changes: 16 additions & 16 deletions src/com/lynx/skyblocktp/commands/tpcommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

import static com.lynx.skyblocktp.config.loadChunk;
import static com.lynx.skyblocktp.skyblock.*;

public class tpcommand implements CommandExecutor {
Expand All @@ -22,23 +24,25 @@ public boolean onCommand(CommandSender sender, Command command, String s, String
Location location = new Location(player.getWorld(), x, y, z);
loadChunk(location);
sender.sendMessage("Creating new island");
for (int j = z; j < structure.length; j++) {
for (int k = y; k < structure[j].length; k++) {
for (int l = x; l < structure[j][l].length; l++) {
int xPos = location.getBlockX() + l - structure[j][k].length / 2;
int yPos = location.getBlockY() + k;
int zPos = location.getBlockZ() + j - structure[j].length / 2;
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++) {
int xPos = x + i;
int zPos = z + j;

Location grassLocation = new Location(player.getWorld(), xPos, y-3, zPos);
grassLocation.getBlock().setType(grass[i][j]);
Location grassLocation2 = new Location(player.getWorld(), xPos, y-2, zPos);
grassLocation2.getBlock().setType(grass[i][j]);
Location strLoc = new Location(player.getWorld(),xPos,y-1,zPos);
strLoc.getBlock().setType(str[i][j]);

Location blockLocation = new Location(player.getWorld(), xPos, yPos, zPos);
blockLocation.getBlock().setType(structure[j][k][l]);
}
}
}
loadChunk(location);
sender.sendMessage("Island is finished... teleporting");
player.teleport(location);
sender.sendMessage("Teleported!");
Location respawnLocation = new Location(player.getWorld(), x, y + 2, z);
player.setRespawnLocation(respawnLocation);
player.setRespawnLocation(location);
player.getInventory().addItem(new ItemStack(Material.LAVA_BUCKET, 1));
player.getInventory().addItem(new ItemStack(Material.ICE, 1));
int h = (int)(Math.random()*3)+1;
Expand All @@ -57,9 +61,5 @@ public boolean onCommand(CommandSender sender, Command command, String s, String
return true;
}

public static void loadChunk(Location location) {
if (!location.getChunk().isLoaded()) {
location.getChunk().load();
}
}

}
7 changes: 6 additions & 1 deletion src/com/lynx/skyblocktp/config.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static com.lynx.skyblocktp.skyblock.usedPlayers;
import java.io.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import static com.lynx.skyblocktp.skyblock.*;

Expand Down Expand Up @@ -59,7 +60,11 @@ public static void saveUsedPlayers() {
e.printStackTrace();
}
}

public static void loadChunk(Location location) {
if (!location.getChunk().isLoaded()) {
location.getChunk().load();
}
}
public static void loadUsedLocation() {
try {
FileReader reader = new FileReader("saveloc.txt");
Expand Down
29 changes: 14 additions & 15 deletions src/com/lynx/skyblocktp/skyblock.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.*;
import com.lynx.skyblocktp.config.*;

import static com.lynx.skyblocktp.config.*;

public class skyblock extends JavaPlugin {
public static int x = 0;
public static int y = 64;
public static int z = 0;
public static List<Player> usedPlayers = new ArrayList<>();
public static Material[][][] structure = {
{{Material.GRASS_BLOCK,Material.GRASS_BLOCK,Material.GRASS_BLOCK},
{Material.GRASS_BLOCK,Material.GRASS_BLOCK,Material.GRASS_BLOCK},
{Material.GRASS_BLOCK,Material.GRASS_BLOCK,Material.GRASS_BLOCK}},
{{Material.GRASS_BLOCK,Material.GRASS_BLOCK,Material.GRASS_BLOCK},
public static Material[][] grass = {
{Material.GRASS_BLOCK,Material.GRASS_BLOCK,Material.GRASS_BLOCK},
{Material.GRASS_BLOCK,Material.GRASS_BLOCK,Material.GRASS_BLOCK}},
{{Material.GRASS_BLOCK,Material.GRASS_BLOCK,Material.GRASS_BLOCK},
{Material.GRASS_BLOCK,Material.BEDROCK,Material.GRASS_BLOCK},
{Material.GRASS_BLOCK,Material.GRASS_BLOCK,Material.GRASS_BLOCK}},
{{Material.AIR,Material.CHEST,Material.AIR},
{Material.GRASS_BLOCK,Material.GRASS_BLOCK,Material.GRASS_BLOCK}
};
public static Material[][] str = {
{Material.AIR,Material.CHEST,Material.AIR},
{Material.AIR,Material.AIR,Material.AIR},
{Material.AIR,Material.OAK_SAPLING,Material.AIR}}
{Material.AIR,Material.OAK_SAPLING,Material.AIR}
};


Expand All @@ -33,9 +32,9 @@ public class skyblock extends JavaPlugin {
public void onEnable(){
getServer().getConsoleSender().sendMessage("SkyblockTP Enabled");
getCommand("skyblock").setExecutor(new tpcommand());
config.createFile();
config.loadUsedLocation();
config.loadUsedPlayers();
createFile();
loadUsedLocation();
loadUsedPlayers();
// check for saveloc.txt and usedplayers.txt, creating them if they don't exist
}

Expand All @@ -47,8 +46,8 @@ public void onEnable(){

@Override
public void onDisable(){
config.saveUsedLocation(x,y,z);
config.saveUsedPlayers();
saveUsedLocation(x,y,z);
saveUsedPlayers();
}

}

0 comments on commit da147d6

Please sign in to comment.