mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
[CI skip] Reduced technical debt
This commit is contained in:
parent
4dbc66fc4e
commit
e3dc17a9df
@ -181,17 +181,17 @@ public final class Script {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void upload(Player p, AndroidType androidType, int id, String name, String code) {
|
public static void upload(Player p, AndroidType androidType, int id, String name, String code) {
|
||||||
Config script = new Config("plugins/Slimefun/scripts/" + androidType.name() + '/' + p.getName() + ' ' + String.valueOf(id) + ".sfs");
|
Config config = new Config("plugins/Slimefun/scripts/" + androidType.name() + '/' + p.getName() + ' ' + String.valueOf(id) + ".sfs");
|
||||||
|
|
||||||
script.setValue("author", p.getUniqueId().toString());
|
config.setValue("author", p.getUniqueId().toString());
|
||||||
script.setValue("author_name", p.getName());
|
config.setValue("author_name", p.getName());
|
||||||
script.setValue("name", ChatUtils.removeColorCodes(name));
|
config.setValue("name", ChatUtils.removeColorCodes(name));
|
||||||
script.setValue("code", code);
|
config.setValue("code", code);
|
||||||
script.setValue("downloads", 0);
|
config.setValue("downloads", 0);
|
||||||
script.setValue("android", androidType.name());
|
config.setValue("android", androidType.name());
|
||||||
script.setValue("rating.positive", new ArrayList<String>());
|
config.setValue("rating.positive", new ArrayList<String>());
|
||||||
script.setValue("rating.negative", new ArrayList<String>());
|
config.setValue("rating.negative", new ArrayList<String>());
|
||||||
script.save();
|
config.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public abstract class GEOMiner extends AContainer implements InventoryBlock, Rec
|
|||||||
private static final int[] OUTPUT_BORDER = { 19, 20, 21, 22, 23, 24, 25, 28, 34, 37, 43, 46, 47, 48, 49, 50, 51, 52 };
|
private static final int[] OUTPUT_BORDER = { 19, 20, 21, 22, 23, 24, 25, 28, 34, 37, 43, 46, 47, 48, 49, 50, 51, 52 };
|
||||||
private static final int[] OUTPUT_SLOTS = { 29, 30, 31, 32, 33, 38, 39, 40, 41, 42 };
|
private static final int[] OUTPUT_SLOTS = { 29, 30, 31, 32, 33, 38, 39, 40, 41, 42 };
|
||||||
private static final int PROCESSING_TIME = 14;
|
private static final int PROCESSING_TIME = 14;
|
||||||
|
|
||||||
public GEOMiner(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
public GEOMiner(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||||
super(category, item, recipeType, recipe);
|
super(category, item, recipeType, recipe);
|
||||||
|
|
||||||
@ -152,22 +152,25 @@ public abstract class GEOMiner extends AContainer implements InventoryBlock, Rec
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tick(Block b) {
|
protected void tick(Block b) {
|
||||||
BlockMenu menu = BlockStorage.getInventory(b);
|
BlockMenu inv = BlockStorage.getInventory(b);
|
||||||
|
|
||||||
if (isProcessing(b)) {
|
if (isProcessing(b)) {
|
||||||
int timeleft = progress.get(b);
|
int timeleft = progress.get(b);
|
||||||
|
|
||||||
if (timeleft > 0) {
|
if (timeleft > 0) {
|
||||||
ChestMenuUtils.updateProgressbar(menu, 4, timeleft, processing.get(b).getTicks(), getProgressBar());
|
ChestMenuUtils.updateProgressbar(inv, 4, timeleft, processing.get(b).getTicks(), getProgressBar());
|
||||||
|
|
||||||
|
if (ChargableBlock.getCharge(b) < getEnergyConsumption()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
|
|
||||||
ChargableBlock.addCharge(b, -getEnergyConsumption());
|
ChargableBlock.addCharge(b, -getEnergyConsumption());
|
||||||
|
|
||||||
progress.put(b, timeleft - 1);
|
progress.put(b, timeleft - 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
menu.replaceExistingItem(4, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "));
|
inv.replaceExistingItem(4, new CustomItem(new ItemStack(Material.BLACK_STAINED_GLASS_PANE), " "));
|
||||||
menu.pushItem(processing.get(b).getOutput()[0], getOutputSlots());
|
inv.pushItem(processing.get(b).getOutput()[0], getOutputSlots());
|
||||||
|
|
||||||
progress.remove(b);
|
progress.remove(b);
|
||||||
processing.remove(b);
|
processing.remove(b);
|
||||||
@ -177,34 +180,38 @@ public abstract class GEOMiner extends AContainer implements InventoryBlock, Rec
|
|||||||
SimpleHologram.update(b, "&4GEO-Scan required!");
|
SimpleHologram.update(b, "&4GEO-Scan required!");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (GEOResource resource : SlimefunPlugin.getRegistry().getGEOResources().values()) {
|
start(b, inv);
|
||||||
if (resource.isObtainableFromGEOMiner()) {
|
|
||||||
OptionalInt optional = SlimefunPlugin.getGPSNetwork().getResourceManager().getSupplies(resource, b.getWorld(), b.getX() >> 4, b.getZ() >> 4);
|
|
||||||
|
|
||||||
if (!optional.isPresent()) {
|
|
||||||
SimpleHologram.update(b, "&4GEO-Scan required!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int supplies = optional.getAsInt();
|
|
||||||
|
|
||||||
if (supplies > 0) {
|
|
||||||
MachineRecipe r = new MachineRecipe(PROCESSING_TIME / getSpeed(), new ItemStack[0], new ItemStack[] { resource.getItem().clone() });
|
|
||||||
if (!menu.fits(r.getOutput()[0], getOutputSlots())) return;
|
|
||||||
|
|
||||||
processing.put(b, r);
|
|
||||||
progress.put(b, r.getTicks());
|
|
||||||
SlimefunPlugin.getGPSNetwork().getResourceManager().setSupplies(resource, b.getWorld(), b.getX() >> 4, b.getZ() >> 4, supplies - 1);
|
|
||||||
SimpleHologram.update(b, "&7Mining: &r" + resource.getName());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SimpleHologram.update(b, "&7Finished");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void start(Block b, BlockMenu inv) {
|
||||||
|
for (GEOResource resource : SlimefunPlugin.getRegistry().getGEOResources().values()) {
|
||||||
|
if (resource.isObtainableFromGEOMiner()) {
|
||||||
|
OptionalInt optional = SlimefunPlugin.getGPSNetwork().getResourceManager().getSupplies(resource, b.getWorld(), b.getX() >> 4, b.getZ() >> 4);
|
||||||
|
|
||||||
|
if (!optional.isPresent()) {
|
||||||
|
SimpleHologram.update(b, "&4GEO-Scan required!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int supplies = optional.getAsInt();
|
||||||
|
if (supplies > 0) {
|
||||||
|
MachineRecipe r = new MachineRecipe(PROCESSING_TIME / getSpeed(), new ItemStack[0], new ItemStack[] { resource.getItem().clone() });
|
||||||
|
|
||||||
|
if (!inv.fits(r.getOutput()[0], getOutputSlots())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
processing.put(b, r);
|
||||||
|
progress.put(b, r.getTicks());
|
||||||
|
SlimefunPlugin.getGPSNetwork().getResourceManager().setSupplies(resource, b.getWorld(), b.getX() >> 4, b.getZ() >> 4, supplies - 1);
|
||||||
|
SimpleHologram.update(b, "&7Mining: &r" + resource.getName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SimpleHologram.update(b, "&7Finished");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -88,13 +88,19 @@ public class AncientAltarListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Optional<Block> blockOptional = e.getClickedBlock();
|
Optional<Block> blockOptional = e.getClickedBlock();
|
||||||
if (!blockOptional.isPresent()) return;
|
if (!blockOptional.isPresent()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Block b = blockOptional.get();
|
Block b = blockOptional.get();
|
||||||
if (b.getType() != Material.ENCHANTING_TABLE && b.getType() != Material.DISPENSER) return;
|
if (b.getType() != Material.ENCHANTING_TABLE && b.getType() != Material.DISPENSER) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Optional<SlimefunItem> slimefunBlock = e.getSlimefunBlock();
|
Optional<SlimefunItem> slimefunBlock = e.getSlimefunBlock();
|
||||||
if (!slimefunBlock.isPresent()) return;
|
if (!slimefunBlock.isPresent()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String id = slimefunBlock.get().getID();
|
String id = slimefunBlock.get().getID();
|
||||||
|
|
||||||
@ -124,7 +130,9 @@ public class AncientAltarListener implements Listener {
|
|||||||
Item stack = findItem(pedestal);
|
Item stack = findItem(pedestal);
|
||||||
|
|
||||||
if (stack == null) {
|
if (stack == null) {
|
||||||
if (p.getInventory().getItemInMainHand().getType() == Material.AIR) return;
|
if (p.getInventory().getItemInMainHand().getType() != Material.AIR) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (pedestal.getRelative(0, 1, 0).getType() != Material.AIR) {
|
if (pedestal.getRelative(0, 1, 0).getType() != Material.AIR) {
|
||||||
SlimefunPlugin.getLocal().sendMessage(p, "machines.ANCIENT_PEDESTAL.obstructed", true);
|
SlimefunPlugin.getLocal().sendMessage(p, "machines.ANCIENT_PEDESTAL.obstructed", true);
|
||||||
|
@ -33,7 +33,11 @@ public final class ReactorHologram {
|
|||||||
public static void update(Location l, String name) {
|
public static void update(Location l, String name) {
|
||||||
Slimefun.runSync(() -> {
|
Slimefun.runSync(() -> {
|
||||||
ArmorStand hologram = getArmorStand(l, true);
|
ArmorStand hologram = getArmorStand(l, true);
|
||||||
if (!hologram.isCustomNameVisible()) hologram.setCustomNameVisible(true);
|
|
||||||
|
if (!hologram.isCustomNameVisible()) {
|
||||||
|
hologram.setCustomNameVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
hologram.setCustomName(ChatColors.color(name));
|
hologram.setCustomName(ChatColors.color(name));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,10 @@ public final class SimpleHologram {
|
|||||||
public static void remove(Block b) {
|
public static void remove(Block b) {
|
||||||
Slimefun.runSync(() -> {
|
Slimefun.runSync(() -> {
|
||||||
ArmorStand hologram = getArmorStand(b, false);
|
ArmorStand hologram = getArmorStand(b, false);
|
||||||
if (hologram != null) hologram.remove();
|
|
||||||
|
if (hologram != null) {
|
||||||
|
hologram.remove();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user