mirror of
https://github.com/songoda/EpicHoppers.git
synced 2025-01-25 09:01:35 +01:00
Lots of code cleaned up.
Started work on a module API.
This commit is contained in:
parent
ef08449afb
commit
d9a492c9ff
@ -1,6 +1,6 @@
|
||||
package com.songoda.epichoppers.api.hopper.levels;
|
||||
|
||||
import com.songoda.epichoppers.api.hopper.levels.modules.ModuleAbstract;
|
||||
import com.songoda.epichoppers.api.hopper.levels.modules.Module;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -69,7 +69,7 @@ public interface Level {
|
||||
|
||||
List<String> getDescription();
|
||||
|
||||
ArrayList<ModuleAbstract> getRegisteredModules();
|
||||
ArrayList<Module> getRegisteredModules();
|
||||
|
||||
void addModule(ModuleAbstract module);
|
||||
void addModule(Module module);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.songoda.epichoppers.api.hopper.levels;
|
||||
|
||||
import com.songoda.epichoppers.api.hopper.levels.modules.ModuleAbstract;
|
||||
import com.songoda.epichoppers.api.hopper.levels.modules.Module;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
@ -20,7 +20,7 @@ public interface LevelManager {
|
||||
* @param filter Whether or not access to the filter is allowed.
|
||||
* @param teleport Whether or not teleporting through hoppers is allowed.
|
||||
*/
|
||||
void addLevel(int level, int costExperience, int costEconomy, int range, int amount, boolean filter, boolean teleport, ArrayList<ModuleAbstract> modules);
|
||||
void addLevel(int level, int costExperience, int costEconomy, int range, int amount, boolean filter, boolean teleport, ArrayList<Module> modules);
|
||||
|
||||
/**
|
||||
* Get {@link Level} by corresponding integer value.
|
||||
|
@ -5,7 +5,7 @@ import org.bukkit.Material;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ModuleAbstract {
|
||||
public interface Module {
|
||||
|
||||
String getName();
|
||||
|
@ -9,7 +9,7 @@ import com.songoda.epichoppers.api.EpicHoppersAPI;
|
||||
import com.songoda.epichoppers.api.hopper.*;
|
||||
import com.songoda.epichoppers.api.hopper.levels.Level;
|
||||
import com.songoda.epichoppers.api.hopper.levels.LevelManager;
|
||||
import com.songoda.epichoppers.api.hopper.levels.modules.ModuleAbstract;
|
||||
import com.songoda.epichoppers.api.hopper.levels.modules.Module;
|
||||
import com.songoda.epichoppers.api.utils.ClaimableProtectionPluginHook;
|
||||
import com.songoda.epichoppers.api.utils.ProtectionPluginHook;
|
||||
import com.songoda.epichoppers.boost.BoostData;
|
||||
@ -46,7 +46,6 @@ import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
@ -267,7 +266,7 @@ public class EpicHoppersPlugin extends JavaPlugin implements EpicHoppers {
|
||||
int costExperiance = levels.getInt("Cost-xp");
|
||||
int costEconomy = levels.getInt("Cost-eco");
|
||||
|
||||
ArrayList<ModuleAbstract> modules = new ArrayList<>();
|
||||
ArrayList<Module> modules = new ArrayList<>();
|
||||
|
||||
for (String key : levels.getKeys(false)) {
|
||||
if (key.equals("Suction") && levels.getInt("Suction") != 0) {
|
||||
|
@ -2,18 +2,14 @@ package com.songoda.epichoppers.handlers;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.api.hopper.levels.modules.ModuleAbstract;
|
||||
import com.songoda.epichoppers.api.hopper.levels.modules.Module;
|
||||
import com.songoda.epichoppers.boost.BoostData;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Hopper;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.inventory.*;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -82,7 +78,7 @@ public class HopHandler {
|
||||
|
||||
List<Material> materials = new ArrayList<>();
|
||||
|
||||
for (ModuleAbstract module : hopper.getLevel().getRegisteredModules()) {
|
||||
for (Module module : hopper.getLevel().getRegisteredModules()) {
|
||||
|
||||
// Run Module
|
||||
module.run(hopper);
|
||||
@ -90,7 +86,6 @@ public class HopHandler {
|
||||
// Add banned materials to list.
|
||||
if (module.getBlockedItems(hopper) == null) continue;
|
||||
materials.addAll(module.getBlockedItems(hopper));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,14 +2,14 @@ package com.songoda.epichoppers.hopper.levels;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.api.hopper.levels.Level;
|
||||
import com.songoda.epichoppers.api.hopper.levels.modules.ModuleAbstract;
|
||||
import com.songoda.epichoppers.api.hopper.levels.modules.Module;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ELevel implements Level {
|
||||
|
||||
private final ArrayList<ModuleAbstract> registeredModules;
|
||||
private final ArrayList<Module> registeredModules;
|
||||
|
||||
private int level, costExperience, costEconomy, range, amount;
|
||||
|
||||
@ -17,7 +17,7 @@ public class ELevel implements Level {
|
||||
|
||||
private final List<String> description = new ArrayList<>();
|
||||
|
||||
ELevel(int level, int costExperience, int costEconomy, int range, int amount, boolean filter, boolean teleport, ArrayList<ModuleAbstract> registeredModules) {
|
||||
ELevel(int level, int costExperience, int costEconomy, int range, int amount, boolean filter, boolean teleport, ArrayList<Module> registeredModules) {
|
||||
this.level = level;
|
||||
this.costExperience = costExperience;
|
||||
this.costEconomy = costEconomy;
|
||||
@ -34,7 +34,7 @@ public class ELevel implements Level {
|
||||
if (filter) description.add(instance.getLocale().getMessage("interface.hopper.filter", true));
|
||||
if (teleport) description.add(instance.getLocale().getMessage("interface.hopper.teleport", true));
|
||||
|
||||
for (ModuleAbstract module : registeredModules) {
|
||||
for (Module module : registeredModules) {
|
||||
description.add(module.getDescription());
|
||||
}
|
||||
|
||||
@ -81,12 +81,12 @@ public class ELevel implements Level {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ModuleAbstract> getRegisteredModules() {
|
||||
public ArrayList<Module> getRegisteredModules() {
|
||||
return new ArrayList<>(registeredModules);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addModule(ModuleAbstract module) {
|
||||
public void addModule(Module module) {
|
||||
registeredModules.add(module);
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package com.songoda.epichoppers.hopper.levels;
|
||||
|
||||
import com.songoda.epichoppers.api.hopper.levels.Level;
|
||||
import com.songoda.epichoppers.api.hopper.levels.LevelManager;
|
||||
import com.songoda.epichoppers.api.hopper.levels.modules.ModuleAbstract;
|
||||
import com.songoda.epichoppers.api.hopper.levels.modules.Module;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -11,7 +11,7 @@ public class ELevelManager implements LevelManager {
|
||||
private final NavigableMap<Integer, ELevel> registeredLevels = new TreeMap<>();
|
||||
|
||||
@Override
|
||||
public void addLevel(int level, int costExperience, int costEconomy, int range, int amount, boolean filter, boolean teleport, ArrayList<ModuleAbstract> modules) {
|
||||
public void addLevel(int level, int costExperience, int costEconomy, int range, int amount, boolean filter, boolean teleport, ArrayList<Module> modules) {
|
||||
registeredLevels.put(level, new ELevel(level, costExperience, costEconomy, range, amount, filter, teleport, modules));
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package com.songoda.epichoppers.hopper.levels.modules;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.api.hopper.Hopper;
|
||||
import com.songoda.epichoppers.api.hopper.levels.modules.ModuleAbstract;
|
||||
import com.songoda.epichoppers.api.hopper.levels.modules.Module;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@ -16,7 +16,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ModuleAutoCrafting implements ModuleAbstract {
|
||||
public class ModuleAutoCrafting implements Module {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -3,7 +3,7 @@ package com.songoda.epichoppers.hopper.levels.modules;
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.api.hopper.Hopper;
|
||||
import com.songoda.epichoppers.api.hopper.levels.modules.ModuleAbstract;
|
||||
import com.songoda.epichoppers.api.hopper.levels.modules.Module;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -13,7 +13,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ModuleBlockBreak implements ModuleAbstract {
|
||||
public class ModuleBlockBreak implements Module {
|
||||
|
||||
private Map<Block, Integer> blockTick = new HashMap<>();
|
||||
|
||||
|
@ -3,7 +3,7 @@ package com.songoda.epichoppers.hopper.levels.modules;
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppersPlugin;
|
||||
import com.songoda.epichoppers.api.hopper.Hopper;
|
||||
import com.songoda.epichoppers.api.hopper.levels.modules.ModuleAbstract;
|
||||
import com.songoda.epichoppers.api.hopper.levels.modules.Module;
|
||||
import com.songoda.epichoppers.utils.Debugger;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
@ -16,7 +16,7 @@ import org.bukkit.metadata.FixedMetadataValue;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class ModuleSuction implements ModuleAbstract {
|
||||
public class ModuleSuction implements Module {
|
||||
|
||||
private final int amount;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user