This commit is contained in:
jascotty2 2019-10-04 15:13:43 -05:00
commit 1d8b4fa032
4 changed files with 51 additions and 10 deletions

View File

@ -4,7 +4,7 @@ stages:
variables: variables:
name: "EpicFarming" name: "EpicFarming"
path: "/builds/$CI_PROJECT_PATH" path: "/builds/$CI_PROJECT_PATH"
version: "2.3.1" version: "2.3.2"
build: build:
stage: build stage: build

View File

@ -34,6 +34,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -115,18 +116,32 @@ public class EpicFarming extends SongodaPlugin {
/* /*
* Register Farms into FarmManger from configuration * Register Farms into FarmManger from configuration
*/ */
Bukkit.getScheduler().runTaskLater(this, () -> { Bukkit.getScheduler().runTaskLaterAsynchronously(this, () -> {
if (storage.containsGroup("farms")) { if (storage.containsGroup("farms")) {
for (StorageRow row : storage.getRowsByGroup("farms")) { for (StorageRow row : storage.getRowsByGroup("farms")) {
Location location = Methods.unserializeLocation(row.getKey()); Location location = Methods.unserializeLocation(row.getKey());
if (location == null || location.getWorld() == null) return; if (location == null || location.getWorld() == null) continue;
int level = row.get("level").asInt(); int level = 1;
List<ItemStack> items = row.get("contents").asItemStackList(); int configLevel = row.get("level").asInt();
UUID placedBY = UUID.fromString(row.get("placedby").asString()); if (configLevel != 0 && configLevel > 0) {
level = configLevel;
}
List<ItemStack> items = new ArrayList<ItemStack>();
List<ItemStack> configItems = row.get("contents").asItemStackList();
if (configItems != null && configItems.size() > 0) {
items = configItems;
}
UUID placedBY = null;
String configPlacedBY = row.get("placedby").asString();
if (configPlacedBY != null) {
placedBY = UUID.fromString(configPlacedBY);
}
Farm farm = new Farm(location, levelManager.getLevel(level), placedBY); Farm farm = new Farm(location, levelManager.getLevel(level), placedBY);
farm.setItems(items); farm.setItems(items);
farmManager.addFarm(location, farm); Bukkit.getScheduler().runTask(EpicFarming.getInstance(), () -> {
farmManager.addFarm(location, farm);
});
} }
} }
@ -141,7 +156,9 @@ public class EpicFarming extends SongodaPlugin {
Long.parseLong(row.getKey()), Long.parseLong(row.getKey()),
UUID.fromString(row.get("player").asString())); UUID.fromString(row.get("player").asString()));
this.boostManager.addBoostToPlayer(boostData); Bukkit.getScheduler().runTask(EpicFarming.getInstance(), () -> {
this.boostManager.addBoostToPlayer(boostData);
});
} }
} }

View File

@ -8,6 +8,8 @@ import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
public class CommandBoost extends AbstractCommand { public class CommandBoost extends AbstractCommand {
@ -55,7 +57,18 @@ public class CommandBoost extends AbstractCommand {
} }
@Override @Override
protected List<String> onTab(CommandSender commandSender, String... strings) { protected List<String> onTab(CommandSender sender, String... args) {
if (args.length == 1) {
List<String> players = new ArrayList<>();
for (Player player : Bukkit.getOnlinePlayers()) {
players.add(player.getName());
}
return players;
} else if (args.length == 2) {
return Arrays.asList("1", "2", "3", "4", "5");
} else if (args.length == 3) {
return Arrays.asList("1m", "1h", "1d");
}
return null; return null;
} }

View File

@ -7,6 +7,8 @@ import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
public class CommandGiveFarmItem extends AbstractCommand { public class CommandGiveFarmItem extends AbstractCommand {
@ -55,7 +57,16 @@ public class CommandGiveFarmItem extends AbstractCommand {
} }
@Override @Override
protected List<String> onTab(CommandSender commandSender, String... strings) { protected List<String> onTab(CommandSender sender, String... args) {
if (args.length == 1) {
List<String> players = new ArrayList<>();
for (Player player : Bukkit.getOnlinePlayers()) {
players.add(player.getName());
}
return players;
} else if (args.length == 2) {
return Arrays.asList("1", "2", "3", "4", "5");
}
return null; return null;
} }