From bb87385d83be8053d652d9d96c8b21c3bf5e7c01 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 25 Aug 2019 03:36:30 +0200 Subject: [PATCH 1/7] Converted components and almost finished Towny-Factions --- plugin.yml | 32 +-- pom.xml | 191 ++++++++++-------- .../Factions/2.14.0/Factions-2.14.0.pom | 10 + .../Factions/maven-metadata-local.xml | 12 ++ .../MassiveCore/2.14.0/MassiveCore-2.14.0.pom | 10 + .../MassiveCore/maven-metadata-local.xml | 12 ++ .../presents/ButtonPresents.java | 21 +- .../buttondevteam/presents/StaticMain.java | 20 +- .../presents/architecture/Component.java | 76 ------- .../chunkarchive/ChunkArchiveComponent.java | 17 +- .../components/dungeon/DungeonComponent.java | 22 +- .../components/magic/MagicComponent.java | 48 ++--- .../research/ResearchComponent.java | 22 +- .../dictionary/DictionaryComponent.java | 71 +++---- .../components/spawn/SpawnComponent.java | 17 +- .../townyfactions/TownyFactionsComponent.java | 89 ++++++++ target/classes/plugin.yml | 32 +-- 17 files changed, 406 insertions(+), 296 deletions(-) create mode 100644 repo/com/massivecraft/Factions/2.14.0/Factions-2.14.0.pom create mode 100644 repo/com/massivecraft/Factions/maven-metadata-local.xml create mode 100644 repo/com/massivecraft/MassiveCore/2.14.0/MassiveCore-2.14.0.pom create mode 100644 repo/com/massivecraft/MassiveCore/maven-metadata-local.xml delete mode 100644 src/main/java/buttondevteam/presents/architecture/Component.java create mode 100644 src/main/java/buttondevteam/presents/components/townyfactions/TownyFactionsComponent.java diff --git a/plugin.yml b/plugin.yml index 77ab901..d2e613f 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,15 +1,17 @@ -main: buttondevteam.presents.ButtonPresents -name: ButtonPresents -version: 0.0.1 - -commands: - dictionary: - description: A set of Hello World commands and listeners, type in /hello to see subcommands - rtp: - description: A command that allows players to randomly teleport across the map - spawn: - description: A set of commands designed to be used in spawn - magic: - description: A set of fun commands designed for cheaty stuff - research: - description: A set of commands designed for R and D \ No newline at end of file +main: buttondevteam.presents.ButtonPresents +name: ButtonPresents +version: 0.0.1 + +commands: + dictionary: + description: A set of Hello World commands and listeners, type in /hello to see subcommands + rtp: + description: A command that allows players to randomly teleport across the map + spawn: + description: A set of commands designed to be used in spawn + magic: + description: A set of fun commands designed for cheaty stuff + research: + description: A set of commands designed for R and D + +softdepend: [Factions] diff --git a/pom.xml b/pom.xml index 04e47c4..aa3ffa1 100644 --- a/pom.xml +++ b/pom.xml @@ -1,86 +1,105 @@ - - 4.0.0 - - com.github.tbmcplugins - ButtonPresents - 0.0.1-SNAPSHOT - jar - - ButtonPresents - http://maven.apache.org - - - UTF-8 - - - - - src - - **/*.java - - - - . - - *.yml - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.0 - - 1.8 - 1.8 - - - - - - - spigot-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - - jcenter - http://jcenter.bintray.com - - - jitpack.io - https://jitpack.io - - - - - - org.apache.commons - commons-lang3 - 3.5 - - - org.spigotmc - spigot - 1.12.2-R0.1-SNAPSHOT - - - com.github.TBMCPlugins.ButtonCore - ButtonCore - master-SNAPSHOT - - - com.github.tbmcplugins - ButtonWebsiteModule - master-SNAPSHOT - - - junit - junit - 3.8.1 - test - - - + + 4.0.0 + + com.github.tbmcplugins + ButtonPresents + 0.0.1-SNAPSHOT + jar + + ButtonPresents + http://maven.apache.org + + + UTF-8 + + + + + src + + **/*.java + + + + . + + *.yml + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.0 + + 1.8 + 1.8 + + + + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + jcenter + http://jcenter.bintray.com + + + jitpack.io + https://jitpack.io + + + repo + file://${basedir}/repo + + + + + + org.apache.commons + commons-lang3 + 3.5 + + + org.spigotmc + spigot + 1.12.2-R0.1-SNAPSHOT + + + com.github.TBMCPlugins.ButtonCore + ButtonCore + master-SNAPSHOT + + + com.github.tbmcplugins + ButtonWebsiteModule + master-SNAPSHOT + + + com.massivecraft + Factions + 2.14.0 + + + com.massivecraft + MassiveCore + 2.14.0 + + + com.github.TBMCPlugins.ButtonCore + Towny + master-SNAPSHOT + + + junit + junit + 3.8.1 + test + + + diff --git a/repo/com/massivecraft/Factions/2.14.0/Factions-2.14.0.pom b/repo/com/massivecraft/Factions/2.14.0/Factions-2.14.0.pom new file mode 100644 index 0000000..51f1166 --- /dev/null +++ b/repo/com/massivecraft/Factions/2.14.0/Factions-2.14.0.pom @@ -0,0 +1,10 @@ + + + 4.0.0 + com.massivecraft + Factions + 2.14.0 + POM was created from install:install-file + diff --git a/repo/com/massivecraft/Factions/maven-metadata-local.xml b/repo/com/massivecraft/Factions/maven-metadata-local.xml new file mode 100644 index 0000000..4379776 --- /dev/null +++ b/repo/com/massivecraft/Factions/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + com.massivecraft + Factions + + 2.14.0 + + 2.14.0 + + 20190824204629 + + diff --git a/repo/com/massivecraft/MassiveCore/2.14.0/MassiveCore-2.14.0.pom b/repo/com/massivecraft/MassiveCore/2.14.0/MassiveCore-2.14.0.pom new file mode 100644 index 0000000..e79c625 --- /dev/null +++ b/repo/com/massivecraft/MassiveCore/2.14.0/MassiveCore-2.14.0.pom @@ -0,0 +1,10 @@ + + + 4.0.0 + com.massivecraft + MassiveCore + 2.14.0 + POM was created from install:install-file + diff --git a/repo/com/massivecraft/MassiveCore/maven-metadata-local.xml b/repo/com/massivecraft/MassiveCore/maven-metadata-local.xml new file mode 100644 index 0000000..4d6cf23 --- /dev/null +++ b/repo/com/massivecraft/MassiveCore/maven-metadata-local.xml @@ -0,0 +1,12 @@ + + + com.massivecraft + MassiveCore + + 2.14.0 + + 2.14.0 + + 20190824204534 + + diff --git a/src/main/java/buttondevteam/presents/ButtonPresents.java b/src/main/java/buttondevteam/presents/ButtonPresents.java index 65be054..e6451ef 100644 --- a/src/main/java/buttondevteam/presents/ButtonPresents.java +++ b/src/main/java/buttondevteam/presents/ButtonPresents.java @@ -1,10 +1,12 @@ package buttondevteam.presents; +import buttondevteam.lib.architecture.Component; import buttondevteam.presents.components.chunkarchive.ChunkArchiveComponent; import buttondevteam.presents.components.magic.MagicComponent; import buttondevteam.presents.components.research.ResearchComponent; import buttondevteam.presents.components.research.dictionary.DictionaryComponent; import buttondevteam.presents.components.spawn.SpawnComponent; +import buttondevteam.presents.components.townyfactions.TownyFactionsComponent; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; @@ -17,13 +19,18 @@ public class ButtonPresents extends JavaPlugin{ Logger logger = getLogger(); logger.info(pdfFile.getName() + " has been started (V." + pdfFile.getVersion()+ ")."); - - - new DictionaryComponent().register(this); - new SpawnComponent().register(this); - new MagicComponent().register(this); - new ResearchComponent().register(this); - new ChunkArchiveComponent().register(this); + + + Component.registerComponent(this, new DictionaryComponent()); + Component.registerComponent(this, new SpawnComponent()); + Component.registerComponent(this, new MagicComponent()); + Component.registerComponent(this, new ResearchComponent()); + try { + Component.registerComponent(this, new ChunkArchiveComponent()); + } catch (NoClassDefFoundError e) { + getLogger().warning("ChunkArchive compatibility error, not registering it."); + } + Component.registerComponent(this, new TownyFactionsComponent()); logger.info(pdfFile.getName() + " has fully registered (V." + pdfFile.getVersion()+ ")."); } diff --git a/src/main/java/buttondevteam/presents/StaticMain.java b/src/main/java/buttondevteam/presents/StaticMain.java index 2b8d7b3..4c589f2 100644 --- a/src/main/java/buttondevteam/presents/StaticMain.java +++ b/src/main/java/buttondevteam/presents/StaticMain.java @@ -1,14 +1,24 @@ package buttondevteam.presents; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - public class StaticMain { public static void main(String[] args){ - GsonBuilder builder = new GsonBuilder(); + /*GsonBuilder builder = new GsonBuilder(); Gson gson = builder.create(); - System.out.println(gson.toJson(new output())); + System.out.println(gson.toJson(new output()));*/ + + int distance = 5; + for (int i = -distance; i <= distance; i++) { + for (int j = -distance; j <= distance; j++) { + //if(i*i+j*j<=distance*distance) { + double dist = Math.sqrt(Math.pow((double) (i), 2.0D) + Math.pow((double) (j), 2.0D)); + if (dist < distance) { + System.out.print("X"); + } else + System.out.print("-"); + } + System.out.println(); + } } static class output{ public String ali = "pls"; diff --git a/src/main/java/buttondevteam/presents/architecture/Component.java b/src/main/java/buttondevteam/presents/architecture/Component.java deleted file mode 100644 index 9d6d055..0000000 --- a/src/main/java/buttondevteam/presents/architecture/Component.java +++ /dev/null @@ -1,76 +0,0 @@ -package buttondevteam.presents.architecture; - -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.event.Listener; -import org.bukkit.plugin.java.JavaPlugin; - -import buttondevteam.lib.TBMCCoreAPI; -import buttondevteam.lib.chat.TBMCChatAPI; -import buttondevteam.lib.chat.TBMCCommandBase; -import buttondevteam.website.ButtonWebsiteModule; -import buttondevteam.website.page.Page; - -/** - * A Module class allows the compacting of projects into one single package. - * - * Each feature can have its commands and listeners coded into the Module class, - * as well as any other pointers to memory units, or other classes in the package. - * - * This package can then be moved from eclipse project to eclipse project smoothly, - * as long as the destination project has the Module abstract class, and as long as all dependencies are either - * contained in the moved package, or moved along with it. - * @author Alisolarflare - * - */ -public abstract class Component{ - /** - * Registers the module, when called by the JavaPlugin class. Call - * registerCommand() and registerListener() within this method. - * - * @param plugin Plugin class called to register commands and listeners - */ - public abstract void register(JavaPlugin plugin); - /** - * Registers a TBMCCommand to the plugin - * @param plugin Main plugin responsible for stuff - * @param label Name of the command in plugin.yml - * @param commandExecutor Custom coded CommandExecutor class - */ - protected void registerCommand(JavaPlugin plugin, TBMCCommandBase commandBase){ - TBMCChatAPI.AddCommand(plugin, commandBase); - //plugin.getCommand(commandBase.getClass().getSimpleName().toString()).setExecutor(commandBase); - } - /** - * Registers a Listener to this plugin - * @param plugin Main plugin responsible for stuff - * @param label Name of the command in plugin.yml - * @param commandExecutor Custom coded CommandExecutor class - */ - protected Listener registerListener(JavaPlugin plugin, Listener listener){ - TBMCCoreAPI.RegisterEventsForExceptions(listener, plugin); - return listener; - } - protected Page addPage(JavaPlugin plugin, Page page){ - ButtonWebsiteModule.addPage(page); - return page; - } - - public void saveData(FileConfiguration config, String pathToData, Object data){ - config.set("moduledata." + this.getClassName() + "." + pathToData, data); - } - public Object getData(FileConfiguration config, String pathToData, Object data){ - return config.get("moduledata." + this.getClassName() + "." + pathToData, data); - } - - public String getClassName(){ - Class enclosingClass = getClass().getEnclosingClass(); - String className = "nullModule"; - if (enclosingClass != null) { - className = (enclosingClass.getName()); - } else { - className = (getClass().getName()); - } - return className; - } - -} diff --git a/src/main/java/buttondevteam/presents/components/chunkarchive/ChunkArchiveComponent.java b/src/main/java/buttondevteam/presents/components/chunkarchive/ChunkArchiveComponent.java index 19cdff7..63fcd63 100644 --- a/src/main/java/buttondevteam/presents/components/chunkarchive/ChunkArchiveComponent.java +++ b/src/main/java/buttondevteam/presents/components/chunkarchive/ChunkArchiveComponent.java @@ -1,7 +1,8 @@ package buttondevteam.presents.components.chunkarchive; import buttondevteam.lib.TBMCCoreAPI; -import buttondevteam.presents.architecture.Component; +import buttondevteam.lib.architecture.Component; +import buttondevteam.presents.ButtonPresents; import net.minecraft.server.v1_12_R1.ChunkRegionLoader; import net.minecraft.server.v1_12_R1.ExceptionWorldConflict; import org.bukkit.Bukkit; @@ -11,22 +12,21 @@ import org.bukkit.craftbukkit.v1_12_R1.CraftWorld; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.world.ChunkPopulateEvent; -import org.bukkit.plugin.java.JavaPlugin; import java.io.File; import java.io.IOException; import java.util.logging.Logger; // @formatter:off -public class ChunkArchiveComponent extends Component implements Listener { +public class ChunkArchiveComponent extends Component implements Listener { private final File dataFolder = new File("plugins", "ChunkArchive"); @Override - public void register(JavaPlugin plugin) { + public void enable() { try { - this.registerListener(plugin, this); + this.registerListener(this); File testFolder = new File(dataFolder, "test"); testFolder.mkdirs(); - Logger logger = plugin.getLogger(); + Logger logger = getPlugin().getLogger(); logger.info("Starting chunk save test..."); ChunkRegionLoader testcrl = new ChunkRegionLoader(testFolder, ((CraftServer) Bukkit.getServer()).getServer().dataConverterManager); @@ -39,6 +39,11 @@ public class ChunkArchiveComponent extends Component implements Listener { TBMCCoreAPI.SendException("ChunkArchive loading/testing failed!", e); } } + + @Override + protected void disable() { + + } /*------------------------------------------------------------*/ private final ChunkRegionLoader chunkRegionLoader = diff --git a/src/main/java/buttondevteam/presents/components/dungeon/DungeonComponent.java b/src/main/java/buttondevteam/presents/components/dungeon/DungeonComponent.java index 88c5502..295df29 100644 --- a/src/main/java/buttondevteam/presents/components/dungeon/DungeonComponent.java +++ b/src/main/java/buttondevteam/presents/components/dungeon/DungeonComponent.java @@ -1,16 +1,20 @@ package buttondevteam.presents.components.dungeon; -import org.bukkit.plugin.java.JavaPlugin; +import buttondevteam.lib.architecture.Component; +import buttondevteam.presents.ButtonPresents; -import buttondevteam.presents.architecture.Component; - -public class DungeonComponent extends Component{ +public class DungeonComponent extends Component { @Override - public void register(JavaPlugin plugin) { - this.registerCommand(plugin, new DungeonCreate()); - this.registerCommand(plugin, new DungeonDelete()); - + public void enable() { + this.registerCommand(new DungeonCreate()); + this.registerCommand(new DungeonDelete()); + } - + + @Override + protected void disable() { + + } + } diff --git a/src/main/java/buttondevteam/presents/components/magic/MagicComponent.java b/src/main/java/buttondevteam/presents/components/magic/MagicComponent.java index 64c17e3..923cf96 100644 --- a/src/main/java/buttondevteam/presents/components/magic/MagicComponent.java +++ b/src/main/java/buttondevteam/presents/components/magic/MagicComponent.java @@ -1,23 +1,25 @@ -package buttondevteam.presents.components.magic; - -import org.bukkit.plugin.java.JavaPlugin; - -import buttondevteam.presents.architecture.Component; -import buttondevteam.presents.components.magic.tricks.AliArrowListener; -import buttondevteam.presents.components.magic.tricks.BoomBowDeathListener; -import buttondevteam.presents.components.magic.tricks.BoomBowListener; -import buttondevteam.presents.components.magic.tricks.CannonBowListener; -import buttondevteam.presents.components.magic.tricks.CannonBowSettings; - - -public class MagicComponent extends Component{ - - @Override - public void register(JavaPlugin plugin) { - registerCommand(plugin, new CannonBowSettings()); - registerListener(plugin, new AliArrowListener(plugin)); - registerListener(plugin, new BoomBowDeathListener()); - registerListener(plugin, new BoomBowListener(plugin)); - registerListener(plugin, new CannonBowListener(plugin)); - } -} +package buttondevteam.presents.components.magic; + +import buttondevteam.lib.architecture.Component; +import buttondevteam.presents.ButtonPresents; +import buttondevteam.presents.components.magic.tricks.*; +import org.bukkit.plugin.java.JavaPlugin; + + +public class MagicComponent extends Component { + + @Override + public void enable() { + JavaPlugin plugin = getPlugin(); + registerCommand(new CannonBowSettings()); + registerListener(new AliArrowListener(plugin)); + registerListener(new BoomBowDeathListener()); + registerListener(new BoomBowListener(plugin)); + registerListener(new CannonBowListener(plugin)); + } + + @Override + protected void disable() { + + } +} diff --git a/src/main/java/buttondevteam/presents/components/research/ResearchComponent.java b/src/main/java/buttondevteam/presents/components/research/ResearchComponent.java index 08a1d28..0a2ab37 100644 --- a/src/main/java/buttondevteam/presents/components/research/ResearchComponent.java +++ b/src/main/java/buttondevteam/presents/components/research/ResearchComponent.java @@ -1,22 +1,26 @@ package buttondevteam.presents.components.research; -import org.bukkit.plugin.java.JavaPlugin; - -import buttondevteam.presents.architecture.Component; +import buttondevteam.lib.architecture.Component; +import buttondevteam.presents.ButtonPresents; import buttondevteam.presents.components.research.questions.OverflowCrash; import buttondevteam.presents.components.research.questions.OverwhelmCrash; import buttondevteam.presents.components.research.questions.PluginConfigInfo; import buttondevteam.presents.components.research.questions.PluginDataFolderInfo; -public class ResearchComponent extends Component { +public class ResearchComponent extends Component { @Override - public void register(JavaPlugin plugin) { + public void enable() { // TODO Auto-generated method stub - this.registerCommand(plugin, new PluginConfigInfo()); - this.registerCommand(plugin, new PluginDataFolderInfo()); - this.registerCommand(plugin, new OverwhelmCrash()); - this.registerCommand(plugin, new OverflowCrash()); + this.registerCommand(new PluginConfigInfo()); + this.registerCommand(new PluginDataFolderInfo()); + this.registerCommand(new OverwhelmCrash()); + this.registerCommand(new OverflowCrash()); + + } + + @Override + protected void disable() { } diff --git a/src/main/java/buttondevteam/presents/components/research/dictionary/DictionaryComponent.java b/src/main/java/buttondevteam/presents/components/research/dictionary/DictionaryComponent.java index 0fb7a16..14df597 100644 --- a/src/main/java/buttondevteam/presents/components/research/dictionary/DictionaryComponent.java +++ b/src/main/java/buttondevteam/presents/components/research/dictionary/DictionaryComponent.java @@ -1,51 +1,46 @@ package buttondevteam.presents.components.research.dictionary; -import org.bukkit.plugin.java.JavaPlugin; - -import buttondevteam.presents.architecture.Component; +import buttondevteam.lib.architecture.Component; +import buttondevteam.presents.ButtonPresents; import buttondevteam.presents.components.research.dictionary.commands.SendJSON; import buttondevteam.presents.components.research.dictionary.commands.SendMessage; import buttondevteam.presents.components.research.dictionary.config.LoadConfig; import buttondevteam.presents.components.research.dictionary.config.SaveConfig; import buttondevteam.presents.components.research.dictionary.config.TimePersistence; import buttondevteam.presents.components.research.dictionary.effects.Bedsplode; -import buttondevteam.presents.components.research.dictionary.pages.DataPage; -import buttondevteam.presents.components.research.dictionary.pages.HelloPage; -import buttondevteam.presents.components.research.dictionary.pages.JSONPage; -import buttondevteam.presents.components.research.dictionary.pages.LocationPage; -import buttondevteam.presents.components.research.dictionary.pages.POSTPage; -import buttondevteam.presents.components.research.dictionary.pages.PlayersOnlinePage; -import buttondevteam.presents.components.research.dictionary.spawning.PlaySound; -import buttondevteam.presents.components.research.dictionary.spawning.SetBlock; -import buttondevteam.presents.components.research.dictionary.spawning.SpawnCow; -import buttondevteam.presents.components.research.dictionary.spawning.SpawnItem; -import buttondevteam.presents.components.research.dictionary.spawning.SpawnMagicPotato; -import buttondevteam.presents.components.research.dictionary.spawning.SpawnParticle; +import buttondevteam.presents.components.research.dictionary.spawning.*; +import org.bukkit.plugin.java.JavaPlugin; -public class DictionaryComponent extends Component{ +public class DictionaryComponent extends Component { @Override - public void register(JavaPlugin plugin) { - - this.registerCommand(plugin, new SendMessage()); - this.registerCommand(plugin, new SendJSON()); - this.registerCommand(plugin, new SaveConfig()); - this.registerCommand(plugin, new LoadConfig()); - this.registerCommand(plugin, new TimePersistence()); - - this.registerListener(plugin, new Bedsplode()); - this.registerCommand(plugin, new SpawnCow()); - this.registerCommand(plugin, new SpawnItem()); - this.registerCommand(plugin, new SpawnMagicPotato()); - this.registerCommand(plugin, new SetBlock()); - this.registerCommand(plugin, new SpawnParticle()); - this.registerCommand(plugin, new PlaySound()); - - this.addPage(plugin, new HelloPage()); - this.addPage(plugin, new DataPage()); - this.addPage(plugin, new PlayersOnlinePage(plugin)); - this.addPage(plugin, new LocationPage(plugin)); - this.addPage(plugin, new POSTPage(plugin)); - this.addPage(plugin, new JSONPage()); + public void enable() { + JavaPlugin plugin = getPlugin(); + + this.registerCommand(new SendMessage()); + this.registerCommand(new SendJSON()); + this.registerCommand(new SaveConfig()); + this.registerCommand(new LoadConfig()); + this.registerCommand(new TimePersistence()); + + this.registerListener(new Bedsplode()); + this.registerCommand(new SpawnCow()); + this.registerCommand(new SpawnItem()); + this.registerCommand(new SpawnMagicPotato()); + this.registerCommand(new SetBlock()); + this.registerCommand(new SpawnParticle()); + this.registerCommand(new PlaySound()); + + /*ButtonWebsiteModule.addPage(new HelloPage()); + ButtonWebsiteModule.addPage(new DataPage()); + ButtonWebsiteModule.addPage(new PlayersOnlinePage(plugin)); + ButtonWebsiteModule.addPage(new LocationPage(plugin)); + ButtonWebsiteModule.addPage(new POSTPage(plugin)); + ButtonWebsiteModule.addPage(new JSONPage());*/ + } + + @Override + protected void disable() { + } } diff --git a/src/main/java/buttondevteam/presents/components/spawn/SpawnComponent.java b/src/main/java/buttondevteam/presents/components/spawn/SpawnComponent.java index 69793bd..d4273b2 100644 --- a/src/main/java/buttondevteam/presents/components/spawn/SpawnComponent.java +++ b/src/main/java/buttondevteam/presents/components/spawn/SpawnComponent.java @@ -1,15 +1,18 @@ package buttondevteam.presents.components.spawn; -import org.bukkit.plugin.java.JavaPlugin; +import buttondevteam.lib.architecture.Component; +import buttondevteam.presents.ButtonPresents; -import buttondevteam.presents.architecture.Component; - -public class SpawnComponent extends Component{ +public class SpawnComponent extends Component { @Override - public void register(JavaPlugin plugin) { - this.registerCommand(plugin, new ChooseColor()); - + public void enable() { + this.registerCommand(new ChooseColor()); + } + + @Override + protected void disable() { + } } diff --git a/src/main/java/buttondevteam/presents/components/townyfactions/TownyFactionsComponent.java b/src/main/java/buttondevteam/presents/components/townyfactions/TownyFactionsComponent.java new file mode 100644 index 0000000..f09e221 --- /dev/null +++ b/src/main/java/buttondevteam/presents/components/townyfactions/TownyFactionsComponent.java @@ -0,0 +1,89 @@ +package buttondevteam.presents.components.townyfactions; + +import buttondevteam.lib.architecture.Component; +import buttondevteam.lib.architecture.ConfigData; +import buttondevteam.presents.ButtonPresents; +import com.massivecraft.factions.entity.BoardColl; +import com.massivecraft.factions.event.EventFactionsChunksChange; +import com.massivecraft.massivecore.ps.PS; +import com.palmergames.bukkit.towny.event.TownPreClaimEvent; +import com.palmergames.bukkit.towny.exceptions.NotRegisteredException; +import com.palmergames.bukkit.towny.object.Coord; +import com.palmergames.bukkit.towny.object.TownyUniverse; +import com.palmergames.bukkit.towny.object.WorldCoord; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +public class TownyFactionsComponent extends Component implements Listener { + @Override + public void enable() { + registerListener(this); + } + + @Override + protected void disable() { + + } + + /** + * Defines how many chunks should be between towns and factions + */ + private ConfigData distance() { + return getConfig().getData("distance", 5); + } + + @EventHandler + public void onFactionsClaim(EventFactionsChunksChange event) throws NotRegisteredException { + if (event.getNewFaction().isNone()) + return; //Allow unclaiming + for (PS chunk : event.getChunks()) { + int x = chunk.getChunkX() * 16; + int z = chunk.getChunkZ() * 16; + int size = Coord.getCellSize(); + int amount = size / 16; + World world = chunk.asBukkitWorld(); + int max = 0; + for (int i = 0; i < amount; i++) { + for (int j = 0; j < amount; j++) { + Coord coord = Coord.parseCoord(new Location(world, x + i * size, 64, z + j * size)); + int dist = TownyUniverse.getDataSource().getWorld(world.getName()) + .getMinDistanceFromOtherTownsPlots(coord); + if (dist > max) max = dist; + } + } + int distance = max * amount; + if (distance().get() >= distance) { + event.setCancelled(true); + event.getSender().sendMessage("§cYou are too close to a town!"); + } + } + } + + @EventHandler + public void onTownyClaim(TownPreClaimEvent event) { + PS chunkCoord = PS.valueOf(getLocation(event.getTownBlock().getWorldCoord())).getChunkCoords(true); + int distance = distance().get(); + for (int i = -distance; i <= distance; i++) { + for (int j = -distance; j <= distance; j++) { + if (i * i + j * j <= distance * distance) { + PS chunk = PS.valueOf(chunkCoord.getChunkX() + i, chunkCoord.getChunkZ() + j) + .withWorld(chunkCoord.getWorld()); //TODO: Doesn't have the world for some reason + if (!BoardColl.get().getFactionAt(chunk).isNone()) { + event.setCancelled(true); + } + } + } + } + } + + //https://github.com/TownyAdvanced/Towny/blob/master/src/com/palmergames/bukkit/towny/tasks/DrawSmokeTask.java + + private Location getLocation(WorldCoord coord) { //Based on parseCoord() - needfix would be always false because the remainder is 0 + int cellSize = Coord.getCellSize(); + int xresult = coord.getX() * cellSize; + int zresult = coord.getZ() * cellSize; + return new Location(coord.getBukkitWorld(), xresult, 64, zresult); + } +} diff --git a/target/classes/plugin.yml b/target/classes/plugin.yml index 77ab901..d2e613f 100644 --- a/target/classes/plugin.yml +++ b/target/classes/plugin.yml @@ -1,15 +1,17 @@ -main: buttondevteam.presents.ButtonPresents -name: ButtonPresents -version: 0.0.1 - -commands: - dictionary: - description: A set of Hello World commands and listeners, type in /hello to see subcommands - rtp: - description: A command that allows players to randomly teleport across the map - spawn: - description: A set of commands designed to be used in spawn - magic: - description: A set of fun commands designed for cheaty stuff - research: - description: A set of commands designed for R and D \ No newline at end of file +main: buttondevteam.presents.ButtonPresents +name: ButtonPresents +version: 0.0.1 + +commands: + dictionary: + description: A set of Hello World commands and listeners, type in /hello to see subcommands + rtp: + description: A command that allows players to randomly teleport across the map + spawn: + description: A set of commands designed to be used in spawn + magic: + description: A set of fun commands designed for cheaty stuff + research: + description: A set of commands designed for R and D + +softdepend: [Factions] -- 2.30.2 From 4d3838caa7a321f6877e3c25b21c266c6428eb23 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Mon, 26 Aug 2019 00:59:27 +0200 Subject: [PATCH 2/7] Fix Towny claim check and depend on the Core --- plugin.yml | 1 + .../components/townyfactions/TownyFactionsComponent.java | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/plugin.yml b/plugin.yml index d2e613f..5dd8f6a 100644 --- a/plugin.yml +++ b/plugin.yml @@ -15,3 +15,4 @@ commands: description: A set of commands designed for R and D softdepend: [Factions] +depend: [ButtonCore] \ No newline at end of file diff --git a/src/main/java/buttondevteam/presents/components/townyfactions/TownyFactionsComponent.java b/src/main/java/buttondevteam/presents/components/townyfactions/TownyFactionsComponent.java index f09e221..b6cda94 100644 --- a/src/main/java/buttondevteam/presents/components/townyfactions/TownyFactionsComponent.java +++ b/src/main/java/buttondevteam/presents/components/townyfactions/TownyFactionsComponent.java @@ -63,13 +63,13 @@ public class TownyFactionsComponent extends Component implements @EventHandler public void onTownyClaim(TownPreClaimEvent event) { - PS chunkCoord = PS.valueOf(getLocation(event.getTownBlock().getWorldCoord())).getChunkCoords(true); + PS coord = PS.valueOf(getLocation(event.getTownBlock().getWorldCoord())); int distance = distance().get(); for (int i = -distance; i <= distance; i++) { for (int j = -distance; j <= distance; j++) { if (i * i + j * j <= distance * distance) { - PS chunk = PS.valueOf(chunkCoord.getChunkX() + i, chunkCoord.getChunkZ() + j) - .withWorld(chunkCoord.getWorld()); //TODO: Doesn't have the world for some reason + PS chunk = PS.valueOf(coord.getChunkX(true) + i, coord.getChunkZ(true) + j) + .withWorld(coord.getWorld()); if (!BoardColl.get().getFactionAt(chunk).isNone()) { event.setCancelled(true); } -- 2.30.2 From aa8d8a3028c5309ec4cd645695ddda2595572e95 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Tue, 27 Aug 2019 02:54:28 +0200 Subject: [PATCH 3/7] Adding distance in the message --- plugin.yml | 2 +- .../components/townyfactions/TownyFactionsComponent.java | 2 +- target/classes/plugin.yml | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/plugin.yml b/plugin.yml index 5dd8f6a..af04016 100644 --- a/plugin.yml +++ b/plugin.yml @@ -15,4 +15,4 @@ commands: description: A set of commands designed for R and D softdepend: [Factions] -depend: [ButtonCore] \ No newline at end of file +depend: [ChromaCore] \ No newline at end of file diff --git a/src/main/java/buttondevteam/presents/components/townyfactions/TownyFactionsComponent.java b/src/main/java/buttondevteam/presents/components/townyfactions/TownyFactionsComponent.java index b6cda94..ad9ebb5 100644 --- a/src/main/java/buttondevteam/presents/components/townyfactions/TownyFactionsComponent.java +++ b/src/main/java/buttondevteam/presents/components/townyfactions/TownyFactionsComponent.java @@ -56,7 +56,7 @@ public class TownyFactionsComponent extends Component implements int distance = max * amount; if (distance().get() >= distance) { event.setCancelled(true); - event.getSender().sendMessage("§cYou are too close to a town!"); + event.getSender().sendMessage("§cYou are too close to a town! " + distance + " chunks away, " + distance().get() + " is allowed."); } } } diff --git a/target/classes/plugin.yml b/target/classes/plugin.yml index d2e613f..af04016 100644 --- a/target/classes/plugin.yml +++ b/target/classes/plugin.yml @@ -15,3 +15,4 @@ commands: description: A set of commands designed for R and D softdepend: [Factions] +depend: [ChromaCore] \ No newline at end of file -- 2.30.2 From ba0042311b2a3e2e05d24f03d3029bd3d92ccb1a Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 21 Sep 2019 22:16:44 +0200 Subject: [PATCH 4/7] Made Towny-Factions work for... not just 16x16 plots Math is hard TBMCPlugins/PluginConfigs#68 --- .../townyfactions/TownyFactionsComponent.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/buttondevteam/presents/components/townyfactions/TownyFactionsComponent.java b/src/main/java/buttondevteam/presents/components/townyfactions/TownyFactionsComponent.java index ad9ebb5..986467c 100644 --- a/src/main/java/buttondevteam/presents/components/townyfactions/TownyFactionsComponent.java +++ b/src/main/java/buttondevteam/presents/components/townyfactions/TownyFactionsComponent.java @@ -34,7 +34,7 @@ public class TownyFactionsComponent extends Component implements return getConfig().getData("distance", 5); } - @EventHandler + @EventHandler(ignoreCancelled = true) public void onFactionsClaim(EventFactionsChunksChange event) throws NotRegisteredException { if (event.getNewFaction().isNone()) return; //Allow unclaiming @@ -42,9 +42,10 @@ public class TownyFactionsComponent extends Component implements int x = chunk.getChunkX() * 16; int z = chunk.getChunkZ() * 16; int size = Coord.getCellSize(); - int amount = size / 16; + int amount = 16 / size; World world = chunk.asBukkitWorld(); int max = 0; + if (amount < 1) amount = 1; //For plot sizes > 16 for (int i = 0; i < amount; i++) { for (int j = 0; j < amount; j++) { Coord coord = Coord.parseCoord(new Location(world, x + i * size, 64, z + j * size)); @@ -53,15 +54,15 @@ public class TownyFactionsComponent extends Component implements if (dist > max) max = dist; } } - int distance = max * amount; + int distance = max / amount; if (distance().get() >= distance) { event.setCancelled(true); - event.getSender().sendMessage("§cYou are too close to a town! " + distance + " chunks away, " + distance().get() + " is allowed."); + event.getSender().sendMessage("§cYou are too close to a town! " + (distance - 1) + " chunks away, " + distance().get() + " is allowed."); } } } - @EventHandler + @EventHandler(ignoreCancelled = true) public void onTownyClaim(TownPreClaimEvent event) { PS coord = PS.valueOf(getLocation(event.getTownBlock().getWorldCoord())); int distance = distance().get(); -- 2.30.2 From 648518d5b6f99fd4f79e31637994788d6448414a Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 21 Sep 2019 22:43:26 +0200 Subject: [PATCH 5/7] Allow claiming town plots in the same chunk Off by one error --- .../components/townyfactions/TownyFactionsComponent.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/buttondevteam/presents/components/townyfactions/TownyFactionsComponent.java b/src/main/java/buttondevteam/presents/components/townyfactions/TownyFactionsComponent.java index 986467c..5a49d14 100644 --- a/src/main/java/buttondevteam/presents/components/townyfactions/TownyFactionsComponent.java +++ b/src/main/java/buttondevteam/presents/components/townyfactions/TownyFactionsComponent.java @@ -66,8 +66,8 @@ public class TownyFactionsComponent extends Component implements public void onTownyClaim(TownPreClaimEvent event) { PS coord = PS.valueOf(getLocation(event.getTownBlock().getWorldCoord())); int distance = distance().get(); - for (int i = -distance; i <= distance; i++) { - for (int j = -distance; j <= distance; j++) { + for (int i = -distance + 1; i <= distance - 1; i++) { + for (int j = -distance + 1; j <= distance - 1; j++) { if (i * i + j * j <= distance * distance) { PS chunk = PS.valueOf(coord.getChunkX(true) + i, coord.getChunkZ(true) + j) .withWorld(coord.getWorld()); -- 2.30.2 From 226dbc8c77092ae27c507e13962c2bcbf2b85ca1 Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 22 Sep 2019 00:54:27 +0200 Subject: [PATCH 6/7] Add portal limiter - simply disallow certain worlds --- .../presents/ButtonPresents.java | 2 + .../portals/PortalLimitComponent.java | 40 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/main/java/buttondevteam/presents/components/portals/PortalLimitComponent.java diff --git a/src/main/java/buttondevteam/presents/ButtonPresents.java b/src/main/java/buttondevteam/presents/ButtonPresents.java index e6451ef..715dad9 100644 --- a/src/main/java/buttondevteam/presents/ButtonPresents.java +++ b/src/main/java/buttondevteam/presents/ButtonPresents.java @@ -3,6 +3,7 @@ package buttondevteam.presents; import buttondevteam.lib.architecture.Component; import buttondevteam.presents.components.chunkarchive.ChunkArchiveComponent; import buttondevteam.presents.components.magic.MagicComponent; +import buttondevteam.presents.components.portals.PortalLimitComponent; import buttondevteam.presents.components.research.ResearchComponent; import buttondevteam.presents.components.research.dictionary.DictionaryComponent; import buttondevteam.presents.components.spawn.SpawnComponent; @@ -31,6 +32,7 @@ public class ButtonPresents extends JavaPlugin{ getLogger().warning("ChunkArchive compatibility error, not registering it."); } Component.registerComponent(this, new TownyFactionsComponent()); + Component.registerComponent(this, new PortalLimitComponent()); logger.info(pdfFile.getName() + " has fully registered (V." + pdfFile.getVersion()+ ")."); } diff --git a/src/main/java/buttondevteam/presents/components/portals/PortalLimitComponent.java b/src/main/java/buttondevteam/presents/components/portals/PortalLimitComponent.java new file mode 100644 index 0000000..ef358c9 --- /dev/null +++ b/src/main/java/buttondevteam/presents/components/portals/PortalLimitComponent.java @@ -0,0 +1,40 @@ +package buttondevteam.presents.components.portals; + +import buttondevteam.lib.architecture.Component; +import buttondevteam.lib.architecture.ConfigData; +import buttondevteam.presents.ButtonPresents; +import com.google.common.collect.Lists; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.entity.EntityPortalEvent; +import org.bukkit.event.player.PlayerPortalEvent; + +import java.util.List; + +public class PortalLimitComponent extends Component implements Listener { + @Override + protected void enable() { + registerListener(this); + } + + @Override + protected void disable() { + + } + + private ConfigData> worlds() { + return getConfig().getData("worlds", Lists.newArrayList("v1", "v2", "v3")); + } + + @EventHandler(ignoreCancelled = true) + public void onPortalEnter(PlayerPortalEvent event) { + if (worlds().get().contains(event.getFrom().getWorld().getName())) + event.setCancelled(true); + } + + @EventHandler(ignoreCancelled = true) + public void onPortalEnter(EntityPortalEvent event) { + if (worlds().get().contains(event.getFrom().getWorld().getName())) + event.setCancelled(true); + } +} -- 2.30.2 From af0c34b66e04dd384561257c2e6964c1e809dffb Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sun, 27 Oct 2019 23:28:44 +0100 Subject: [PATCH 7/7] Update Factions deps --- .idea/.gitignore | 2 + .idea/ButtonPresents.iml | 22 ++++ .idea/compiler.xml | 16 +++ .idea/encodings.xml | 6 + .idea/inspectionProfiles/Project_Default.xml | 11 ++ .idea/misc.xml | 5 + .idea/modules.xml | 8 ++ .idea/uiDesigner.xml | 124 ++++++++++++++++++ .idea/vcs.xml | 6 + pom.xml | 4 +- .../Factions/3.2.2/Factions-3.2.2.jar | Bin 0 -> 763895 bytes .../Factions-3.2.2.pom} | 2 +- .../Factions/maven-metadata-local.xml | 5 +- .../MassiveCore/3.2.2/MassiveCore-3.2.2.jar | Bin 0 -> 1384554 bytes .../MassiveCore-3.2.2.pom} | 2 +- .../MassiveCore/maven-metadata-local.xml | 5 +- 16 files changed, 210 insertions(+), 8 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/ButtonPresents.iml create mode 100644 .idea/compiler.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/uiDesigner.xml create mode 100644 .idea/vcs.xml create mode 100644 repo/com/massivecraft/Factions/3.2.2/Factions-3.2.2.jar rename repo/com/massivecraft/Factions/{2.14.0/Factions-2.14.0.pom => 3.2.2/Factions-3.2.2.pom} (93%) create mode 100644 repo/com/massivecraft/MassiveCore/3.2.2/MassiveCore-3.2.2.jar rename repo/com/massivecraft/MassiveCore/{2.14.0/MassiveCore-2.14.0.pom => 3.2.2/MassiveCore-3.2.2.pom} (93%) diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..5c98b42 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml \ No newline at end of file diff --git a/.idea/ButtonPresents.iml b/.idea/ButtonPresents.iml new file mode 100644 index 0000000..8b9a7fb --- /dev/null +++ b/.idea/ButtonPresents.iml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..4b65c14 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..b26911b --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..4f1aeda --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,11 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 9896aeb..37b940b 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,10 @@ + + + + +