mirror of
https://github.com/songoda/EpicHoppers.git
synced 2024-11-22 10:15:43 +01:00
1.13
This commit is contained in:
parent
fa9d46bede
commit
50cf216632
16
.gitignore
vendored
16
.gitignore
vendored
@ -1,8 +1,8 @@
|
||||
|
||||
out/
|
||||
|
||||
\.idea/
|
||||
/src/main/resources/META-INF/MANIFEST.MF
|
||||
/EpicHoppers.iml
|
||||
|
||||
target/
|
||||
|
||||
out/
|
||||
|
||||
\.idea/
|
||||
/src/main/resources/META-INF/MANIFEST.MF
|
||||
/EpicHoppers.iml
|
||||
|
||||
target/
|
||||
|
16
LICENSE
16
LICENSE
@ -1,9 +1,9 @@
|
||||
Copyright (c) 2018 Brianna O’Keefe
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software with minimal restriction, including the rights to use, copy, modify or merge while excluding the rights to publish, (re)distribute, sub-license, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The same distribution rights and limitations above shall similarly apply to any and all source code, and other means that can be used to emulate this work.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
Copyright (c) 2018 Brianna O’Keefe
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software with minimal restriction, including the rights to use, copy, modify or merge while excluding the rights to publish, (re)distribute, sub-license, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The same distribution rights and limitations above shall similarly apply to any and all source code, and other means that can be used to emulate this work.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@ -1,5 +1,5 @@
|
||||
# EpicHoppers
|
||||
|
||||
EpicHoppers is a plugin that both optimizes hoppers and adds new and intuitive/enjoyable functions to them.
|
||||
|
||||
# EpicHoppers
|
||||
|
||||
EpicHoppers is a plugin that both optimizes hoppers and adds new and intuitive/enjoyable functions to them.
|
||||
|
||||
![N|Solid](https://i.imgur.com/jKtE7ZM.png)
|
398
pom.xml
398
pom.xml
@ -1,200 +1,200 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>EpicHoppers</artifactId>
|
||||
<version>2.3.0</version>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
<build>
|
||||
<finalName>EpicHoppers</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>1.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jcenter</id>
|
||||
<url>http://jcenter.bintray.com</url>
|
||||
</repository>
|
||||
<!--Bukkit Repo-->
|
||||
<repository>
|
||||
<id>bukkit-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
<!--Songoda Repo-->
|
||||
<repository>
|
||||
<id>songoda-public</id>
|
||||
<url>http://repo.songoda.com/repository/songoda-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>songoda-private</id>
|
||||
<url>http://repo.songoda.com/repository/songoda-private/</url>
|
||||
</repository>
|
||||
<!--WorldGuard Repo-->
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>http://maven.sk89q.com/repo/</url>
|
||||
</repository>
|
||||
<!--Vault Repo-->
|
||||
<repository>
|
||||
<id>vault-repo</id>
|
||||
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
|
||||
</repository>
|
||||
<!--uSkyBlock Repo-->
|
||||
<repository>
|
||||
<id>uSkyBlock-mvn-repo</id>
|
||||
<url>https://raw.github.com/rlf/uSkyBlock/mvn-repo/</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<!--aAkyBlock Repo-->
|
||||
<repository>
|
||||
<id>bintray-tastybento-maven-repo</id>
|
||||
<name>bintray</name>
|
||||
<url>http://dl.bintray.com/tastybento/maven-repo</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<!--Bukkit API-->
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--Arconix API-->
|
||||
<dependency>
|
||||
<groupId>com.songoda.arconix</groupId>
|
||||
<artifactId>api</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda.arconix</groupId>
|
||||
<artifactId>plugin</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--WorldGuard API-->
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldguard</artifactId>
|
||||
<version>6.1.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--Vault API-->
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--Towny API-->
|
||||
<dependency>
|
||||
<groupId>com.palmergames</groupId>
|
||||
<artifactId>Towny</artifactId>
|
||||
<version>0.92.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--uSkyBlock API-->
|
||||
<dependency>
|
||||
<groupId>com.github.rlf</groupId>
|
||||
<artifactId>uSkyBlock-API</artifactId>
|
||||
<version>2.6.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--RedProtect API-->
|
||||
<dependency>
|
||||
<groupId>br.net.fabiozumbi12</groupId>
|
||||
<artifactId>RedProtect</artifactId>
|
||||
<version>7.3.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--PlotSquared API-->
|
||||
<dependency>
|
||||
<groupId>com.intellectualcrafters</groupId>
|
||||
<artifactId>PlotSquared</artifactId>
|
||||
<version>18.05.01</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--Kingdoms API-->
|
||||
<dependency>
|
||||
<groupId>org.kingdoms</groupId>
|
||||
<artifactId>Kingdoms</artifactId>
|
||||
<version>13.3.40</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--GriefPrevention API-->
|
||||
<dependency>
|
||||
<groupId>com.github.TechFortress</groupId>
|
||||
<artifactId>GriefPrevention</artifactId>
|
||||
<version>16.7.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--FactionsFramework API-->
|
||||
<dependency>
|
||||
<groupId>me.markeh</groupId>
|
||||
<artifactId>factionsframework</artifactId>
|
||||
<version>1.2.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--aSkyBlock API-->
|
||||
<dependency>
|
||||
<groupId>com.wasteofplastic</groupId>
|
||||
<artifactId>askyblock</artifactId>
|
||||
<version>3.0.8.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--https://mvnrepository.com/artifact/commons-lang/commons-lang -->
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.6</version>
|
||||
<scope>compile
|
||||
</scope>
|
||||
</dependency>
|
||||
<!--CB 1.7 R4-->
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.7.10</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>EpicHoppers</artifactId>
|
||||
<version>2.3.0</version>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
<build>
|
||||
<finalName>EpicHoppers</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>1.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jcenter</id>
|
||||
<url>http://jcenter.bintray.com</url>
|
||||
</repository>
|
||||
<!--Bukkit Repo-->
|
||||
<repository>
|
||||
<id>bukkit-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
||||
</repository>
|
||||
<!--Songoda Repo-->
|
||||
<repository>
|
||||
<id>songoda-public</id>
|
||||
<url>http://repo.songoda.com/repository/songoda-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>songoda-private</id>
|
||||
<url>http://repo.songoda.com/repository/songoda-private/</url>
|
||||
</repository>
|
||||
<!--WorldGuard Repo-->
|
||||
<repository>
|
||||
<id>sk89q-repo</id>
|
||||
<url>http://maven.sk89q.com/repo/</url>
|
||||
</repository>
|
||||
<!--Vault Repo-->
|
||||
<repository>
|
||||
<id>vault-repo</id>
|
||||
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
|
||||
</repository>
|
||||
<!--uSkyBlock Repo-->
|
||||
<repository>
|
||||
<id>uSkyBlock-mvn-repo</id>
|
||||
<url>https://raw.github.com/rlf/uSkyBlock/mvn-repo/</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<!--aAkyBlock Repo-->
|
||||
<repository>
|
||||
<id>bintray-tastybento-maven-repo</id>
|
||||
<name>bintray</name>
|
||||
<url>http://dl.bintray.com/tastybento/maven-repo</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<!--Bukkit API-->
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--Arconix API-->
|
||||
<dependency>
|
||||
<groupId>com.songoda.arconix</groupId>
|
||||
<artifactId>api</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda.arconix</groupId>
|
||||
<artifactId>plugin</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--WorldGuard API-->
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldguard</artifactId>
|
||||
<version>6.1.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--Vault API-->
|
||||
<dependency>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--Towny API-->
|
||||
<dependency>
|
||||
<groupId>com.palmergames</groupId>
|
||||
<artifactId>Towny</artifactId>
|
||||
<version>0.92.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--uSkyBlock API-->
|
||||
<dependency>
|
||||
<groupId>com.github.rlf</groupId>
|
||||
<artifactId>uSkyBlock-API</artifactId>
|
||||
<version>2.6.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--RedProtect API-->
|
||||
<dependency>
|
||||
<groupId>br.net.fabiozumbi12</groupId>
|
||||
<artifactId>RedProtect</artifactId>
|
||||
<version>7.3.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--PlotSquared API-->
|
||||
<dependency>
|
||||
<groupId>com.intellectualcrafters</groupId>
|
||||
<artifactId>PlotSquared</artifactId>
|
||||
<version>18.05.01</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--Kingdoms API-->
|
||||
<dependency>
|
||||
<groupId>org.kingdoms</groupId>
|
||||
<artifactId>Kingdoms</artifactId>
|
||||
<version>13.3.40</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--GriefPrevention API-->
|
||||
<dependency>
|
||||
<groupId>com.github.TechFortress</groupId>
|
||||
<artifactId>GriefPrevention</artifactId>
|
||||
<version>16.7.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--FactionsFramework API-->
|
||||
<dependency>
|
||||
<groupId>me.markeh</groupId>
|
||||
<artifactId>factionsframework</artifactId>
|
||||
<version>1.2.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--aSkyBlock API-->
|
||||
<dependency>
|
||||
<groupId>com.wasteofplastic</groupId>
|
||||
<artifactId>askyblock</artifactId>
|
||||
<version>3.0.8.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--https://mvnrepository.com/artifact/commons-lang/commons-lang -->
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.6</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.6</version>
|
||||
<scope>compile
|
||||
</scope>
|
||||
</dependency>
|
||||
<!--CB 1.7 R4-->
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.7.10</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,19 +1,19 @@
|
||||
package com.songoda.epichoppers.API;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Created by songo on 6/11/2017.
|
||||
*/
|
||||
public class EpicHoppersAPI {
|
||||
|
||||
public int getILevel(ItemStack item) {
|
||||
if (item.getItemMeta().getDisplayName().contains(":")) {
|
||||
String arr[] = (item.getItemMeta().getDisplayName().replace("§", "")).split(":");
|
||||
return Integer.parseInt(arr[0]);
|
||||
} else {
|
||||
return EpicHoppers.getInstance().getLevelManager().getLowestLevel().getLevel();
|
||||
}
|
||||
}
|
||||
package com.songoda.epichoppers.API;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Created by songo on 6/11/2017.
|
||||
*/
|
||||
public class EpicHoppersAPI {
|
||||
|
||||
public int getILevel(ItemStack item) {
|
||||
if (item.getItemMeta().getDisplayName().contains(":")) {
|
||||
String arr[] = (item.getItemMeta().getDisplayName().replace("§", "")).split(":");
|
||||
return Integer.parseInt(arr[0]);
|
||||
} else {
|
||||
return EpicHoppers.getInstance().getLevelManager().getLowestLevel().getLevel();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,291 +1,282 @@
|
||||
package com.songoda.epichoppers;
|
||||
|
||||
import com.songoda.arconix.api.mcupdate.MCUpdate;
|
||||
import com.songoda.arconix.api.utils.ConfigWrapper;
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.API.EpicHoppersAPI;
|
||||
import com.songoda.epichoppers.Events.*;
|
||||
import com.songoda.epichoppers.Handlers.*;
|
||||
import com.songoda.epichoppers.Hopper.Filter;
|
||||
import com.songoda.epichoppers.Hopper.Hopper;
|
||||
import com.songoda.epichoppers.Hopper.HopperManager;
|
||||
import com.songoda.epichoppers.Hopper.LevelManager;
|
||||
import com.songoda.epichoppers.Utils.SettingsManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public final class EpicHoppers extends JavaPlugin implements Listener {
|
||||
public static CommandSender console = Bukkit.getConsoleSender();
|
||||
|
||||
public boolean v1_12 = Bukkit.getServer().getClass().getPackage().getName().contains("1_12");
|
||||
public boolean v1_11 = Bukkit.getServer().getClass().getPackage().getName().contains("1_11");
|
||||
public boolean v1_10 = Bukkit.getServer().getClass().getPackage().getName().contains("1_10");
|
||||
public boolean v1_9 = Bukkit.getServer().getClass().getPackage().getName().contains("1_9");
|
||||
public boolean v1_7 = Bukkit.getServer().getClass().getPackage().getName().contains("1_7");
|
||||
public boolean v1_8 = Bukkit.getServer().getClass().getPackage().getName().contains("1_8");
|
||||
|
||||
public Map<UUID, Hopper> inShow = new HashMap<>();
|
||||
public Map<UUID, Hopper> inFilter = new HashMap<>();
|
||||
|
||||
public HookHandler hooks;
|
||||
public SettingsManager sm;
|
||||
|
||||
public References references = null;
|
||||
public ConfigWrapper dataFile = new ConfigWrapper(this, "", "data.yml");
|
||||
|
||||
public Map<Player, Block> sync = new HashMap<>();
|
||||
public Map<Player, Block> bsync = new HashMap<>();
|
||||
|
||||
public Map<Player, Date> lastTp = new HashMap<>();
|
||||
|
||||
public Map<Player, Block> lastBlock = new HashMap<>();
|
||||
|
||||
public EnchantmentHandler enchant;
|
||||
|
||||
private Locale locale;
|
||||
|
||||
private HopperManager hopperManager;
|
||||
private LevelManager levelManager;
|
||||
|
||||
private TeleportHandler teleportHandler;
|
||||
|
||||
private EpicHoppersAPI api;
|
||||
|
||||
public void onEnable() {
|
||||
Arconix.pl().hook(this);
|
||||
|
||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&a============================="));
|
||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&7EpicHoppers " + this.getDescription().getVersion() + " by &5Brianna <3&7!"));
|
||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&7Action: &aEnabling&7..."));
|
||||
Bukkit.getPluginManager().registerEvents(this, this);
|
||||
|
||||
api = new EpicHoppersAPI();
|
||||
|
||||
sm = new SettingsManager(this);
|
||||
setupConfig();
|
||||
loadDataFile();
|
||||
enchant = new EnchantmentHandler();
|
||||
|
||||
// Locales
|
||||
Locale.init(this);
|
||||
Locale.saveDefaultLocale("en_US");
|
||||
this.locale = Locale.getLocale(this.getConfig().getString("Locale", "en_US"));
|
||||
|
||||
loadLevelManager();
|
||||
|
||||
hopperManager = new HopperManager();
|
||||
|
||||
/*
|
||||
* Register hoppers into HopperManger from configuration
|
||||
*/
|
||||
Bukkit.getScheduler().runTaskLater(this, () -> {
|
||||
if (dataFile.getConfig().contains("data.sync")) {
|
||||
for (String locationStr : dataFile.getConfig().getConfigurationSection("data.sync").getKeys(false)) {
|
||||
Location location = Arconix.pl().getApi().serialize().unserializeLocation(locationStr);
|
||||
if (location == null || location.getBlock() == null) return;
|
||||
|
||||
int level = dataFile.getConfig().getInt("data.sync." + locationStr + ".level");
|
||||
|
||||
String blockLoc = dataFile.getConfig().getString("data.sync." + locationStr + ".block");
|
||||
Block block = blockLoc == null ? null : Arconix.pl().getApi().serialize().unserializeLocation(dataFile.getConfig().getString("data.sync." + locationStr + ".block")).getBlock();
|
||||
|
||||
boolean walkOnTeleport = dataFile.getConfig().getBoolean("data.sync." + locationStr + ".walkOnTeleport");
|
||||
|
||||
String playerStr = dataFile.getConfig().getString("data.sync." + locationStr + ".player");
|
||||
UUID player = playerStr == null ? null : UUID.fromString(playerStr);
|
||||
|
||||
List<ItemStack> whiteList = (ArrayList<ItemStack>)dataFile.getConfig().getList("data.sync." + locationStr + ".whitelist");
|
||||
List<ItemStack> blackList = (ArrayList<ItemStack>)dataFile.getConfig().getList("data.sync." + locationStr + ".blacklist");
|
||||
List<ItemStack> voidList = (ArrayList<ItemStack>)dataFile.getConfig().getList("data.sync." + locationStr + ".void");
|
||||
|
||||
String blackLoc = dataFile.getConfig().getString("data.sync." + locationStr + ".black");
|
||||
Block black = blackLoc == null ? null : Arconix.pl().getApi().serialize().unserializeLocation(dataFile.getConfig().getString("data.sync." + locationStr + ".black")).getBlock();
|
||||
|
||||
Filter filter = new Filter();
|
||||
|
||||
filter.setWhiteList(whiteList);
|
||||
filter.setBlackList(blackList);
|
||||
filter.setVoidList(voidList);
|
||||
filter.setEndPoint(black);
|
||||
|
||||
Hopper hopper = new Hopper(location, levelManager.getLevel(level), player, block, filter, walkOnTeleport);
|
||||
|
||||
hopperManager.addHopper(location, hopper);
|
||||
}
|
||||
}
|
||||
|
||||
}, 10);
|
||||
|
||||
references = new References();
|
||||
|
||||
hooks = new HookHandler();
|
||||
hooks.hook();
|
||||
|
||||
new HopHandler(this);
|
||||
teleportHandler = new TeleportHandler(this);
|
||||
|
||||
new MCUpdate(this, true);
|
||||
//new MassiveStats(this, 9000);
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, this::saveToFile, 6000, 6000);
|
||||
|
||||
this.getCommand("EpicHoppers").setExecutor(new CommandHandler(this));
|
||||
|
||||
getServer().getPluginManager().registerEvents(new HopperListeners(this), this);
|
||||
getServer().getPluginManager().registerEvents(new BlockListeners(this), this);
|
||||
getServer().getPluginManager().registerEvents(new InteractListeners(this), this);
|
||||
getServer().getPluginManager().registerEvents(new InventoryListeners(this), this);
|
||||
getServer().getPluginManager().registerEvents(new LoginListeners(this), this);
|
||||
|
||||
|
||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&a============================="));
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
saveToFile();
|
||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&a============================="));
|
||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&7EpicHoppers " + this.getDescription().getVersion() + " by &5Brianna <3!"));
|
||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&7Action: &cDisabling&7..."));
|
||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&a============================="));
|
||||
dataFile.saveConfig();
|
||||
}
|
||||
|
||||
/*
|
||||
* Saves registered hopper to file.
|
||||
*/
|
||||
private void saveToFile() {
|
||||
|
||||
// Wipe old hopper information
|
||||
dataFile.getConfig().set("data.sync", null);
|
||||
|
||||
/*
|
||||
* Dump HopperManager to file.
|
||||
*/
|
||||
for (Hopper hopper : hopperManager.getHoppers().values()) {
|
||||
if (hopper.getLevel() == null || hopper.getLocation() == null || hopper.getLocation().getChunk() == null) continue;
|
||||
String locationStr = Arconix.pl().getApi().serialize().serializeLocation(hopper.getLocation());
|
||||
dataFile.getConfig().set("data.sync." + locationStr + ".level", hopper.getLevel().getLevel());
|
||||
dataFile.getConfig().set("data.sync." + locationStr + ".block", hopper.getSyncedBlock() == null ? null : Arconix.pl().getApi().serialize().serializeLocation(hopper.getSyncedBlock().getLocation()));
|
||||
dataFile.getConfig().set("data.sync." + locationStr + ".player", hopper.getLastPlayer() == null ? null : hopper.getLastPlayer().toString());
|
||||
dataFile.getConfig().set("data.sync." + locationStr + ".walkOnTeleport", hopper.isWalkOnTeleport());
|
||||
dataFile.getConfig().set("data.sync." + locationStr + ".whitelist", hopper.getFilter().getWhiteList());
|
||||
dataFile.getConfig().set("data.sync." + locationStr + ".blacklist", hopper.getFilter().getBlackList());
|
||||
dataFile.getConfig().set("data.sync." + locationStr + ".void", hopper.getFilter().getVoidList());
|
||||
dataFile.getConfig().set("data.sync." + locationStr + ".black", hopper.getFilter().getEndPoint() == null ? null : Arconix.pl().getApi().serialize().serializeLocation(hopper.getFilter().getEndPoint().getLocation()));
|
||||
}
|
||||
|
||||
//Save to file
|
||||
dataFile.saveConfig();
|
||||
}
|
||||
|
||||
private void loadLevelManager() {
|
||||
// Load an instance of LevelManager
|
||||
levelManager = new LevelManager();
|
||||
/*
|
||||
* Register Levels into LevelManager from configuration.
|
||||
*/
|
||||
levelManager.clear();
|
||||
for (String levelName : getConfig().getConfigurationSection("settings.levels").getKeys(false)) {
|
||||
int level = Integer.valueOf(levelName.split("-")[1]);
|
||||
int radius = getConfig().getInt("settings.levels." + levelName + ".Range");
|
||||
int amount = getConfig().getInt("settings.levels." + levelName + ".Amount");
|
||||
int suction = getConfig().getInt("settings.levels." + levelName + ".Suction");
|
||||
int blockBreak = getConfig().getInt("settings.levels." + levelName + ".BlockBreak");
|
||||
int costExperiance = getConfig().getInt("settings.levels." + levelName + ".Cost-xp");
|
||||
int costEconomy = getConfig().getInt("settings.levels." + levelName + ".Cost-eco");
|
||||
levelManager.addLevel(level, costExperiance, costEconomy, radius, amount, suction, blockBreak);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupConfig() {
|
||||
sm.updateSettings();
|
||||
|
||||
if (!getConfig().contains("settings.levels.Level-1")) {
|
||||
getConfig().addDefault("settings.levels.Level-1.Range", 10);
|
||||
getConfig().addDefault("settings.levels.Level-1.Amount", 1);
|
||||
getConfig().addDefault("settings.levels.Level-1.Cost-xp", 20);
|
||||
getConfig().addDefault("settings.levels.Level-1.Cost-eco", 5000);
|
||||
|
||||
getConfig().addDefault("settings.levels.Level-2.Range", 20);
|
||||
getConfig().addDefault("settings.levels.Level-2.Amount", 2);
|
||||
getConfig().addDefault("settings.levels.Level-2.Cost-xp", 25);
|
||||
getConfig().addDefault("settings.levels.Level-2.Cost-eco", 7500);
|
||||
|
||||
getConfig().addDefault("settings.levels.Level-3.Range", 30);
|
||||
getConfig().addDefault("settings.levels.Level-3.Amount", 3);
|
||||
getConfig().addDefault("settings.levels.Level-3.Suction", 1);
|
||||
getConfig().addDefault("settings.levels.Level-3.Cost-xp", 30);
|
||||
getConfig().addDefault("settings.levels.Level-3.Cost-eco", 10000);
|
||||
|
||||
getConfig().addDefault("settings.levels.Level-4.Range", 40);
|
||||
getConfig().addDefault("settings.levels.Level-4.Amount", 4);
|
||||
getConfig().addDefault("settings.levels.Level-4.Suction", 2);
|
||||
|
||||
if (!v1_7 && !v1_8)
|
||||
getConfig().addDefault("settings.levels.Level-4.BlockBreak", 4);
|
||||
getConfig().addDefault("settings.levels.Level-4.Cost-xp", 35);
|
||||
getConfig().addDefault("settings.levels.Level-4.Cost-eco", 12000);
|
||||
|
||||
getConfig().addDefault("settings.levels.Level-5.Range", 50);
|
||||
getConfig().addDefault("settings.levels.Level-5.Amount", 5);
|
||||
getConfig().addDefault("settings.levels.Level-5.Suction", 3);
|
||||
|
||||
if (!v1_7 && !v1_8)
|
||||
getConfig().addDefault("settings.levels.Level-5.BlockBreak", 2);
|
||||
getConfig().addDefault("settings.levels.Level-5.Cost-xp", 40);
|
||||
getConfig().addDefault("settings.levels.Level-5.Cost-eco", 15000);
|
||||
}
|
||||
|
||||
getConfig().options().copyDefaults(true);
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
private void loadDataFile() {
|
||||
dataFile.getConfig().options().copyDefaults(true);
|
||||
dataFile.saveConfig();
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
locale.reloadMessages();
|
||||
hooks.hooksFile.createNewFile("Loading hooks File", "EpicSpawners Spawners File");
|
||||
hooks = new HookHandler();
|
||||
hooks.hook();
|
||||
references = new References();
|
||||
reloadConfig();
|
||||
saveConfig();
|
||||
loadLevelManager();
|
||||
}
|
||||
|
||||
public Locale getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
public TeleportHandler getTeleportHandler() {
|
||||
return teleportHandler;
|
||||
}
|
||||
|
||||
public LevelManager getLevelManager() {
|
||||
return levelManager;
|
||||
}
|
||||
|
||||
public HopperManager getHopperManager() {
|
||||
return hopperManager;
|
||||
}
|
||||
|
||||
public static EpicHoppers getInstance() {
|
||||
return (EpicHoppers) Bukkit.getServer().getPluginManager().getPlugin("EpicHoppers");
|
||||
}
|
||||
|
||||
public EpicHoppersAPI getApi() {
|
||||
return api;
|
||||
}
|
||||
}
|
||||
package com.songoda.epichoppers;
|
||||
|
||||
import com.songoda.arconix.api.mcupdate.MCUpdate;
|
||||
import com.songoda.arconix.api.utils.ConfigWrapper;
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.API.EpicHoppersAPI;
|
||||
import com.songoda.epichoppers.Events.*;
|
||||
import com.songoda.epichoppers.Handlers.*;
|
||||
import com.songoda.epichoppers.Hopper.Filter;
|
||||
import com.songoda.epichoppers.Hopper.Hopper;
|
||||
import com.songoda.epichoppers.Hopper.HopperManager;
|
||||
import com.songoda.epichoppers.Hopper.LevelManager;
|
||||
import com.songoda.epichoppers.Utils.SettingsManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
public final class EpicHoppers extends JavaPlugin implements Listener {
|
||||
public static CommandSender console = Bukkit.getConsoleSender();
|
||||
|
||||
public Map<UUID, Hopper> inShow = new HashMap<>();
|
||||
public Map<UUID, Hopper> inFilter = new HashMap<>();
|
||||
|
||||
public HookHandler hooks;
|
||||
public SettingsManager sm;
|
||||
|
||||
public References references = null;
|
||||
public ConfigWrapper dataFile = new ConfigWrapper(this, "", "data.yml");
|
||||
|
||||
public Map<Player, Block> sync = new HashMap<>();
|
||||
public Map<Player, Block> bsync = new HashMap<>();
|
||||
|
||||
public Map<Player, Date> lastTp = new HashMap<>();
|
||||
|
||||
public Map<Player, Block> lastBlock = new HashMap<>();
|
||||
|
||||
public EnchantmentHandler enchant;
|
||||
|
||||
private Locale locale;
|
||||
|
||||
private HopperManager hopperManager;
|
||||
private LevelManager levelManager;
|
||||
|
||||
private TeleportHandler teleportHandler;
|
||||
|
||||
private EpicHoppersAPI api;
|
||||
|
||||
public void onEnable() {
|
||||
Arconix.pl().hook(this);
|
||||
|
||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&a============================="));
|
||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&7EpicHoppers " + this.getDescription().getVersion() + " by &5Brianna <3&7!"));
|
||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&7Action: &aEnabling&7..."));
|
||||
Bukkit.getPluginManager().registerEvents(this, this);
|
||||
|
||||
api = new EpicHoppersAPI();
|
||||
|
||||
sm = new SettingsManager(this);
|
||||
setupConfig();
|
||||
loadDataFile();
|
||||
enchant = new EnchantmentHandler();
|
||||
|
||||
// Locales
|
||||
Locale.init(this);
|
||||
Locale.saveDefaultLocale("en_US");
|
||||
this.locale = Locale.getLocale(this.getConfig().getString("Locale", "en_US"));
|
||||
|
||||
loadLevelManager();
|
||||
|
||||
hopperManager = new HopperManager();
|
||||
|
||||
/*
|
||||
* Register hoppers into HopperManger from configuration
|
||||
*/
|
||||
Bukkit.getScheduler().runTaskLater(this, () -> {
|
||||
if (dataFile.getConfig().contains("data.sync")) {
|
||||
for (String locationStr : dataFile.getConfig().getConfigurationSection("data.sync").getKeys(false)) {
|
||||
Location location = Arconix.pl().getApi().serialize().unserializeLocation(locationStr);
|
||||
if (location == null || location.getBlock() == null) return;
|
||||
|
||||
int level = dataFile.getConfig().getInt("data.sync." + locationStr + ".level");
|
||||
|
||||
String blockLoc = dataFile.getConfig().getString("data.sync." + locationStr + ".block");
|
||||
Block block = blockLoc == null ? null : Arconix.pl().getApi().serialize().unserializeLocation(dataFile.getConfig().getString("data.sync." + locationStr + ".block")).getBlock();
|
||||
|
||||
boolean walkOnTeleport = dataFile.getConfig().getBoolean("data.sync." + locationStr + ".walkOnTeleport");
|
||||
|
||||
String playerStr = dataFile.getConfig().getString("data.sync." + locationStr + ".player");
|
||||
UUID player = playerStr == null ? null : UUID.fromString(playerStr);
|
||||
|
||||
List<ItemStack> whiteList = (ArrayList<ItemStack>)dataFile.getConfig().getList("data.sync." + locationStr + ".whitelist");
|
||||
List<ItemStack> blackList = (ArrayList<ItemStack>)dataFile.getConfig().getList("data.sync." + locationStr + ".blacklist");
|
||||
List<ItemStack> voidList = (ArrayList<ItemStack>)dataFile.getConfig().getList("data.sync." + locationStr + ".void");
|
||||
|
||||
String blackLoc = dataFile.getConfig().getString("data.sync." + locationStr + ".black");
|
||||
Block black = blackLoc == null ? null : Arconix.pl().getApi().serialize().unserializeLocation(dataFile.getConfig().getString("data.sync." + locationStr + ".black")).getBlock();
|
||||
|
||||
Filter filter = new Filter();
|
||||
|
||||
filter.setWhiteList(whiteList);
|
||||
filter.setBlackList(blackList);
|
||||
filter.setVoidList(voidList);
|
||||
filter.setEndPoint(black);
|
||||
|
||||
Hopper hopper = new Hopper(location, levelManager.getLevel(level), player, block, filter, walkOnTeleport);
|
||||
|
||||
hopperManager.addHopper(location, hopper);
|
||||
}
|
||||
}
|
||||
|
||||
}, 10);
|
||||
|
||||
references = new References();
|
||||
|
||||
hooks = new HookHandler();
|
||||
hooks.hook();
|
||||
|
||||
new HopHandler(this);
|
||||
teleportHandler = new TeleportHandler(this);
|
||||
|
||||
new MCUpdate(this, true);
|
||||
//new MassiveStats(this, 9000);
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, this::saveToFile, 6000, 6000);
|
||||
|
||||
this.getCommand("EpicHoppers").setExecutor(new CommandHandler(this));
|
||||
|
||||
getServer().getPluginManager().registerEvents(new HopperListeners(this), this);
|
||||
getServer().getPluginManager().registerEvents(new BlockListeners(this), this);
|
||||
getServer().getPluginManager().registerEvents(new InteractListeners(this), this);
|
||||
getServer().getPluginManager().registerEvents(new InventoryListeners(this), this);
|
||||
getServer().getPluginManager().registerEvents(new LoginListeners(this), this);
|
||||
|
||||
|
||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&a============================="));
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
saveToFile();
|
||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&a============================="));
|
||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&7EpicHoppers " + this.getDescription().getVersion() + " by &5Brianna <3!"));
|
||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&7Action: &cDisabling&7..."));
|
||||
console.sendMessage(Arconix.pl().getApi().format().formatText("&a============================="));
|
||||
dataFile.saveConfig();
|
||||
}
|
||||
|
||||
/*
|
||||
* Saves registered hopper to file.
|
||||
*/
|
||||
private void saveToFile() {
|
||||
|
||||
// Wipe old hopper information
|
||||
dataFile.getConfig().set("data.sync", null);
|
||||
|
||||
/*
|
||||
* Dump HopperManager to file.
|
||||
*/
|
||||
for (Hopper hopper : hopperManager.getHoppers().values()) {
|
||||
if (hopper.getLevel() == null || hopper.getLocation() == null || hopper.getLocation().getChunk() == null) continue;
|
||||
String locationStr = Arconix.pl().getApi().serialize().serializeLocation(hopper.getLocation());
|
||||
dataFile.getConfig().set("data.sync." + locationStr + ".level", hopper.getLevel().getLevel());
|
||||
dataFile.getConfig().set("data.sync." + locationStr + ".block", hopper.getSyncedBlock() == null ? null : Arconix.pl().getApi().serialize().serializeLocation(hopper.getSyncedBlock().getLocation()));
|
||||
dataFile.getConfig().set("data.sync." + locationStr + ".player", hopper.getLastPlayer() == null ? null : hopper.getLastPlayer().toString());
|
||||
dataFile.getConfig().set("data.sync." + locationStr + ".walkOnTeleport", hopper.isWalkOnTeleport());
|
||||
dataFile.getConfig().set("data.sync." + locationStr + ".whitelist", hopper.getFilter().getWhiteList());
|
||||
dataFile.getConfig().set("data.sync." + locationStr + ".blacklist", hopper.getFilter().getBlackList());
|
||||
dataFile.getConfig().set("data.sync." + locationStr + ".void", hopper.getFilter().getVoidList());
|
||||
dataFile.getConfig().set("data.sync." + locationStr + ".black", hopper.getFilter().getEndPoint() == null ? null : Arconix.pl().getApi().serialize().serializeLocation(hopper.getFilter().getEndPoint().getLocation()));
|
||||
}
|
||||
|
||||
//Save to file
|
||||
dataFile.saveConfig();
|
||||
}
|
||||
|
||||
private void loadLevelManager() {
|
||||
// Load an instance of LevelManager
|
||||
levelManager = new LevelManager();
|
||||
/*
|
||||
* Register Levels into LevelManager from configuration.
|
||||
*/
|
||||
levelManager.clear();
|
||||
for (String levelName : getConfig().getConfigurationSection("settings.levels").getKeys(false)) {
|
||||
int level = Integer.valueOf(levelName.split("-")[1]);
|
||||
int radius = getConfig().getInt("settings.levels." + levelName + ".Range");
|
||||
int amount = getConfig().getInt("settings.levels." + levelName + ".Amount");
|
||||
int suction = getConfig().getInt("settings.levels." + levelName + ".Suction");
|
||||
int blockBreak = getConfig().getInt("settings.levels." + levelName + ".BlockBreak");
|
||||
int costExperiance = getConfig().getInt("settings.levels." + levelName + ".Cost-xp");
|
||||
int costEconomy = getConfig().getInt("settings.levels." + levelName + ".Cost-eco");
|
||||
levelManager.addLevel(level, costExperiance, costEconomy, radius, amount, suction, blockBreak);
|
||||
}
|
||||
}
|
||||
|
||||
private void setupConfig() {
|
||||
sm.updateSettings();
|
||||
|
||||
if (!getConfig().contains("settings.levels.Level-1")) {
|
||||
getConfig().addDefault("settings.levels.Level-1.Range", 10);
|
||||
getConfig().addDefault("settings.levels.Level-1.Amount", 1);
|
||||
getConfig().addDefault("settings.levels.Level-1.Cost-xp", 20);
|
||||
getConfig().addDefault("settings.levels.Level-1.Cost-eco", 5000);
|
||||
|
||||
getConfig().addDefault("settings.levels.Level-2.Range", 20);
|
||||
getConfig().addDefault("settings.levels.Level-2.Amount", 2);
|
||||
getConfig().addDefault("settings.levels.Level-2.Cost-xp", 25);
|
||||
getConfig().addDefault("settings.levels.Level-2.Cost-eco", 7500);
|
||||
|
||||
getConfig().addDefault("settings.levels.Level-3.Range", 30);
|
||||
getConfig().addDefault("settings.levels.Level-3.Amount", 3);
|
||||
getConfig().addDefault("settings.levels.Level-3.Suction", 1);
|
||||
getConfig().addDefault("settings.levels.Level-3.Cost-xp", 30);
|
||||
getConfig().addDefault("settings.levels.Level-3.Cost-eco", 10000);
|
||||
|
||||
getConfig().addDefault("settings.levels.Level-4.Range", 40);
|
||||
getConfig().addDefault("settings.levels.Level-4.Amount", 4);
|
||||
getConfig().addDefault("settings.levels.Level-4.Suction", 2);
|
||||
|
||||
getConfig().addDefault("settings.levels.Level-4.BlockBreak", 4);
|
||||
getConfig().addDefault("settings.levels.Level-4.Cost-xp", 35);
|
||||
getConfig().addDefault("settings.levels.Level-4.Cost-eco", 12000);
|
||||
|
||||
getConfig().addDefault("settings.levels.Level-5.Range", 50);
|
||||
getConfig().addDefault("settings.levels.Level-5.Amount", 5);
|
||||
getConfig().addDefault("settings.levels.Level-5.Suction", 3);
|
||||
|
||||
getConfig().addDefault("settings.levels.Level-5.BlockBreak", 2);
|
||||
getConfig().addDefault("settings.levels.Level-5.Cost-xp", 40);
|
||||
getConfig().addDefault("settings.levels.Level-5.Cost-eco", 15000);
|
||||
}
|
||||
|
||||
getConfig().options().copyDefaults(true);
|
||||
saveConfig();
|
||||
}
|
||||
|
||||
private void loadDataFile() {
|
||||
dataFile.getConfig().options().copyDefaults(true);
|
||||
dataFile.saveConfig();
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
locale.reloadMessages();
|
||||
hooks.hooksFile.createNewFile("Loading hooks File", "EpicSpawners Spawners File");
|
||||
hooks = new HookHandler();
|
||||
hooks.hook();
|
||||
references = new References();
|
||||
reloadConfig();
|
||||
saveConfig();
|
||||
loadLevelManager();
|
||||
}
|
||||
|
||||
public Locale getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
public TeleportHandler getTeleportHandler() {
|
||||
return teleportHandler;
|
||||
}
|
||||
|
||||
public LevelManager getLevelManager() {
|
||||
return levelManager;
|
||||
}
|
||||
|
||||
public HopperManager getHopperManager() {
|
||||
return hopperManager;
|
||||
}
|
||||
|
||||
public static EpicHoppers getInstance() {
|
||||
return (EpicHoppers) Bukkit.getServer().getPluginManager().getPlugin("EpicHoppers");
|
||||
}
|
||||
|
||||
public EpicHoppersAPI getApi() {
|
||||
return api;
|
||||
}
|
||||
}
|
||||
|
@ -1,185 +1,171 @@
|
||||
package com.songoda.epichoppers.Events;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Hopper.Filter;
|
||||
import com.songoda.epichoppers.Hopper.Hopper;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.Utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ExperienceOrb;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/14/2017.
|
||||
*/
|
||||
public class BlockListeners implements Listener {
|
||||
|
||||
private EpicHoppers instance;
|
||||
|
||||
public BlockListeners(EpicHoppers instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockPlace(BlockPlaceEvent e) {
|
||||
try {
|
||||
if (e.getBlock().getType().equals(Material.ENDER_CHEST)) {
|
||||
instance.dataFile.getConfig().set("data.enderTracker." + Arconix.pl().getApi().serialize().serializeLocation(e.getBlock()), e.getPlayer().getUniqueId().toString());
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getBlock().getType() != Material.HOPPER) return;
|
||||
|
||||
int amt = count(e.getBlock().getChunk());
|
||||
if (amt >= instance.getConfig().getInt("Main.Max Hoppers Per Chunk") && instance.getConfig().getInt("Main.Max Hoppers Per Chunk") != -1) {
|
||||
e.getPlayer().sendMessage(instance.getLocale().getMessage("event.hopper.toomany"));
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!e.getItemInHand().getItemMeta().hasDisplayName()) return;
|
||||
|
||||
ItemStack item = e.getItemInHand().clone();
|
||||
|
||||
//not sure what this shit does
|
||||
byte b = e.getBlock().getData();
|
||||
e.getBlock().setType(Material.AIR);
|
||||
e.getBlock().getLocation().getBlock().setType(Material.HOPPER);
|
||||
e.getBlock().getLocation().getBlock().setData(b);
|
||||
|
||||
instance.getHopperManager().addHopper(e.getBlock().getLocation(), new Hopper(e.getBlock(), instance.getLevelManager().getLevel(instance.getApi().getILevel(item)), e.getPlayer().getUniqueId(), null, new Filter(), false));
|
||||
|
||||
} catch (Exception ee) {
|
||||
Debugger.runReport(ee);
|
||||
}
|
||||
}
|
||||
|
||||
public int count(Chunk c) {
|
||||
try {
|
||||
int count = 0;
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int y = 0; y < c.getWorld().getMaxHeight(); y++) {
|
||||
if (c.getBlock(x, y, z).getType() == Material.HOPPER) count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return 9999;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
try {
|
||||
if (event.getBlock().getType().equals(Material.ENDER_CHEST)) {
|
||||
instance.dataFile.getConfig().set("data.enderTracker." + Arconix.pl().getApi().serialize().serializeLocation(event.getBlock()), null);
|
||||
}
|
||||
|
||||
Block block = event.getBlock();
|
||||
|
||||
if (event.getPlayer().getItemInHand() == null) return;
|
||||
|
||||
handleSyncTouch(event);
|
||||
|
||||
if (event.getBlock().getType() != Material.HOPPER) return;
|
||||
|
||||
Hopper hopper = instance.getHopperManager().getHopper(block);
|
||||
|
||||
int level = hopper.getLevel().getLevel();
|
||||
|
||||
if (level != 0) {
|
||||
event.setCancelled(true);
|
||||
ItemStack item = new ItemStack(Material.HOPPER, 1);
|
||||
ItemMeta itemmeta = item.getItemMeta();
|
||||
itemmeta.setDisplayName(Arconix.pl().getApi().format().formatText(Methods.formatName(level, true)));
|
||||
item.setItemMeta(itemmeta);
|
||||
|
||||
event.getBlock().setType(Material.AIR);
|
||||
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), item);
|
||||
}
|
||||
|
||||
for (ItemStack i : hopper.getFilter().getWhiteList()) {
|
||||
if (i != null)
|
||||
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), i);
|
||||
}
|
||||
|
||||
for (ItemStack i : hopper.getFilter().getBlackList()) {
|
||||
if (i != null)
|
||||
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), i);
|
||||
}
|
||||
for (ItemStack i : hopper.getFilter().getVoidList()) {
|
||||
if (i != null)
|
||||
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), i);
|
||||
}
|
||||
instance.getHopperManager().removeHopper(block.getLocation());
|
||||
|
||||
instance.sync.remove(event.getPlayer());
|
||||
|
||||
|
||||
} catch (Exception ee) {
|
||||
Debugger.runReport(ee);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSyncTouch(BlockBreakEvent e) {
|
||||
if (!Methods.isSync(e.getPlayer())) return;
|
||||
|
||||
ItemStack tool = e.getPlayer().getItemInHand();
|
||||
ItemMeta meta = tool.getItemMeta();
|
||||
if (tool.getItemMeta().getLore().size() != 2) return;
|
||||
|
||||
Location location = Arconix.pl().getApi().serialize().unserializeLocation(meta.getLore().get(1).replaceAll("§", ""));
|
||||
|
||||
if (location.getBlock().getType() != Material.CHEST) return;
|
||||
|
||||
if (e.getBlock().getType() == Material.MOB_SPAWNER || e.getBlock().getType() == Material.HOPPER || e.getBlock().getType() == Material.DISPENSER) return;
|
||||
|
||||
try {
|
||||
if (e.getBlock().getType().name().contains("SHULKER") && e.getBlock().getType() != Material.SHULKER_SHELL) return;
|
||||
} catch (Exception ee) {
|
||||
|
||||
}
|
||||
|
||||
InventoryHolder ih = (InventoryHolder) location.getBlock().getState();
|
||||
if (e.getPlayer().getItemInHand().getItemMeta().hasEnchant(Enchantment.SILK_TOUCH)) {
|
||||
ih.getInventory().addItem(new ItemStack(e.getBlock().getType(),1, e.getBlock().getData()));
|
||||
} else {
|
||||
for (ItemStack is : e.getBlock().getDrops())
|
||||
ih.getInventory().addItem(is);
|
||||
}
|
||||
if (instance.v1_12) {
|
||||
e.setDropItems(false);
|
||||
return;
|
||||
}
|
||||
|
||||
e.isCancelled();
|
||||
e.getPlayer().getItemInHand().setDurability((short) (e.getPlayer().getItemInHand().getDurability() + 1));
|
||||
if (e.getPlayer().getItemInHand().getDurability() >= e.getPlayer().getItemInHand().getType().getMaxDurability()) {
|
||||
e.getPlayer().getItemInHand().setType(null);
|
||||
}
|
||||
if (e.getExpToDrop() > 0)
|
||||
e.getPlayer().getWorld().spawn(e.getBlock().getLocation(), ExperienceOrb.class).setExperience(e.getExpToDrop());
|
||||
e.getBlock().setType(Material.AIR);
|
||||
}
|
||||
package com.songoda.epichoppers.Events;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Hopper.Filter;
|
||||
import com.songoda.epichoppers.Hopper.Hopper;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.Utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ExperienceOrb;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/14/2017.
|
||||
*/
|
||||
public class BlockListeners implements Listener {
|
||||
|
||||
private EpicHoppers instance;
|
||||
|
||||
public BlockListeners(EpicHoppers instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockPlace(BlockPlaceEvent e) {
|
||||
try {
|
||||
if (e.getBlock().getType().equals(Material.ENDER_CHEST)) {
|
||||
instance.dataFile.getConfig().set("data.enderTracker." + Arconix.pl().getApi().serialize().serializeLocation(e.getBlock()), e.getPlayer().getUniqueId().toString());
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getBlock().getType() != Material.HOPPER) return;
|
||||
|
||||
int amt = count(e.getBlock().getChunk());
|
||||
if (amt >= instance.getConfig().getInt("Main.Max Hoppers Per Chunk") && instance.getConfig().getInt("Main.Max Hoppers Per Chunk") != -1) {
|
||||
e.getPlayer().sendMessage(instance.getLocale().getMessage("event.hopper.toomany"));
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!e.getItemInHand().getItemMeta().hasDisplayName()) return;
|
||||
|
||||
ItemStack item = e.getItemInHand().clone();
|
||||
|
||||
e.getBlock().setType(Material.AIR);
|
||||
e.getBlock().getLocation().getBlock().setType(Material.HOPPER);
|
||||
|
||||
instance.getHopperManager().addHopper(e.getBlock().getLocation(), new Hopper(e.getBlock(), instance.getLevelManager().getLevel(instance.getApi().getILevel(item)), e.getPlayer().getUniqueId(), null, new Filter(), false));
|
||||
|
||||
} catch (Exception ee) {
|
||||
Debugger.runReport(ee);
|
||||
}
|
||||
}
|
||||
|
||||
public int count(Chunk c) {
|
||||
try {
|
||||
int count = 0;
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int y = 0; y < c.getWorld().getMaxHeight(); y++) {
|
||||
if (c.getBlock(x, y, z).getType() == Material.HOPPER) count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return 9999;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
try {
|
||||
if (event.getBlock().getType().equals(Material.ENDER_CHEST)) {
|
||||
instance.dataFile.getConfig().set("data.enderTracker." + Arconix.pl().getApi().serialize().serializeLocation(event.getBlock()), null);
|
||||
}
|
||||
|
||||
Block block = event.getBlock();
|
||||
|
||||
if (event.getPlayer().getItemInHand() == null) return;
|
||||
|
||||
handleSyncTouch(event);
|
||||
|
||||
if (event.getBlock().getType() != Material.HOPPER) return;
|
||||
|
||||
Hopper hopper = instance.getHopperManager().getHopper(block);
|
||||
|
||||
int level = hopper.getLevel().getLevel();
|
||||
|
||||
if (level != 0) {
|
||||
event.setCancelled(true);
|
||||
ItemStack item = new ItemStack(Material.HOPPER, 1);
|
||||
ItemMeta itemmeta = item.getItemMeta();
|
||||
itemmeta.setDisplayName(Arconix.pl().getApi().format().formatText(Methods.formatName(level, true)));
|
||||
item.setItemMeta(itemmeta);
|
||||
|
||||
event.getBlock().setType(Material.AIR);
|
||||
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), item);
|
||||
}
|
||||
|
||||
for (ItemStack i : hopper.getFilter().getWhiteList()) {
|
||||
if (i != null)
|
||||
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), i);
|
||||
}
|
||||
|
||||
for (ItemStack i : hopper.getFilter().getBlackList()) {
|
||||
if (i != null)
|
||||
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), i);
|
||||
}
|
||||
for (ItemStack i : hopper.getFilter().getVoidList()) {
|
||||
if (i != null)
|
||||
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), i);
|
||||
}
|
||||
instance.getHopperManager().removeHopper(block.getLocation());
|
||||
|
||||
instance.sync.remove(event.getPlayer());
|
||||
|
||||
|
||||
} catch (Exception ee) {
|
||||
Debugger.runReport(ee);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleSyncTouch(BlockBreakEvent e) {
|
||||
if (!Methods.isSync(e.getPlayer())) return;
|
||||
|
||||
ItemStack tool = e.getPlayer().getItemInHand();
|
||||
ItemMeta meta = tool.getItemMeta();
|
||||
if (tool.getItemMeta().getLore().size() != 2) return;
|
||||
|
||||
Location location = Arconix.pl().getApi().serialize().unserializeLocation(meta.getLore().get(1).replaceAll("§", ""));
|
||||
|
||||
if (location.getBlock().getType() != Material.CHEST) return;
|
||||
|
||||
if (e.getBlock().getType() == Material.SPAWNER || e.getBlock().getType() == Material.HOPPER || e.getBlock().getType() == Material.DISPENSER) return;
|
||||
|
||||
try {
|
||||
if (e.getBlock().getType().name().contains("SHULKER") && e.getBlock().getType() != Material.SHULKER_SHELL) return;
|
||||
} catch (Exception ee) {
|
||||
|
||||
}
|
||||
|
||||
InventoryHolder ih = (InventoryHolder) location.getBlock().getState();
|
||||
if (e.getPlayer().getItemInHand().getItemMeta().hasEnchant(Enchantment.SILK_TOUCH)) {
|
||||
ih.getInventory().addItem(new ItemStack(e.getBlock().getType(),1, e.getBlock().getData()));
|
||||
} else {
|
||||
for (ItemStack is : e.getBlock().getDrops())
|
||||
ih.getInventory().addItem(is);
|
||||
}
|
||||
e.setDropItems(false);
|
||||
return;
|
||||
}
|
||||
}
|
@ -1,130 +1,107 @@
|
||||
package com.songoda.epichoppers.Events;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.Utils.Methods;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Hopper;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by songoda on 4/18/2017.
|
||||
*/
|
||||
public class HopperListeners implements Listener {
|
||||
|
||||
private EpicHoppers instance;
|
||||
|
||||
public HopperListeners(EpicHoppers instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onHop(InventoryMoveItemEvent e) {
|
||||
try {
|
||||
Inventory source = e.getSource();
|
||||
|
||||
if (instance.v1_7 || instance.v1_8) return;
|
||||
|
||||
|
||||
if (!instance.getHopperManager().isHopper(e.getSource().getLocation())) return;
|
||||
|
||||
com.songoda.epichoppers.Hopper.Hopper hopper = instance.getHopperManager().getHopper(e.getSource().getLocation());
|
||||
|
||||
if (source.getHolder() instanceof Hopper && hopper.getSyncedBlock() != null) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
/*
|
||||
//if amt is not 1
|
||||
int amt = hopper.getLevel().getAmount();
|
||||
|
||||
if (amt <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.setCancelled(true);
|
||||
|
||||
// Set amount of items per hopper transfer
|
||||
ItemStack item = e.getItem();
|
||||
int transferAmount = Math.min(amt, getItemCount(source, item));
|
||||
item.setAmount(transferAmount);
|
||||
|
||||
e.getDestination().addItem(item); //hacky as shit
|
||||
|
||||
source.removeItem(item);
|
||||
//Please work.
|
||||
*/
|
||||
} catch (Exception ee) {
|
||||
Debugger.runReport(ee);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<UUID, Player> ents = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void onDed(EntityDamageByEntityEvent e) {
|
||||
try {
|
||||
if (e.getDamager() instanceof Player) {
|
||||
Player p = (Player) e.getDamager();
|
||||
if (Methods.isSync(p)) {
|
||||
double d = ((LivingEntity) e.getEntity()).getHealth() - e.getDamage();
|
||||
if (d < 1) {
|
||||
ents.put(e.getEntity().getUniqueId(), p);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ee) {
|
||||
Debugger.runReport(ee);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDrop(EntityDeathEvent e) {
|
||||
try {
|
||||
if (ents.containsKey(e.getEntity().getUniqueId())) {
|
||||
Player p = ents.get(e.getEntity().getUniqueId());
|
||||
|
||||
ItemStack item = p.getItemInHand();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
Location location = Arconix.pl().getApi().serialize().unserializeLocation(meta.getLore().get(1).replaceAll("§", ""));
|
||||
if (location.getBlock().getType() == Material.CHEST) {
|
||||
InventoryHolder ih = (InventoryHolder) location.getBlock().getState();
|
||||
for (ItemStack is : e.getDrops()) {
|
||||
ih.getInventory().addItem(is);
|
||||
}
|
||||
e.getDrops().clear();
|
||||
}
|
||||
}
|
||||
} catch (Exception ee) {
|
||||
Debugger.runReport(ee);
|
||||
}
|
||||
}
|
||||
|
||||
private int getItemCount(Inventory inventory, ItemStack item) {
|
||||
int amount = 0;
|
||||
|
||||
for (ItemStack inventoryItem : inventory) {
|
||||
if (!item.isSimilar(inventoryItem)) continue;
|
||||
amount += inventoryItem.getAmount();
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
package com.songoda.epichoppers.Events;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.Utils.Methods;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Hopper;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by songoda on 4/18/2017.
|
||||
*/
|
||||
public class HopperListeners implements Listener {
|
||||
|
||||
private EpicHoppers instance;
|
||||
|
||||
public HopperListeners(EpicHoppers instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onHop(InventoryMoveItemEvent e) {
|
||||
try {
|
||||
Inventory source = e.getSource();
|
||||
|
||||
|
||||
if (!instance.getHopperManager().isHopper(e.getSource().getLocation())) return;
|
||||
|
||||
com.songoda.epichoppers.Hopper.Hopper hopper = instance.getHopperManager().getHopper(e.getSource().getLocation());
|
||||
|
||||
if (source.getHolder() instanceof Hopper && hopper.getSyncedBlock() != null) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} catch (Exception ee) {
|
||||
Debugger.runReport(ee);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<UUID, Player> ents = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void onDed(EntityDamageByEntityEvent e) {
|
||||
try {
|
||||
if (e.getDamager() instanceof Player) {
|
||||
Player p = (Player) e.getDamager();
|
||||
if (Methods.isSync(p)) {
|
||||
double d = ((LivingEntity) e.getEntity()).getHealth() - e.getDamage();
|
||||
if (d < 1) {
|
||||
ents.put(e.getEntity().getUniqueId(), p);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ee) {
|
||||
Debugger.runReport(ee);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDrop(EntityDeathEvent e) {
|
||||
try {
|
||||
if (ents.containsKey(e.getEntity().getUniqueId())) {
|
||||
Player p = ents.get(e.getEntity().getUniqueId());
|
||||
|
||||
ItemStack item = p.getItemInHand();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
Location location = Arconix.pl().getApi().serialize().unserializeLocation(meta.getLore().get(1).replaceAll("§", ""));
|
||||
if (location.getBlock().getType() == Material.CHEST) {
|
||||
InventoryHolder ih = (InventoryHolder) location.getBlock().getState();
|
||||
for (ItemStack is : e.getDrops()) {
|
||||
ih.getInventory().addItem(is);
|
||||
}
|
||||
e.getDrops().clear();
|
||||
}
|
||||
}
|
||||
} catch (Exception ee) {
|
||||
Debugger.runReport(ee);
|
||||
}
|
||||
}
|
||||
|
||||
private int getItemCount(Inventory inventory, ItemStack item) {
|
||||
int amount = 0;
|
||||
|
||||
for (ItemStack inventoryItem : inventory) {
|
||||
if (!item.isSimilar(inventoryItem)) continue;
|
||||
amount += inventoryItem.getAmount();
|
||||
}
|
||||
|
||||
return amount;
|
||||
}
|
||||
}
|
||||
|
@ -1,101 +1,100 @@
|
||||
package com.songoda.epichoppers.Events;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Hopper.Hopper;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.Utils.Methods;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/14/2017.
|
||||
*/
|
||||
public class InteractListeners implements Listener {
|
||||
|
||||
private EpicHoppers instance;
|
||||
|
||||
public InteractListeners(EpicHoppers instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockInteract(PlayerInteractEvent e) {
|
||||
try {
|
||||
Player player = e.getPlayer();
|
||||
if (e.getAction() != Action.LEFT_CLICK_BLOCK
|
||||
|| e.getClickedBlock() == null
|
||||
|| player.isSneaking()
|
||||
|| !player.hasPermission("EpicHoppers.overview")
|
||||
|| !instance.hooks.canBuild(player, e.getClickedBlock().getLocation())
|
||||
|| !(e.getClickedBlock().getState() instanceof InventoryHolder || e.getClickedBlock().getType().equals(Material.ENDER_CHEST))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getClickedBlock().getType() == Material.CHEST && Methods.isSync(player)) {
|
||||
ItemStack item = e.getPlayer().getItemInHand();
|
||||
if (item.getItemMeta().getLore().size() == 2) {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.desyncchest", item.getType().toString()));
|
||||
instance.enchant.createSyncTouch(item, null);
|
||||
} else {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.syncchest", item.getType().toString()));
|
||||
instance.enchant.createSyncTouch(item, e.getClickedBlock());
|
||||
}
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!instance.sync.containsKey(player) && !instance.bsync.containsKey(player)) {
|
||||
if (e.getClickedBlock().getType() == Material.HOPPER) {
|
||||
instance.lastBlock.put(player, e.getClickedBlock());
|
||||
Hopper hopper = instance.getHopperManager().getHopper(e.getClickedBlock());
|
||||
if (instance.getConfig().getBoolean("Main.Allow Hopper Upgrading")) {
|
||||
if (player.getItemInHand().getType() != Material.WOOD_PICKAXE && player.getItemInHand().getType() != Material.STONE_PICKAXE &&
|
||||
player.getItemInHand().getType() != Material.IRON_PICKAXE && player.getItemInHand().getType() != Material.DIAMOND_PICKAXE) {
|
||||
hopper.overview(player);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else { //ToDO: What is this?
|
||||
if (player.hasPermission("EpicHoppers.Admin")) {
|
||||
instance.sync.put(player, instance.lastBlock.get(player));
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.syncnext"));
|
||||
hopper.timeout(player);
|
||||
player.closeInventory();
|
||||
}
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getClickedBlock().getType() == Material.BREWING_STAND) return;
|
||||
|
||||
if (e.getClickedBlock().getState() instanceof InventoryHolder || e.getClickedBlock().getType().equals(Material.ENDER_CHEST) && instance.getConfig().getBoolean("Main.Support Enderchests")) {
|
||||
if (instance.sync.containsKey(player) && instance.sync.get(player).equals(e.getClickedBlock()) || instance.bsync.containsKey(player) && instance.bsync.get(player).equals(e.getClickedBlock())) {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.syncself"));
|
||||
} else {
|
||||
if (instance.sync.containsKey(player)) {
|
||||
Hopper hopper = instance.getHopperManager().getHopper(instance.sync.get(player));
|
||||
hopper.sync(e.getClickedBlock(), false, player);
|
||||
} else if (instance.bsync.containsKey(player)) {
|
||||
Hopper hopper = instance.getHopperManager().getHopper(instance.bsync.get(player));
|
||||
hopper.sync(e.getClickedBlock(), true, player);
|
||||
}
|
||||
}
|
||||
e.setCancelled(true);
|
||||
instance.sync.remove(player);
|
||||
instance.bsync.remove(player);
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception ee) {
|
||||
Debugger.runReport(ee);
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.songoda.epichoppers.Events;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Hopper.Hopper;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.Utils.Methods;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/14/2017.
|
||||
*/
|
||||
public class InteractListeners implements Listener {
|
||||
|
||||
private EpicHoppers instance;
|
||||
|
||||
public InteractListeners(EpicHoppers instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockInteract(PlayerInteractEvent e) {
|
||||
try {
|
||||
Player player = e.getPlayer();
|
||||
if (e.getAction() != Action.LEFT_CLICK_BLOCK
|
||||
|| e.getClickedBlock() == null
|
||||
|| player.isSneaking()
|
||||
|| !player.hasPermission("EpicHoppers.overview")
|
||||
|| !instance.hooks.canBuild(player, e.getClickedBlock().getLocation())
|
||||
|| !(e.getClickedBlock().getState() instanceof InventoryHolder || e.getClickedBlock().getType().equals(Material.ENDER_CHEST))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getClickedBlock().getType() == Material.CHEST && Methods.isSync(player)) {
|
||||
ItemStack item = e.getPlayer().getInventory().getItemInMainHand();
|
||||
if (item.getItemMeta().getLore().size() == 2) {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.desyncchest", item.getType().toString()));
|
||||
instance.enchant.createSyncTouch(item, null);
|
||||
} else {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.syncchest", item.getType().toString()));
|
||||
instance.enchant.createSyncTouch(item, e.getClickedBlock());
|
||||
}
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!instance.sync.containsKey(player) && !instance.bsync.containsKey(player)) {
|
||||
if (e.getClickedBlock().getType() == Material.HOPPER) {
|
||||
instance.lastBlock.put(player, e.getClickedBlock());
|
||||
Hopper hopper = instance.getHopperManager().getHopper(e.getClickedBlock());
|
||||
if (instance.getConfig().getBoolean("Main.Allow Hopper Upgrading")) {
|
||||
if (!player.getInventory().getItemInMainHand().getType().name().contains("PICKAXE")) {
|
||||
hopper.overview(player);
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else { //ToDO: What is this?
|
||||
if (player.hasPermission("EpicHoppers.Admin")) {
|
||||
instance.sync.put(player, instance.lastBlock.get(player));
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.syncnext"));
|
||||
hopper.timeout(player);
|
||||
player.closeInventory();
|
||||
}
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getClickedBlock().getType() == Material.BREWING_STAND) return;
|
||||
|
||||
if (e.getClickedBlock().getState() instanceof InventoryHolder || e.getClickedBlock().getType().equals(Material.ENDER_CHEST) && instance.getConfig().getBoolean("Main.Support Enderchests")) {
|
||||
if (instance.sync.containsKey(player) && instance.sync.get(player).equals(e.getClickedBlock()) || instance.bsync.containsKey(player) && instance.bsync.get(player).equals(e.getClickedBlock())) {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.syncself"));
|
||||
} else {
|
||||
if (instance.sync.containsKey(player)) {
|
||||
Hopper hopper = instance.getHopperManager().getHopper(instance.sync.get(player));
|
||||
hopper.sync(e.getClickedBlock(), false, player);
|
||||
} else if (instance.bsync.containsKey(player)) {
|
||||
Hopper hopper = instance.getHopperManager().getHopper(instance.bsync.get(player));
|
||||
hopper.sync(e.getClickedBlock(), true, player);
|
||||
}
|
||||
}
|
||||
e.setCancelled(true);
|
||||
instance.sync.remove(player);
|
||||
instance.bsync.remove(player);
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception ee) {
|
||||
Debugger.runReport(ee);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,212 +1,212 @@
|
||||
package com.songoda.epichoppers.Events;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Hopper.Hopper;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.Utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.*;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/14/2017.
|
||||
*/
|
||||
public class InventoryListeners implements Listener {
|
||||
|
||||
private EpicHoppers instance;
|
||||
|
||||
public InventoryListeners(EpicHoppers instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent e) {
|
||||
try {
|
||||
|
||||
Inventory inv = e.getInventory();
|
||||
Player player = (Player) e.getWhoClicked();
|
||||
if (inv == null || e.getCurrentItem() == null) return;
|
||||
|
||||
if (e.getCursor() != null && e.getCurrentItem() != null) {
|
||||
ItemStack c = e.getCursor();
|
||||
ItemStack item = e.getCurrentItem();
|
||||
if (c.hasItemMeta()
|
||||
&& c.getItemMeta().hasLore()
|
||||
&& c.getType() == Material.ENCHANTED_BOOK
|
||||
&& (item.getType().name().toUpperCase().contains("AXE") || item.getType().name().toUpperCase().contains("SPADE") || item.getType().name().toUpperCase().contains("SWORD"))
|
||||
&& c.getItemMeta().getLore().equals(instance.enchant.getbook().getItemMeta().getLore())) {
|
||||
instance.enchant.createSyncTouch(item, null);
|
||||
e.setCancelled(true);
|
||||
player.setItemOnCursor(new ItemStack(Material.AIR));
|
||||
player.updateInventory();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if (!e.getCurrentItem().hasItemMeta()) return;
|
||||
|
||||
if (doFilter(e)) return;
|
||||
|
||||
if (e.getSlot() != 64537
|
||||
&& e.getInventory().getType() == InventoryType.ANVIL
|
||||
&& e.getAction() != InventoryAction.NOTHING
|
||||
&& e.getCurrentItem().getType() != Material.AIR) {
|
||||
ItemStack item = e.getCurrentItem();
|
||||
if (item.getType() == Material.HOPPER) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!instance.inShow.containsKey(player.getUniqueId()) || instance.inFilter.containsKey(player.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
e.setCancelled(true);
|
||||
Hopper hopper = instance.getHopperManager().getHopper(instance.lastBlock.get(player));
|
||||
if (e.getCurrentItem().getItemMeta().hasDisplayName()
|
||||
&& e.getCurrentItem().getItemMeta().getDisplayName().equals(instance.getLocale().getMessage("interface.hopper.perltitle"))
|
||||
&& (instance.getConfig().getBoolean("Main.Allow Players To Teleport Through Hoppers") || player.hasPermission("EpicHoppers.Teleport"))) {
|
||||
if (e.isLeftClick()) {
|
||||
if (hopper.getSyncedBlock() != null) {
|
||||
instance.getTeleportHandler().tpPlayer(player, hopper);
|
||||
}
|
||||
} else {
|
||||
if (!hopper.isWalkOnTeleport()) {
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.walkteleenabled"));
|
||||
hopper.setWalkOnTeleport(true);
|
||||
} else {
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.walkteledisabled"));
|
||||
hopper.setWalkOnTeleport(false);
|
||||
}
|
||||
}
|
||||
player.closeInventory();
|
||||
|
||||
|
||||
} else if (e.getCurrentItem().getItemMeta().hasDisplayName() && e.getCurrentItem().getItemMeta().getDisplayName().equals(instance.getLocale().getMessage("interface.hopper.filtertitle")) && player.hasPermission("EpicHoppers.Filter")) {
|
||||
if (!e.getCurrentItem().getItemMeta().getDisplayName().equals("§l")) {
|
||||
hopper.filter(player);
|
||||
}
|
||||
} else if (e.getSlot() == 11 && player.hasPermission("EpicHoppers.Upgrade.XP")) {
|
||||
if (!e.getCurrentItem().getItemMeta().getDisplayName().equals("§l")) {
|
||||
hopper.upgrade("XP", player);
|
||||
player.closeInventory();
|
||||
}
|
||||
} else if (e.getSlot() == 15 && player.hasPermission("EpicHoppers.Upgrade.ECO")) {
|
||||
if (!e.getCurrentItem().getItemMeta().getDisplayName().equals("§l")) {
|
||||
hopper.upgrade("ECO", player);
|
||||
player.closeInventory();
|
||||
}
|
||||
} else if (e.getSlot() == 22) {
|
||||
if (e.isRightClick()) {
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.desync"));
|
||||
hopper.setSyncedBlock(null);
|
||||
} else {
|
||||
boolean can = true;
|
||||
if (hopper.getLastPlayer() != null) {
|
||||
if (!hopper.getLastPlayer().equals(player.getUniqueId())) {
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.syncdidnotplace"));
|
||||
can = false;
|
||||
}
|
||||
}
|
||||
if (can) {
|
||||
instance.sync.put(player, instance.lastBlock.get(player));
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.syncnext"));
|
||||
hopper.timeout(player);
|
||||
}
|
||||
}
|
||||
player.closeInventory();
|
||||
}
|
||||
} catch (Exception ee) {
|
||||
Debugger.runReport(ee);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean doFilter(InventoryClickEvent e) {
|
||||
Player player = (Player) e.getWhoClicked();
|
||||
if (!instance.inFilter.containsKey(player.getUniqueId())
|
||||
|| e.getInventory() == null
|
||||
|| !e.getInventory().equals(player.getOpenInventory().getTopInventory())) {
|
||||
return false;
|
||||
}
|
||||
if (e.getClick().equals(ClickType.SHIFT_LEFT)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
Hopper hopper = instance.getHopperManager().getHopper(instance.lastBlock.get(player));
|
||||
hopper.compile(player);
|
||||
if (e.getSlot() == 40) {
|
||||
instance.bsync.put(player, instance.lastBlock.get(player));
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.syncnext"));
|
||||
hopper.timeout(player);
|
||||
player.closeInventory();
|
||||
return true;
|
||||
}
|
||||
|
||||
int[] a = {0, 1, 9, 10, 18, 19, 27, 28, 36, 37, 45, 46, 7, 8, 16, 17, 25, 26, 34, 35, 43, 44, 52, 53};
|
||||
e.setCancelled(true);
|
||||
for (int aa : a) {
|
||||
if (aa != e.getSlot()) continue;
|
||||
String name = "";
|
||||
if (e.getCurrentItem().hasItemMeta() && e.getCurrentItem().getItemMeta().hasDisplayName())
|
||||
name = e.getCurrentItem().getItemMeta().getDisplayName();
|
||||
if (!name.equals(instance.getLocale().getMessage("interface.filter.whitelist")) &&
|
||||
!name.equals(instance.getLocale().getMessage("interface.filter.blacklist")) &&
|
||||
!name.equals(instance.getLocale().getMessage("interface.filter.void"))) {
|
||||
e.setCancelled(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (e.getCursor().getType().equals(Material.AIR)) return true;
|
||||
if (e.getCursor().getAmount() != 1) {
|
||||
e.setCancelled(true);
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.onlyone"));
|
||||
return true;
|
||||
}
|
||||
|
||||
e.setCancelled(false);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> player.setItemOnCursor(new ItemStack(Material.AIR)), 1L);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDrop(PlayerDropItemEvent e) {
|
||||
|
||||
ItemStack item = e.getItemDrop().getItemStack();
|
||||
|
||||
if (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String name = item.getItemMeta().getDisplayName();
|
||||
|
||||
if (!name.equals(instance.getLocale().getMessage("interface.filter.whitelist")) &&
|
||||
!name.equals(instance.getLocale().getMessage("interface.filter.blacklist")) &&
|
||||
!name.equals(instance.getLocale().getMessage("interface.filter.void"))) {
|
||||
return;
|
||||
}
|
||||
e.getItemDrop().remove();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClose(InventoryCloseEvent event) {
|
||||
try {
|
||||
final Player player = (Player) event.getPlayer();
|
||||
instance.inShow.remove(player.getUniqueId());
|
||||
if (instance.inFilter.containsKey(player.getUniqueId())) {
|
||||
|
||||
instance.getHopperManager().getHopper(instance.lastBlock.get(player)).compile(player);
|
||||
instance.inFilter.remove(player.getUniqueId());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
package com.songoda.epichoppers.Events;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Hopper.Hopper;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.Utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.*;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/14/2017.
|
||||
*/
|
||||
public class InventoryListeners implements Listener {
|
||||
|
||||
private EpicHoppers instance;
|
||||
|
||||
public InventoryListeners(EpicHoppers instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent e) {
|
||||
try {
|
||||
|
||||
Inventory inv = e.getInventory();
|
||||
Player player = (Player) e.getWhoClicked();
|
||||
if (inv == null || e.getCurrentItem() == null) return;
|
||||
|
||||
if (e.getCursor() != null && e.getCurrentItem() != null) {
|
||||
ItemStack c = e.getCursor();
|
||||
ItemStack item = e.getCurrentItem();
|
||||
if (c.hasItemMeta()
|
||||
&& c.getItemMeta().hasLore()
|
||||
&& c.getType() == Material.ENCHANTED_BOOK
|
||||
&& (item.getType().name().toUpperCase().contains("AXE") || item.getType().name().toUpperCase().contains("SPADE") || item.getType().name().toUpperCase().contains("SWORD"))
|
||||
&& c.getItemMeta().getLore().equals(instance.enchant.getbook().getItemMeta().getLore())) {
|
||||
instance.enchant.createSyncTouch(item, null);
|
||||
e.setCancelled(true);
|
||||
player.setItemOnCursor(new ItemStack(Material.AIR));
|
||||
player.updateInventory();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if (!e.getCurrentItem().hasItemMeta()) return;
|
||||
|
||||
if (doFilter(e)) return;
|
||||
|
||||
if (e.getSlot() != 64537
|
||||
&& e.getInventory().getType() == InventoryType.ANVIL
|
||||
&& e.getAction() != InventoryAction.NOTHING
|
||||
&& e.getCurrentItem().getType() != Material.AIR) {
|
||||
ItemStack item = e.getCurrentItem();
|
||||
if (item.getType() == Material.HOPPER) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!instance.inShow.containsKey(player.getUniqueId()) || instance.inFilter.containsKey(player.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
e.setCancelled(true);
|
||||
Hopper hopper = instance.getHopperManager().getHopper(instance.lastBlock.get(player));
|
||||
if (e.getCurrentItem().getItemMeta().hasDisplayName()
|
||||
&& e.getCurrentItem().getItemMeta().getDisplayName().equals(instance.getLocale().getMessage("interface.hopper.perltitle"))
|
||||
&& (instance.getConfig().getBoolean("Main.Allow Players To Teleport Through Hoppers") || player.hasPermission("EpicHoppers.Teleport"))) {
|
||||
if (e.isLeftClick()) {
|
||||
if (hopper.getSyncedBlock() != null) {
|
||||
instance.getTeleportHandler().tpPlayer(player, hopper);
|
||||
}
|
||||
} else {
|
||||
if (!hopper.isWalkOnTeleport()) {
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.walkteleenabled"));
|
||||
hopper.setWalkOnTeleport(true);
|
||||
} else {
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.walkteledisabled"));
|
||||
hopper.setWalkOnTeleport(false);
|
||||
}
|
||||
}
|
||||
player.closeInventory();
|
||||
|
||||
|
||||
} else if (e.getCurrentItem().getItemMeta().hasDisplayName() && e.getCurrentItem().getItemMeta().getDisplayName().equals(instance.getLocale().getMessage("interface.hopper.filtertitle")) && player.hasPermission("EpicHoppers.Filter")) {
|
||||
if (!e.getCurrentItem().getItemMeta().getDisplayName().equals("§l")) {
|
||||
hopper.filter(player);
|
||||
}
|
||||
} else if (e.getSlot() == 11 && player.hasPermission("EpicHoppers.Upgrade.XP")) {
|
||||
if (!e.getCurrentItem().getItemMeta().getDisplayName().equals("§l")) {
|
||||
hopper.upgrade("XP", player);
|
||||
player.closeInventory();
|
||||
}
|
||||
} else if (e.getSlot() == 15 && player.hasPermission("EpicHoppers.Upgrade.ECO")) {
|
||||
if (!e.getCurrentItem().getItemMeta().getDisplayName().equals("§l")) {
|
||||
hopper.upgrade("ECO", player);
|
||||
player.closeInventory();
|
||||
}
|
||||
} else if (e.getSlot() == 22) {
|
||||
if (e.isRightClick()) {
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.desync"));
|
||||
hopper.setSyncedBlock(null);
|
||||
} else {
|
||||
boolean can = true;
|
||||
if (hopper.getLastPlayer() != null) {
|
||||
if (!hopper.getLastPlayer().equals(player.getUniqueId())) {
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.syncdidnotplace"));
|
||||
can = false;
|
||||
}
|
||||
}
|
||||
if (can) {
|
||||
instance.sync.put(player, instance.lastBlock.get(player));
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.syncnext"));
|
||||
hopper.timeout(player);
|
||||
}
|
||||
}
|
||||
player.closeInventory();
|
||||
}
|
||||
} catch (Exception ee) {
|
||||
Debugger.runReport(ee);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean doFilter(InventoryClickEvent e) {
|
||||
Player player = (Player) e.getWhoClicked();
|
||||
if (!instance.inFilter.containsKey(player.getUniqueId())
|
||||
|| e.getInventory() == null
|
||||
|| !e.getInventory().equals(player.getOpenInventory().getTopInventory())) {
|
||||
return false;
|
||||
}
|
||||
if (e.getClick().equals(ClickType.SHIFT_LEFT)) {
|
||||
e.setCancelled(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
Hopper hopper = instance.getHopperManager().getHopper(instance.lastBlock.get(player));
|
||||
hopper.compile(player);
|
||||
if (e.getSlot() == 40) {
|
||||
instance.bsync.put(player, instance.lastBlock.get(player));
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.syncnext"));
|
||||
hopper.timeout(player);
|
||||
player.closeInventory();
|
||||
return true;
|
||||
}
|
||||
|
||||
int[] a = {0, 1, 9, 10, 18, 19, 27, 28, 36, 37, 45, 46, 7, 8, 16, 17, 25, 26, 34, 35, 43, 44, 52, 53};
|
||||
e.setCancelled(true);
|
||||
for (int aa : a) {
|
||||
if (aa != e.getSlot()) continue;
|
||||
String name = "";
|
||||
if (e.getCurrentItem().hasItemMeta() && e.getCurrentItem().getItemMeta().hasDisplayName())
|
||||
name = e.getCurrentItem().getItemMeta().getDisplayName();
|
||||
if (!name.equals(instance.getLocale().getMessage("interface.filter.whitelist")) &&
|
||||
!name.equals(instance.getLocale().getMessage("interface.filter.blacklist")) &&
|
||||
!name.equals(instance.getLocale().getMessage("interface.filter.void"))) {
|
||||
e.setCancelled(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (e.getCursor().getType().equals(Material.AIR)) return true;
|
||||
if (e.getCursor().getAmount() != 1) {
|
||||
e.setCancelled(true);
|
||||
player.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.hopper.onlyone"));
|
||||
return true;
|
||||
}
|
||||
|
||||
e.setCancelled(false);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> player.setItemOnCursor(new ItemStack(Material.AIR)), 1L);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDrop(PlayerDropItemEvent e) {
|
||||
|
||||
ItemStack item = e.getItemDrop().getItemStack();
|
||||
|
||||
if (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String name = item.getItemMeta().getDisplayName();
|
||||
|
||||
if (!name.equals(instance.getLocale().getMessage("interface.filter.whitelist")) &&
|
||||
!name.equals(instance.getLocale().getMessage("interface.filter.blacklist")) &&
|
||||
!name.equals(instance.getLocale().getMessage("interface.filter.void"))) {
|
||||
return;
|
||||
}
|
||||
e.getItemDrop().remove();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClose(InventoryCloseEvent event) {
|
||||
try {
|
||||
final Player player = (Player) event.getPlayer();
|
||||
instance.inShow.remove(player.getUniqueId());
|
||||
if (instance.inFilter.containsKey(player.getUniqueId())) {
|
||||
|
||||
instance.getHopperManager().getHopper(instance.lastBlock.get(player)).compile(player);
|
||||
instance.inFilter.remove(player.getUniqueId());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,45 +1,45 @@
|
||||
package com.songoda.epichoppers.Events;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/14/2017.
|
||||
*/
|
||||
public class LoginListeners implements Listener {
|
||||
|
||||
private EpicHoppers instance;
|
||||
|
||||
public LoginListeners(EpicHoppers instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||
try {
|
||||
Player p = e.getPlayer();
|
||||
if (p.isOp() && instance.getConfig().getBoolean("Main.Display Helpful Tips For Operators")) {
|
||||
if (instance.getServer().getPluginManager().getPlugin("Factions") != null && instance.hooks.FactionsHook == null) {
|
||||
p.sendMessage("");
|
||||
p.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "&7Here's the deal,"));
|
||||
p.sendMessage(Arconix.pl().getApi().format().formatText("&7Because you're not using the official versions of &6Factions"));
|
||||
p.sendMessage(Arconix.pl().getApi().format().formatText("&7I cannot give you full support out of the box."));
|
||||
p.sendMessage(Arconix.pl().getApi().format().formatText("&7Things will work without it but if you wan't a flawless"));
|
||||
p.sendMessage(Arconix.pl().getApi().format().formatText("&7experience you need to download"));
|
||||
p.sendMessage(Arconix.pl().getApi().format().formatText("&7&6https://www.spigotmc.org/resources/54337/&7."));
|
||||
p.sendMessage(Arconix.pl().getApi().format().formatText("&7If you don't care and don't want to see this message again"));
|
||||
p.sendMessage(Arconix.pl().getApi().format().formatText("&7turn &6Helpful-Tips &7off in the config."));
|
||||
p.sendMessage("");
|
||||
}
|
||||
}
|
||||
} catch (Exception ee) {
|
||||
Debugger.runReport(ee);
|
||||
}
|
||||
}
|
||||
package com.songoda.epichoppers.Events;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/14/2017.
|
||||
*/
|
||||
public class LoginListeners implements Listener {
|
||||
|
||||
private EpicHoppers instance;
|
||||
|
||||
public LoginListeners(EpicHoppers instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||
try {
|
||||
Player p = e.getPlayer();
|
||||
if (p.isOp() && instance.getConfig().getBoolean("Main.Display Helpful Tips For Operators")) {
|
||||
if (instance.getServer().getPluginManager().getPlugin("Factions") != null && instance.hooks.FactionsHook == null) {
|
||||
p.sendMessage("");
|
||||
p.sendMessage(Arconix.pl().getApi().format().formatText(instance.references.getPrefix() + "&7Here's the deal,"));
|
||||
p.sendMessage(Arconix.pl().getApi().format().formatText("&7Because you're not using the official versions of &6Factions"));
|
||||
p.sendMessage(Arconix.pl().getApi().format().formatText("&7I cannot give you full support out of the box."));
|
||||
p.sendMessage(Arconix.pl().getApi().format().formatText("&7Things will work without it but if you wan't a flawless"));
|
||||
p.sendMessage(Arconix.pl().getApi().format().formatText("&7experience you need to download"));
|
||||
p.sendMessage(Arconix.pl().getApi().format().formatText("&7&6https://www.spigotmc.org/resources/54337/&7."));
|
||||
p.sendMessage(Arconix.pl().getApi().format().formatText("&7If you don't care and don't want to see this message again"));
|
||||
p.sendMessage(Arconix.pl().getApi().format().formatText("&7turn &6Helpful-Tips &7off in the config."));
|
||||
p.sendMessage("");
|
||||
}
|
||||
}
|
||||
} catch (Exception ee) {
|
||||
Debugger.runReport(ee);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,70 +1,70 @@
|
||||
package com.songoda.epichoppers.Handlers;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/14/2017.
|
||||
*/
|
||||
|
||||
public class CommandHandler implements CommandExecutor {
|
||||
|
||||
private final EpicHoppers plugin;
|
||||
|
||||
public CommandHandler(final EpicHoppers plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
try {
|
||||
if (args.length == 0 || args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("?")) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(plugin.references.getPrefix() + "&7" + plugin.getDescription().getVersion() + " Created by &5&l&oBrianna"));
|
||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(" &8- &aEH help &7Displays this page."));
|
||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(" &8- &aEH book [player] &7Gives Sync Touch book to you or a player."));
|
||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(" &8- &aEH settings &7Edit the EpicHoppers Settings."));
|
||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(" &8- &aEH reload &7Reloads Configuration and Language files."));
|
||||
sender.sendMessage("");
|
||||
} else if (args[0].equalsIgnoreCase("book")) {
|
||||
if (!sender.hasPermission("synccraft.admin") && !sender.hasPermission("epichoppers.admin")) {
|
||||
sender.sendMessage(plugin.references.getPrefix() + plugin.getLocale().getMessage("event.general.nopermission"));
|
||||
} else {
|
||||
if (args.length == 1) {
|
||||
if (sender instanceof Player)
|
||||
((Player) sender).getInventory().addItem(plugin.enchant.getbook());
|
||||
} else if (Bukkit.getPlayerExact(args[1]) == null) {
|
||||
sender.sendMessage(plugin.references.getPrefix() + Arconix.pl().getApi().format().formatText("&cThat username does not exist, or the user is not online!"));
|
||||
} else {
|
||||
Bukkit.getPlayerExact(args[1]).getInventory().addItem(plugin.enchant.getbook());
|
||||
}
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("reload")) {
|
||||
if (!sender.hasPermission("synccraft.admin") && !sender.hasPermission("epichoppers.admin")) {
|
||||
sender.sendMessage(plugin.references.getPrefix() + plugin.getLocale().getMessage("event.general.nopermission"));
|
||||
} else {
|
||||
plugin.reload();
|
||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(plugin.references.getPrefix() + "&8Configuration and Language files reloaded."));
|
||||
}
|
||||
} else if (sender instanceof Player) {
|
||||
if (args[0].equalsIgnoreCase("settings")) {
|
||||
if (!sender.hasPermission("synccraft.admin") && !sender.hasPermission("epichoppers.admin")) {
|
||||
sender.sendMessage(plugin.references.getPrefix() + plugin.getLocale().getMessage("event.general.nopermission"));
|
||||
} else {
|
||||
Player p = (Player) sender;
|
||||
plugin.sm.openSettingsManager(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
package com.songoda.epichoppers.Handlers;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/14/2017.
|
||||
*/
|
||||
|
||||
public class CommandHandler implements CommandExecutor {
|
||||
|
||||
private final EpicHoppers plugin;
|
||||
|
||||
public CommandHandler(final EpicHoppers plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
try {
|
||||
if (args.length == 0 || args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("?")) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(plugin.references.getPrefix() + "&7" + plugin.getDescription().getVersion() + " Created by &5&l&oBrianna"));
|
||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(" &8- &aEH help &7Displays this page."));
|
||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(" &8- &aEH book [player] &7Gives Sync Touch book to you or a player."));
|
||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(" &8- &aEH settings &7Edit the EpicHoppers Settings."));
|
||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(" &8- &aEH reload &7Reloads Configuration and Language files."));
|
||||
sender.sendMessage("");
|
||||
} else if (args[0].equalsIgnoreCase("book")) {
|
||||
if (!sender.hasPermission("synccraft.admin") && !sender.hasPermission("epichoppers.admin")) {
|
||||
sender.sendMessage(plugin.references.getPrefix() + plugin.getLocale().getMessage("event.general.nopermission"));
|
||||
} else {
|
||||
if (args.length == 1) {
|
||||
if (sender instanceof Player)
|
||||
((Player) sender).getInventory().addItem(plugin.enchant.getbook());
|
||||
} else if (Bukkit.getPlayerExact(args[1]) == null) {
|
||||
sender.sendMessage(plugin.references.getPrefix() + Arconix.pl().getApi().format().formatText("&cThat username does not exist, or the user is not online!"));
|
||||
} else {
|
||||
Bukkit.getPlayerExact(args[1]).getInventory().addItem(plugin.enchant.getbook());
|
||||
}
|
||||
}
|
||||
} else if (args[0].equalsIgnoreCase("reload")) {
|
||||
if (!sender.hasPermission("synccraft.admin") && !sender.hasPermission("epichoppers.admin")) {
|
||||
sender.sendMessage(plugin.references.getPrefix() + plugin.getLocale().getMessage("event.general.nopermission"));
|
||||
} else {
|
||||
plugin.reload();
|
||||
sender.sendMessage(Arconix.pl().getApi().format().formatText(plugin.references.getPrefix() + "&8Configuration and Language files reloaded."));
|
||||
}
|
||||
} else if (sender instanceof Player) {
|
||||
if (args[0].equalsIgnoreCase("settings")) {
|
||||
if (!sender.hasPermission("synccraft.admin") && !sender.hasPermission("epichoppers.admin")) {
|
||||
sender.sendMessage(plugin.references.getPrefix() + plugin.getLocale().getMessage("event.general.nopermission"));
|
||||
} else {
|
||||
Player p = (Player) sender;
|
||||
plugin.sm.openSettingsManager(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,83 +1,83 @@
|
||||
package com.songoda.epichoppers.Handlers;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/22/2017.
|
||||
*/
|
||||
public class EnchantmentHandler {
|
||||
|
||||
private EpicHoppers instance;
|
||||
|
||||
public EnchantmentHandler(EpicHoppers instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
|
||||
public EnchantmentHandler() {
|
||||
}
|
||||
|
||||
public ItemStack createSyncTouch(ItemStack item, Block b) {
|
||||
try {
|
||||
ItemMeta itemmeta = item.getItemMeta();
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
if (b != null) {
|
||||
lore.add(Arconix.pl().getApi().format().formatText("&aSync Touch"));
|
||||
lore.add(Arconix.pl().getApi().format().convertToInvisibleString(Arconix.pl().getApi().serialize().serializeLocation(b)));
|
||||
} else {
|
||||
lore.add(Arconix.pl().getApi().format().formatText("&7Sync Touch"));
|
||||
}
|
||||
itemmeta.setLore(lore);
|
||||
item.setItemMeta(itemmeta);
|
||||
return item;
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void giveSyncTouchBook(Player p) {
|
||||
try {
|
||||
boolean isEmpty = false;
|
||||
for (ItemStack item : p.getInventory().getContents()) {
|
||||
if (item == null) {
|
||||
isEmpty = true;
|
||||
}
|
||||
}
|
||||
if (!isEmpty) {
|
||||
p.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.inventory.noroom"));
|
||||
} else {
|
||||
ItemStack book = getbook();
|
||||
p.getInventory().addItem(book);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getbook() {
|
||||
try {
|
||||
ItemStack book = new ItemStack(Material.ENCHANTED_BOOK);
|
||||
ItemMeta meta = book.getItemMeta();
|
||||
meta.setDisplayName(Arconix.pl().getApi().format().formatText("&eEnchanted Book"));
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add(Arconix.pl().getApi().format().formatText("&7Sync Touch"));
|
||||
meta.setLore(lore);
|
||||
book.setItemMeta(meta);
|
||||
return book;
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
package com.songoda.epichoppers.Handlers;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/22/2017.
|
||||
*/
|
||||
public class EnchantmentHandler {
|
||||
|
||||
private EpicHoppers instance;
|
||||
|
||||
public EnchantmentHandler(EpicHoppers instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
|
||||
public EnchantmentHandler() {
|
||||
}
|
||||
|
||||
public ItemStack createSyncTouch(ItemStack item, Block b) {
|
||||
try {
|
||||
ItemMeta itemmeta = item.getItemMeta();
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
if (b != null) {
|
||||
lore.add(Arconix.pl().getApi().format().formatText("&aSync Touch"));
|
||||
lore.add(Arconix.pl().getApi().format().convertToInvisibleString(Arconix.pl().getApi().serialize().serializeLocation(b)));
|
||||
} else {
|
||||
lore.add(Arconix.pl().getApi().format().formatText("&7Sync Touch"));
|
||||
}
|
||||
itemmeta.setLore(lore);
|
||||
item.setItemMeta(itemmeta);
|
||||
return item;
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void giveSyncTouchBook(Player p) {
|
||||
try {
|
||||
boolean isEmpty = false;
|
||||
for (ItemStack item : p.getInventory().getContents()) {
|
||||
if (item == null) {
|
||||
isEmpty = true;
|
||||
}
|
||||
}
|
||||
if (!isEmpty) {
|
||||
p.sendMessage(instance.references.getPrefix() + instance.getLocale().getMessage("event.inventory.noroom"));
|
||||
} else {
|
||||
ItemStack book = getbook();
|
||||
p.getInventory().addItem(book);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getbook() {
|
||||
try {
|
||||
ItemStack book = new ItemStack(Material.ENCHANTED_BOOK);
|
||||
ItemMeta meta = book.getItemMeta();
|
||||
meta.setDisplayName(Arconix.pl().getApi().format().formatText("&eEnchanted Book"));
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add(Arconix.pl().getApi().format().formatText("&7Sync Touch"));
|
||||
meta.setLore(lore);
|
||||
book.setItemMeta(meta);
|
||||
return book;
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,114 +1,114 @@
|
||||
package com.songoda.epichoppers.Handlers;
|
||||
|
||||
import com.songoda.arconix.api.utils.ConfigWrapper;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Hooks.*;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/17/2017.
|
||||
*/
|
||||
public class HookHandler {
|
||||
|
||||
public Hook FactionsHook = null, RedProtectHook = null, ASkyBlockHook = null, USkyBlockHook = null,
|
||||
WorldGuardHook = null, GriefPreventionHook = null, PlotSquaredHook = null, KingdomsHook = null,
|
||||
TownyHook = null;
|
||||
|
||||
public ConfigWrapper hooksFile = new ConfigWrapper(EpicHoppers.getInstance(), "", "hooks.yml");
|
||||
|
||||
public HookHandler() {
|
||||
}
|
||||
|
||||
public void hook() {
|
||||
try {
|
||||
hooksFile.createNewFile("Loading hooks File", EpicHoppers.getInstance().getDescription().getName() + " hooks File");
|
||||
|
||||
new FactionsHook();
|
||||
new RedProtectHook();
|
||||
new GriefPreventionHook();
|
||||
new ASkyBlockHook();
|
||||
new USkyBlockHook();
|
||||
new WorldGuardHook();
|
||||
new PlotSquaredHook();
|
||||
new KingdomsHook();
|
||||
new TownyHook();
|
||||
|
||||
hooksFile.getConfig().options().copyDefaults(true);
|
||||
hooksFile.saveConfig();
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean isInFaction(String name, Location l) {
|
||||
if (FactionsHook != null) {
|
||||
return FactionsHook.isInClaim(name, l);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getFactionId(String name) {
|
||||
if (FactionsHook != null) {
|
||||
return FactionsHook.getClaimId(name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isInTown(String name, Location l) {
|
||||
if (TownyHook != null) {
|
||||
return TownyHook.isInClaim(name, l);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getTownId(String name) {
|
||||
if (TownyHook != null) {
|
||||
return TownyHook.getClaimId(name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isInIsland(String name, Location l) {
|
||||
if (USkyBlockHook != null)
|
||||
return USkyBlockHook.isInClaim(name, l);
|
||||
else if (ASkyBlockHook != null)
|
||||
return ASkyBlockHook.isInClaim(name, l);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getIslandId(String name) {
|
||||
try {
|
||||
return Bukkit.getOfflinePlayer(name).getUniqueId().toString();
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean canBuild(Player p, Location l) {
|
||||
boolean result = true;
|
||||
if (WorldGuardHook != null)
|
||||
result = WorldGuardHook.canBuild(p, l);
|
||||
if (RedProtectHook != null && result)
|
||||
result = RedProtectHook.canBuild(p, l);
|
||||
if (FactionsHook != null && result)
|
||||
result = FactionsHook.canBuild(p, l);
|
||||
if (ASkyBlockHook != null && result)
|
||||
result = ASkyBlockHook.canBuild(p, l);
|
||||
if (USkyBlockHook != null && result)
|
||||
result = USkyBlockHook.canBuild(p, l);
|
||||
if (GriefPreventionHook != null && result)
|
||||
result = GriefPreventionHook.canBuild(p, l);
|
||||
if (PlotSquaredHook != null && result)
|
||||
result = PlotSquaredHook.canBuild(p, l);
|
||||
if (KingdomsHook != null && result)
|
||||
result = KingdomsHook.canBuild(p, l);
|
||||
if (TownyHook != null && result)
|
||||
result = TownyHook.canBuild(p, l);
|
||||
return result;
|
||||
}
|
||||
package com.songoda.epichoppers.Handlers;
|
||||
|
||||
import com.songoda.arconix.api.utils.ConfigWrapper;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Hooks.*;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/17/2017.
|
||||
*/
|
||||
public class HookHandler {
|
||||
|
||||
public Hook FactionsHook = null, RedProtectHook = null, ASkyBlockHook = null, USkyBlockHook = null,
|
||||
WorldGuardHook = null, GriefPreventionHook = null, PlotSquaredHook = null, KingdomsHook = null,
|
||||
TownyHook = null;
|
||||
|
||||
public ConfigWrapper hooksFile = new ConfigWrapper(EpicHoppers.getInstance(), "", "hooks.yml");
|
||||
|
||||
public HookHandler() {
|
||||
}
|
||||
|
||||
public void hook() {
|
||||
try {
|
||||
hooksFile.createNewFile("Loading hooks File", EpicHoppers.getInstance().getDescription().getName() + " hooks File");
|
||||
|
||||
new FactionsHook();
|
||||
new RedProtectHook();
|
||||
new GriefPreventionHook();
|
||||
new ASkyBlockHook();
|
||||
new USkyBlockHook();
|
||||
new WorldGuardHook();
|
||||
new PlotSquaredHook();
|
||||
new KingdomsHook();
|
||||
new TownyHook();
|
||||
|
||||
hooksFile.getConfig().options().copyDefaults(true);
|
||||
hooksFile.saveConfig();
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean isInFaction(String name, Location l) {
|
||||
if (FactionsHook != null) {
|
||||
return FactionsHook.isInClaim(name, l);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getFactionId(String name) {
|
||||
if (FactionsHook != null) {
|
||||
return FactionsHook.getClaimId(name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isInTown(String name, Location l) {
|
||||
if (TownyHook != null) {
|
||||
return TownyHook.isInClaim(name, l);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getTownId(String name) {
|
||||
if (TownyHook != null) {
|
||||
return TownyHook.getClaimId(name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isInIsland(String name, Location l) {
|
||||
if (USkyBlockHook != null)
|
||||
return USkyBlockHook.isInClaim(name, l);
|
||||
else if (ASkyBlockHook != null)
|
||||
return ASkyBlockHook.isInClaim(name, l);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getIslandId(String name) {
|
||||
try {
|
||||
return Bukkit.getOfflinePlayer(name).getUniqueId().toString();
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean canBuild(Player p, Location l) {
|
||||
boolean result = true;
|
||||
if (WorldGuardHook != null)
|
||||
result = WorldGuardHook.canBuild(p, l);
|
||||
if (RedProtectHook != null && result)
|
||||
result = RedProtectHook.canBuild(p, l);
|
||||
if (FactionsHook != null && result)
|
||||
result = FactionsHook.canBuild(p, l);
|
||||
if (ASkyBlockHook != null && result)
|
||||
result = ASkyBlockHook.canBuild(p, l);
|
||||
if (USkyBlockHook != null && result)
|
||||
result = USkyBlockHook.canBuild(p, l);
|
||||
if (GriefPreventionHook != null && result)
|
||||
result = GriefPreventionHook.canBuild(p, l);
|
||||
if (PlotSquaredHook != null && result)
|
||||
result = PlotSquaredHook.canBuild(p, l);
|
||||
if (KingdomsHook != null && result)
|
||||
result = KingdomsHook.canBuild(p, l);
|
||||
if (TownyHook != null && result)
|
||||
result = TownyHook.canBuild(p, l);
|
||||
return result;
|
||||
}
|
||||
}
|
@ -1,346 +1,344 @@
|
||||
package com.songoda.epichoppers.Handlers;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.Utils.Methods;
|
||||
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.FurnaceInventory;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/14/2017.
|
||||
*/
|
||||
public class HopHandler {
|
||||
|
||||
private EpicHoppers instance;
|
||||
|
||||
public HopHandler(EpicHoppers instance) {
|
||||
try {
|
||||
this.instance = instance;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||
hopperCleaner();
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(instance, this::hopperRunner, 0, instance.getConfig().getLong("Main.Amount of Ticks Between Hops"));
|
||||
}, 40L);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void hopperCleaner() {
|
||||
try {
|
||||
if (instance.dataFile.getConfig().contains("data.sync")) {
|
||||
ConfigurationSection cs = instance.dataFile.getConfig().getConfigurationSection("data.sync");
|
||||
for (String key : cs.getKeys(false)) {
|
||||
if (Arconix.pl().getApi().serialize().unserializeLocation(key).getWorld() != null) {
|
||||
Block b = Arconix.pl().getApi().serialize().unserializeLocation(key).getBlock();
|
||||
if (b == null || !(b.getState() instanceof Hopper)) {
|
||||
instance.dataFile.getConfig().getConfigurationSection("data.sync").set(key, null);
|
||||
instance.getLogger().info("EpicHoppers Removing non-hopper entry: " + key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Block, Integer> blockTick = new HashMap<>();
|
||||
|
||||
private void hopperRunner() {
|
||||
try {
|
||||
Set<Entity> metaItems = new HashSet<>();
|
||||
|
||||
for (com.songoda.epichoppers.Hopper.Hopper hopper : instance.getHopperManager().getHoppers().values()) {
|
||||
|
||||
Location location = hopper.getLocation();
|
||||
|
||||
int x = location.getBlockX() >> 4;
|
||||
int z = location.getBlockZ() >> 4;
|
||||
|
||||
try {
|
||||
if (!location.getWorld().isChunkLoaded(x, z)) {
|
||||
continue;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
continue;
|
||||
}
|
||||
Block block = location.getBlock();
|
||||
|
||||
|
||||
if (block == null || !(block.getState() instanceof Hopper)) {
|
||||
instance.getHopperManager().removeHopper(location);
|
||||
instance.getLogger().info("EpicHoppers Removing non-hopper entry: " + location.toString());
|
||||
}
|
||||
|
||||
org.bukkit.block.Hopper hopperBlock = (org.bukkit.block.Hopper) (block != null ? block.getState() : null);
|
||||
|
||||
if (hopper.getLevel().getBlockBreak() != 0) {
|
||||
int amt = hopper.getLevel().getBlockBreak();
|
||||
if (!blockTick.containsKey(block)) {
|
||||
blockTick.put(block, 1);
|
||||
} else {
|
||||
int tick = blockTick.get(block);
|
||||
int put = tick + 1;
|
||||
blockTick.put(block, put);
|
||||
if (tick >= amt) {
|
||||
Block above = block.getRelative(0, 1, 0);
|
||||
if (above.getType() != Material.AIR && !instance.getConfig().getStringList("Main.BlockBreak Blacklisted Blocks").contains(above.getType().name())) {
|
||||
above.getWorld().playSound(above.getLocation(), Sound.BLOCK_STONE_BREAK, 1F, 1F);
|
||||
Location locationAbove = above.getLocation();
|
||||
locationAbove.add(.5, .5, .5);
|
||||
|
||||
float ox = (float) (0 + (Math.random() * .5));
|
||||
float oy = (float) (0 + (Math.random() * .5));
|
||||
float oz = (float) (0 + (Math.random() * .5));
|
||||
Arconix.pl().getApi().packetLibrary.getParticleManager().broadcastParticle(locationAbove, ox, oy, oz, 0, instance.getConfig().getString("Main.BlockBreak Particle Type"), 15);
|
||||
|
||||
above.breakNaturally();
|
||||
}
|
||||
blockTick.remove(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hopper.getLevel().getSuction() != 0) {
|
||||
int suck = hopper.getLevel().getSuction();
|
||||
double radius = suck + .5;
|
||||
|
||||
Collection<Entity> nearbyEntite = instance.v1_7
|
||||
? Methods.getNearbyEntities(block.getLocation().add(0.5, 0.5, 0.5), radius, radius, radius)
|
||||
: block.getLocation().getWorld().getNearbyEntities(block.getLocation().add(0.5, 0.5, 0.5), radius, radius, radius);
|
||||
|
||||
for (Entity e : nearbyEntite) {
|
||||
if (!(e instanceof Item) || e.getTicksLived() < 10 || e.getLocation().getBlock().getType() == Material.HOPPER) {
|
||||
continue;
|
||||
}
|
||||
ItemStack hopItem = ((Item) e).getItemStack().clone();
|
||||
if (hopItem.getType().name().contains("SHULKER_BOX"))
|
||||
continue;
|
||||
if (hopItem.hasItemMeta() && hopItem.getItemMeta().hasDisplayName() &&
|
||||
StringUtils.substring(hopItem.getItemMeta().getDisplayName(), 0, 3).equals("***")) {
|
||||
continue; //Compatibility with Shop instance: https://www.spigotmc.org/resources/shop-a-simple-intuitive-shop-instance.9628/
|
||||
}
|
||||
if (e.hasMetadata("grabbed"))
|
||||
continue;
|
||||
ItemStack item = ((Item) e).getItemStack();
|
||||
if (!canHop(hopperBlock.getInventory(), item, 1)) {
|
||||
continue;
|
||||
}
|
||||
((Item) e).setPickupDelay(999);
|
||||
e.setMetadata("grabbed", new FixedMetadataValue(instance, ""));
|
||||
metaItems.add(e);
|
||||
if (!e.isOnGround())
|
||||
continue;
|
||||
float xx = (float) (0 + (Math.random() * .3));
|
||||
float yy = (float) (0 + (Math.random() * .3));
|
||||
float zz = (float) (0 + (Math.random() * .3));
|
||||
Arconix.pl().getApi().packetLibrary.getParticleManager().broadcastParticle(e.getLocation(), xx, yy, zz, 0, "FLAME", 5);
|
||||
e.remove();
|
||||
hopperBlock.getInventory().addItem(hopItem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hopper.getSyncedBlock() == null) continue;
|
||||
Location dest = hopper.getSyncedBlock().getLocation();
|
||||
if (dest == null) {
|
||||
hopper.setSyncedBlock(null);
|
||||
continue;
|
||||
}
|
||||
int destx = location.getBlockX() >> 4;
|
||||
int destz = location.getBlockZ() >> 4;
|
||||
if (!dest.getWorld().isChunkLoaded(destx, destz)) {
|
||||
continue;
|
||||
}
|
||||
Block b2 = dest.getBlock();
|
||||
if (!b2.getType().equals(Material.HOPPER) && !b2.getType().equals(Material.CHEST) && !b2.getType().equals(Material.TRAPPED_CHEST) && !(b2.getType().equals(Material.ENDER_CHEST))) {
|
||||
hopper.setSyncedBlock(null);
|
||||
continue;
|
||||
}
|
||||
|
||||
int amt = hopper.getLevel().getAmount();
|
||||
|
||||
ItemStack[] is = hopperBlock.getInventory().getContents();
|
||||
|
||||
List<ItemStack> whiteList = hopper.getFilter().getWhiteList();
|
||||
|
||||
List<ItemStack> blackList = hopper.getFilter().getBlackList();
|
||||
|
||||
int num = 0;
|
||||
while (num != 5) {
|
||||
ItemStack it = null;
|
||||
if (is[num] != null) {
|
||||
it = is[num].clone();
|
||||
it.setAmount(1);
|
||||
}
|
||||
if (is[num] != null
|
||||
&& !whiteList.isEmpty()
|
||||
&& !whiteList.contains(it)) {
|
||||
doBlacklist(hopperBlock, hopper, is[num].clone(), is, amt, num);
|
||||
} else if (is[num] != null && !blackList.contains(it)) {
|
||||
int numm = addItem(hopperBlock, hopper, b2, is[num], is, amt, num);
|
||||
if (numm != 10)
|
||||
num = numm;
|
||||
} else if (is[num] != null && blackList.contains(it)) {
|
||||
doBlacklist(hopperBlock, hopper, is[num].clone(), is, amt, num);
|
||||
}
|
||||
num++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void doBlacklist(Hopper hopperBlock, com.songoda.epichoppers.Hopper.Hopper hopper, ItemStack item, ItemStack[] isS, int amt, int place) {
|
||||
try {
|
||||
Location loc = hopperBlock.getLocation();
|
||||
Block b = loc.getBlock();
|
||||
if (hopper.getFilter().getEndPoint() != null
|
||||
&& b != null && b.getState() instanceof Hopper) {
|
||||
Location dest = hopper.getFilter().getEndPoint().getLocation();
|
||||
int destx = loc.getBlockX() >> 4;
|
||||
int destz = loc.getBlockZ() >> 4;
|
||||
if (!dest.getWorld().isChunkLoaded(destx, destz)) {
|
||||
return;
|
||||
}
|
||||
Block b2 = dest.getBlock();
|
||||
|
||||
addItem(hopperBlock, hopper, b2, item, isS, amt, place);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
private int addItem(Hopper hopperBlock, com.songoda.epichoppers.Hopper.Hopper hopper, Block b2, ItemStack is, ItemStack[] isS, int amt, int place) {
|
||||
try {
|
||||
ItemStack it = null;
|
||||
if (is != null) {
|
||||
it = is.clone();
|
||||
it.setAmount(1);
|
||||
}
|
||||
|
||||
List<Material> ovoid = new ArrayList<>();
|
||||
|
||||
for (ItemStack iss : hopper.getFilter().getVoidList()) {
|
||||
ovoid.add(iss.getType());
|
||||
}
|
||||
|
||||
if (is.getType() == Material.AIR) {
|
||||
return 10;
|
||||
}
|
||||
ItemStack item = is;
|
||||
ItemStack newItem = is.clone();
|
||||
|
||||
if ((item.getAmount() - amt) <= 0) {
|
||||
amt = item.getAmount();
|
||||
}
|
||||
if ((item.getAmount() - amt) >= 1) {
|
||||
newItem.setAmount(newItem.getAmount() - amt);
|
||||
is = newItem.clone();
|
||||
} else {
|
||||
is = null;
|
||||
}
|
||||
|
||||
newItem.setAmount(amt);
|
||||
InventoryHolder ih = null;
|
||||
if (!b2.getType().equals(Material.ENDER_CHEST)) {
|
||||
ih = (InventoryHolder) b2.getState();
|
||||
}
|
||||
|
||||
if (b2.getType().equals(Material.ENDER_CHEST)) {
|
||||
try {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(UUID.fromString(instance.dataFile.getConfig().getString("data.enderTracker." + Arconix.pl().getApi().serialize().serializeLocation(b2))));
|
||||
if (op.isOnline() && canHop(op.getPlayer().getEnderChest(), newItem, amt)) {
|
||||
if (!ovoid.contains(it.getType())) {
|
||||
op.getPlayer().getEnderChest().addItem(newItem);
|
||||
}
|
||||
isS[place] = is;
|
||||
hopperBlock.getInventory().setContents(isS);
|
||||
}
|
||||
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
} else {
|
||||
if (!canHop(ih.getInventory(), newItem, amt) || b2.getType() == Material.BREWING_STAND) {
|
||||
return 4;
|
||||
}
|
||||
if (b2.getType() == Material.FURNACE || b2.getType() == Material.BURNING_FURNACE) {
|
||||
FurnaceInventory fi = (FurnaceInventory) ih.getInventory();
|
||||
int amtt = 0;
|
||||
boolean dont = false;
|
||||
if (fi.getSmelting() != null) {
|
||||
amtt = fi.getSmelting().getAmount();
|
||||
if (fi.getSmelting().getType() != newItem.getType()) {
|
||||
dont = true;
|
||||
} else {
|
||||
if (fi.getSmelting().getAmount() == fi.getSmelting().getMaxStackSize()) {
|
||||
dont = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!dont) {
|
||||
if (amtt + newItem.getAmount() <= 64) {
|
||||
if (!ovoid.contains(it.getType())) {
|
||||
ih.getInventory().addItem(newItem);
|
||||
}
|
||||
isS[place] = is;
|
||||
hopperBlock.getInventory().setContents(isS);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!ovoid.contains(it.getType())) {
|
||||
ih.getInventory().addItem(newItem);
|
||||
}
|
||||
isS[place] = is;
|
||||
hopperBlock.getInventory().setContents(isS);
|
||||
}
|
||||
}
|
||||
return 4;
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean canHop(Inventory i, ItemStack item, int hop) {
|
||||
try {
|
||||
if (i.firstEmpty() != -1) {
|
||||
return true;
|
||||
}
|
||||
boolean can = false;
|
||||
for (ItemStack it : i.getContents()) {
|
||||
if (it == null) {
|
||||
can = true;
|
||||
break;
|
||||
} else {
|
||||
if (it.isSimilar(item)) {
|
||||
if ((it.getAmount() + hop) <= it.getMaxStackSize()) {
|
||||
can = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return can;
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
package com.songoda.epichoppers.Handlers;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.Utils.Methods;
|
||||
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.FurnaceInventory;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/14/2017.
|
||||
*/
|
||||
public class HopHandler {
|
||||
|
||||
private EpicHoppers instance;
|
||||
|
||||
public HopHandler(EpicHoppers instance) {
|
||||
try {
|
||||
this.instance = instance;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||
hopperCleaner();
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(instance, this::hopperRunner, 0, instance.getConfig().getLong("Main.Amount of Ticks Between Hops"));
|
||||
}, 40L);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void hopperCleaner() {
|
||||
try {
|
||||
if (instance.dataFile.getConfig().contains("data.sync")) {
|
||||
ConfigurationSection cs = instance.dataFile.getConfig().getConfigurationSection("data.sync");
|
||||
for (String key : cs.getKeys(false)) {
|
||||
if (Arconix.pl().getApi().serialize().unserializeLocation(key).getWorld() != null) {
|
||||
Block b = Arconix.pl().getApi().serialize().unserializeLocation(key).getBlock();
|
||||
if (b == null || !(b.getState() instanceof Hopper)) {
|
||||
instance.dataFile.getConfig().getConfigurationSection("data.sync").set(key, null);
|
||||
instance.getLogger().info("EpicHoppers Removing non-hopper entry: " + key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Block, Integer> blockTick = new HashMap<>();
|
||||
|
||||
private void hopperRunner() {
|
||||
try {
|
||||
Set<Entity> metaItems = new HashSet<>();
|
||||
|
||||
for (com.songoda.epichoppers.Hopper.Hopper hopper : instance.getHopperManager().getHoppers().values()) {
|
||||
|
||||
Location location = hopper.getLocation();
|
||||
|
||||
int x = location.getBlockX() >> 4;
|
||||
int z = location.getBlockZ() >> 4;
|
||||
|
||||
try {
|
||||
if (!location.getWorld().isChunkLoaded(x, z)) {
|
||||
continue;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
continue;
|
||||
}
|
||||
Block block = location.getBlock();
|
||||
|
||||
|
||||
if (block == null || !(block.getState() instanceof Hopper)) {
|
||||
instance.getHopperManager().removeHopper(location);
|
||||
instance.getLogger().info("EpicHoppers Removing non-hopper entry: " + location.toString());
|
||||
}
|
||||
|
||||
org.bukkit.block.Hopper hopperBlock = (org.bukkit.block.Hopper) (block != null ? block.getState() : null);
|
||||
|
||||
if (hopper.getLevel().getBlockBreak() != 0) {
|
||||
int amt = hopper.getLevel().getBlockBreak();
|
||||
if (!blockTick.containsKey(block)) {
|
||||
blockTick.put(block, 1);
|
||||
} else {
|
||||
int tick = blockTick.get(block);
|
||||
int put = tick + 1;
|
||||
blockTick.put(block, put);
|
||||
if (tick >= amt) {
|
||||
Block above = block.getRelative(0, 1, 0);
|
||||
if (above.getType() != Material.AIR && !instance.getConfig().getStringList("Main.BlockBreak Blacklisted Blocks").contains(above.getType().name())) {
|
||||
above.getWorld().playSound(above.getLocation(), Sound.BLOCK_STONE_BREAK, 1F, 1F);
|
||||
Location locationAbove = above.getLocation();
|
||||
locationAbove.add(.5, .5, .5);
|
||||
|
||||
float ox = (float) (0 + (Math.random() * .5));
|
||||
float oy = (float) (0 + (Math.random() * .5));
|
||||
float oz = (float) (0 + (Math.random() * .5));
|
||||
Arconix.pl().getApi().packetLibrary.getParticleManager().broadcastParticle(locationAbove, ox, oy, oz, 0, instance.getConfig().getString("Main.BlockBreak Particle Type"), 15);
|
||||
|
||||
above.breakNaturally();
|
||||
}
|
||||
blockTick.remove(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hopper.getLevel().getSuction() != 0) {
|
||||
int suck = hopper.getLevel().getSuction();
|
||||
double radius = suck + .5;
|
||||
|
||||
Collection<Entity> nearbyEntite = block.getLocation().getWorld().getNearbyEntities(block.getLocation().add(0.5, 0.5, 0.5), radius, radius, radius);
|
||||
|
||||
for (Entity e : nearbyEntite) {
|
||||
if (!(e instanceof Item) || e.getTicksLived() < 10 || e.getLocation().getBlock().getType() == Material.HOPPER) {
|
||||
continue;
|
||||
}
|
||||
ItemStack hopItem = ((Item) e).getItemStack().clone();
|
||||
if (hopItem.getType().name().contains("SHULKER_BOX"))
|
||||
continue;
|
||||
if (hopItem.hasItemMeta() && hopItem.getItemMeta().hasDisplayName() &&
|
||||
StringUtils.substring(hopItem.getItemMeta().getDisplayName(), 0, 3).equals("***")) {
|
||||
continue; //Compatibility with Shop instance: https://www.spigotmc.org/resources/shop-a-simple-intuitive-shop-instance.9628/
|
||||
}
|
||||
if (e.hasMetadata("grabbed"))
|
||||
continue;
|
||||
ItemStack item = ((Item) e).getItemStack();
|
||||
if (!canHop(hopperBlock.getInventory(), item, 1)) {
|
||||
continue;
|
||||
}
|
||||
((Item) e).setPickupDelay(999);
|
||||
e.setMetadata("grabbed", new FixedMetadataValue(instance, ""));
|
||||
metaItems.add(e);
|
||||
if (!e.isOnGround())
|
||||
continue;
|
||||
float xx = (float) (0 + (Math.random() * .3));
|
||||
float yy = (float) (0 + (Math.random() * .3));
|
||||
float zz = (float) (0 + (Math.random() * .3));
|
||||
Arconix.pl().getApi().packetLibrary.getParticleManager().broadcastParticle(e.getLocation(), xx, yy, zz, 0, "FLAME", 5);
|
||||
e.remove();
|
||||
hopperBlock.getInventory().addItem(hopItem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hopper.getSyncedBlock() == null) continue;
|
||||
Location dest = hopper.getSyncedBlock().getLocation();
|
||||
if (dest == null) {
|
||||
hopper.setSyncedBlock(null);
|
||||
continue;
|
||||
}
|
||||
int destx = location.getBlockX() >> 4;
|
||||
int destz = location.getBlockZ() >> 4;
|
||||
if (!dest.getWorld().isChunkLoaded(destx, destz)) {
|
||||
continue;
|
||||
}
|
||||
Block b2 = dest.getBlock();
|
||||
if (!b2.getType().equals(Material.HOPPER) && !b2.getType().equals(Material.CHEST) && !b2.getType().equals(Material.TRAPPED_CHEST) && !(b2.getType().equals(Material.ENDER_CHEST))) {
|
||||
hopper.setSyncedBlock(null);
|
||||
continue;
|
||||
}
|
||||
|
||||
int amt = hopper.getLevel().getAmount();
|
||||
|
||||
ItemStack[] is = hopperBlock.getInventory().getContents();
|
||||
|
||||
List<ItemStack> whiteList = hopper.getFilter().getWhiteList();
|
||||
|
||||
List<ItemStack> blackList = hopper.getFilter().getBlackList();
|
||||
|
||||
int num = 0;
|
||||
while (num != 5) {
|
||||
ItemStack it = null;
|
||||
if (is[num] != null) {
|
||||
it = is[num].clone();
|
||||
it.setAmount(1);
|
||||
}
|
||||
if (is[num] != null
|
||||
&& !whiteList.isEmpty()
|
||||
&& !whiteList.contains(it)) {
|
||||
doBlacklist(hopperBlock, hopper, is[num].clone(), is, amt, num);
|
||||
} else if (is[num] != null && !blackList.contains(it)) {
|
||||
int numm = addItem(hopperBlock, hopper, b2, is[num], is, amt, num);
|
||||
if (numm != 10)
|
||||
num = numm;
|
||||
} else if (is[num] != null && blackList.contains(it)) {
|
||||
doBlacklist(hopperBlock, hopper, is[num].clone(), is, amt, num);
|
||||
}
|
||||
num++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void doBlacklist(Hopper hopperBlock, com.songoda.epichoppers.Hopper.Hopper hopper, ItemStack item, ItemStack[] isS, int amt, int place) {
|
||||
try {
|
||||
Location loc = hopperBlock.getLocation();
|
||||
Block b = loc.getBlock();
|
||||
if (hopper.getFilter().getEndPoint() != null
|
||||
&& b != null && b.getState() instanceof Hopper) {
|
||||
Location dest = hopper.getFilter().getEndPoint().getLocation();
|
||||
int destx = loc.getBlockX() >> 4;
|
||||
int destz = loc.getBlockZ() >> 4;
|
||||
if (!dest.getWorld().isChunkLoaded(destx, destz)) {
|
||||
return;
|
||||
}
|
||||
Block b2 = dest.getBlock();
|
||||
|
||||
addItem(hopperBlock, hopper, b2, item, isS, amt, place);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
private int addItem(Hopper hopperBlock, com.songoda.epichoppers.Hopper.Hopper hopper, Block b2, ItemStack is, ItemStack[] isS, int amt, int place) {
|
||||
try {
|
||||
ItemStack it = null;
|
||||
if (is != null) {
|
||||
it = is.clone();
|
||||
it.setAmount(1);
|
||||
}
|
||||
|
||||
List<Material> ovoid = new ArrayList<>();
|
||||
|
||||
for (ItemStack iss : hopper.getFilter().getVoidList()) {
|
||||
ovoid.add(iss.getType());
|
||||
}
|
||||
|
||||
if (is.getType() == Material.AIR) {
|
||||
return 10;
|
||||
}
|
||||
ItemStack item = is;
|
||||
ItemStack newItem = is.clone();
|
||||
|
||||
if ((item.getAmount() - amt) <= 0) {
|
||||
amt = item.getAmount();
|
||||
}
|
||||
if ((item.getAmount() - amt) >= 1) {
|
||||
newItem.setAmount(newItem.getAmount() - amt);
|
||||
is = newItem.clone();
|
||||
} else {
|
||||
is = null;
|
||||
}
|
||||
|
||||
newItem.setAmount(amt);
|
||||
InventoryHolder ih = null;
|
||||
if (!b2.getType().equals(Material.ENDER_CHEST)) {
|
||||
ih = (InventoryHolder) b2.getState();
|
||||
}
|
||||
|
||||
if (b2.getType().equals(Material.ENDER_CHEST)) {
|
||||
try {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(UUID.fromString(instance.dataFile.getConfig().getString("data.enderTracker." + Arconix.pl().getApi().serialize().serializeLocation(b2))));
|
||||
if (op.isOnline() && canHop(op.getPlayer().getEnderChest(), newItem, amt)) {
|
||||
if (!ovoid.contains(it.getType())) {
|
||||
op.getPlayer().getEnderChest().addItem(newItem);
|
||||
}
|
||||
isS[place] = is;
|
||||
hopperBlock.getInventory().setContents(isS);
|
||||
}
|
||||
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
} else {
|
||||
if (!canHop(ih.getInventory(), newItem, amt) || b2.getType() == Material.BREWING_STAND) {
|
||||
return 4;
|
||||
}
|
||||
if (b2.getType() == Material.FURNACE) {
|
||||
FurnaceInventory fi = (FurnaceInventory) ih.getInventory();
|
||||
int amtt = 0;
|
||||
boolean dont = false;
|
||||
if (fi.getSmelting() != null) {
|
||||
amtt = fi.getSmelting().getAmount();
|
||||
if (fi.getSmelting().getType() != newItem.getType()) {
|
||||
dont = true;
|
||||
} else {
|
||||
if (fi.getSmelting().getAmount() == fi.getSmelting().getMaxStackSize()) {
|
||||
dont = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!dont) {
|
||||
if (amtt + newItem.getAmount() <= 64) {
|
||||
if (!ovoid.contains(it.getType())) {
|
||||
ih.getInventory().addItem(newItem);
|
||||
}
|
||||
isS[place] = is;
|
||||
hopperBlock.getInventory().setContents(isS);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!ovoid.contains(it.getType())) {
|
||||
ih.getInventory().addItem(newItem);
|
||||
}
|
||||
isS[place] = is;
|
||||
hopperBlock.getInventory().setContents(isS);
|
||||
}
|
||||
}
|
||||
return 4;
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean canHop(Inventory i, ItemStack item, int hop) {
|
||||
try {
|
||||
if (i.firstEmpty() != -1) {
|
||||
return true;
|
||||
}
|
||||
boolean can = false;
|
||||
for (ItemStack it : i.getContents()) {
|
||||
if (it == null) {
|
||||
can = true;
|
||||
break;
|
||||
} else {
|
||||
if (it.isSimilar(item)) {
|
||||
if ((it.getAmount() + hop) <= it.getMaxStackSize()) {
|
||||
can = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return can;
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,109 +1,109 @@
|
||||
package com.songoda.epichoppers.Handlers;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Hopper.Hopper;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.Utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TeleportHandler {
|
||||
|
||||
//Teleport from - teleport 2
|
||||
private final Map<Location, Location> teleportFrom = new HashMap<>();
|
||||
|
||||
private EpicHoppers instance;
|
||||
|
||||
public TeleportHandler(EpicHoppers instance) {
|
||||
try {
|
||||
this.instance = instance;
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(instance, this::teleportRunner, 0, instance.getConfig().getLong("Main.Amount of Ticks Between Teleport"));
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void teleportRunner() {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (!instance.getConfig().getBoolean("Main.Allow Players To Teleport Through Hoppers") || !player.hasPermission("EpicHoppers.Teleport")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Location location = player.getLocation().getBlock().getRelative(BlockFace.DOWN).getLocation();
|
||||
|
||||
if (!instance.getHopperManager().isHopper(location)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Hopper hopper = instance.getHopperManager().getHopper(location);
|
||||
|
||||
if (!hopper.isWalkOnTeleport()) continue;
|
||||
|
||||
if (instance.lastTp.containsKey(player)) {
|
||||
long duration = (new Date()).getTime() - instance.lastTp.get(player).getTime();
|
||||
if (duration <= 5 * 1000) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
tpPlayer(player, hopper);
|
||||
instance.lastTp.put(player, new Date());
|
||||
}
|
||||
}
|
||||
|
||||
public void tpPlayer(Player player, Hopper hopper) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
Block next = hopper.getLocation().getBlock();
|
||||
int num = 1;
|
||||
while (instance.getHopperManager().isHopper(next.getLocation()) && instance.getHopperManager().getHopper(next.getLocation()).getSyncedBlock() != null && num != 15) {
|
||||
Hopper nextHopper = instance.getHopperManager().getHopper(next);
|
||||
if (nextHopper.getSyncedBlock() != null) {
|
||||
next = nextHopper.getSyncedBlock();
|
||||
}
|
||||
if (!next.getType().equals(Material.HOPPER)) {
|
||||
instance.getHopperManager().removeHopper(nextHopper.getLocation());
|
||||
break;
|
||||
}
|
||||
|
||||
Location location = next.getLocation();
|
||||
location.setX(location.getX() + 0.5);
|
||||
location.setZ(location.getZ() + 0.5);
|
||||
location.setY(location.getY() + 1);
|
||||
location.setPitch(player.getLocation().getPitch());
|
||||
location.setDirection(player.getLocation().getDirection());
|
||||
player.teleport(location);
|
||||
next = player.getLocation().subtract(0, 0.5, 0).getBlock();
|
||||
|
||||
num++;
|
||||
}
|
||||
if (num == 1 && teleportFrom.containsKey(hopper.getLocation())) {
|
||||
Location location = teleportFrom.get(hopper.getLocation());
|
||||
location.setX(location.getX() + 0.5);
|
||||
location.setZ(location.getZ() + 0.5);
|
||||
location.setY(location.getY() + 1);
|
||||
location.setPitch(player.getLocation().getPitch());
|
||||
location.setDirection(player.getLocation().getDirection());
|
||||
player.teleport(location);
|
||||
next = player.getLocation().subtract(0, 0.5, 0).getBlock();
|
||||
num ++;
|
||||
|
||||
}
|
||||
if (num != 1) {
|
||||
teleportFrom.put(next.getLocation(), hopper.getLocation());
|
||||
Methods.doParticles(player, hopper.getLocation());
|
||||
Methods.doParticles(player, next.getLocation());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.songoda.epichoppers.Handlers;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Hopper.Hopper;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.Utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class TeleportHandler {
|
||||
|
||||
//Teleport from - teleport 2
|
||||
private final Map<Location, Location> teleportFrom = new HashMap<>();
|
||||
|
||||
private EpicHoppers instance;
|
||||
|
||||
public TeleportHandler(EpicHoppers instance) {
|
||||
try {
|
||||
this.instance = instance;
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(instance, this::teleportRunner, 0, instance.getConfig().getLong("Main.Amount of Ticks Between Teleport"));
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void teleportRunner() {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (!instance.getConfig().getBoolean("Main.Allow Players To Teleport Through Hoppers") || !player.hasPermission("EpicHoppers.Teleport")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Location location = player.getLocation().getBlock().getRelative(BlockFace.DOWN).getLocation();
|
||||
|
||||
if (!instance.getHopperManager().isHopper(location)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Hopper hopper = instance.getHopperManager().getHopper(location);
|
||||
|
||||
if (!hopper.isWalkOnTeleport()) continue;
|
||||
|
||||
if (instance.lastTp.containsKey(player)) {
|
||||
long duration = (new Date()).getTime() - instance.lastTp.get(player).getTime();
|
||||
if (duration <= 5 * 1000) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
tpPlayer(player, hopper);
|
||||
instance.lastTp.put(player, new Date());
|
||||
}
|
||||
}
|
||||
|
||||
public void tpPlayer(Player player, Hopper hopper) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
Block next = hopper.getLocation().getBlock();
|
||||
int num = 1;
|
||||
while (instance.getHopperManager().isHopper(next.getLocation()) && instance.getHopperManager().getHopper(next.getLocation()).getSyncedBlock() != null && num != 15) {
|
||||
Hopper nextHopper = instance.getHopperManager().getHopper(next);
|
||||
if (nextHopper.getSyncedBlock() != null) {
|
||||
next = nextHopper.getSyncedBlock();
|
||||
}
|
||||
if (!next.getType().equals(Material.HOPPER)) {
|
||||
instance.getHopperManager().removeHopper(nextHopper.getLocation());
|
||||
break;
|
||||
}
|
||||
|
||||
Location location = next.getLocation();
|
||||
location.setX(location.getX() + 0.5);
|
||||
location.setZ(location.getZ() + 0.5);
|
||||
location.setY(location.getY() + 1);
|
||||
location.setPitch(player.getLocation().getPitch());
|
||||
location.setDirection(player.getLocation().getDirection());
|
||||
player.teleport(location);
|
||||
next = player.getLocation().subtract(0, 0.5, 0).getBlock();
|
||||
|
||||
num++;
|
||||
}
|
||||
if (num == 1 && teleportFrom.containsKey(hopper.getLocation())) {
|
||||
Location location = teleportFrom.get(hopper.getLocation());
|
||||
location.setX(location.getX() + 0.5);
|
||||
location.setZ(location.getZ() + 0.5);
|
||||
location.setY(location.getY() + 1);
|
||||
location.setPitch(player.getLocation().getPitch());
|
||||
location.setDirection(player.getLocation().getDirection());
|
||||
player.teleport(location);
|
||||
next = player.getLocation().subtract(0, 0.5, 0).getBlock();
|
||||
num ++;
|
||||
|
||||
}
|
||||
if (num != 1) {
|
||||
teleportFrom.put(next.getLocation(), hopper.getLocation());
|
||||
Methods.doParticles(player, hopper.getLocation());
|
||||
Methods.doParticles(player, next.getLocation());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,64 +1,64 @@
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.wasteofplastic.askyblock.ASkyBlockAPI;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/17/2017.
|
||||
*/
|
||||
public class ASkyBlockHook extends Hook {
|
||||
|
||||
private ASkyBlockAPI as;
|
||||
|
||||
public ASkyBlockHook() {
|
||||
super("ASkyblock");
|
||||
if (isEnabled()) {
|
||||
as = ASkyBlockAPI.getInstance();
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
plugin.hooks.ASkyBlockHook = this;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(Player p, Location location) {
|
||||
try {
|
||||
if (hasBypass(p) || as.getIslandAt(location) == null) return true;
|
||||
|
||||
UUID owner = as.getOwner(location);
|
||||
List<UUID> list = as.getTeamMembers(owner);
|
||||
Set<Location> list2 = as.getCoopIslands(p);
|
||||
|
||||
if (owner == null) return true;
|
||||
|
||||
for (UUID uuid : list) {
|
||||
if (uuid.equals(p.getUniqueId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for (Location loc : list2) {
|
||||
if (as.getIslandAt(location).getOwner().equals(as.getIslandAt(loc).getOwner())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return owner.equals(p.getUniqueId());
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInClaim(String uuid, Location location) {
|
||||
return as.getOwner(location).toString().equals(uuid);
|
||||
}
|
||||
|
||||
}
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.wasteofplastic.askyblock.ASkyBlockAPI;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/17/2017.
|
||||
*/
|
||||
public class ASkyBlockHook extends Hook {
|
||||
|
||||
private ASkyBlockAPI as;
|
||||
|
||||
public ASkyBlockHook() {
|
||||
super("ASkyblock");
|
||||
if (isEnabled()) {
|
||||
as = ASkyBlockAPI.getInstance();
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
plugin.hooks.ASkyBlockHook = this;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(Player p, Location location) {
|
||||
try {
|
||||
if (hasBypass(p) || as.getIslandAt(location) == null) return true;
|
||||
|
||||
UUID owner = as.getOwner(location);
|
||||
List<UUID> list = as.getTeamMembers(owner);
|
||||
Set<Location> list2 = as.getCoopIslands(p);
|
||||
|
||||
if (owner == null) return true;
|
||||
|
||||
for (UUID uuid : list) {
|
||||
if (uuid.equals(p.getUniqueId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
for (Location loc : list2) {
|
||||
if (as.getIslandAt(location).getOwner().equals(as.getIslandAt(loc).getOwner())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return owner.equals(p.getUniqueId());
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInClaim(String uuid, Location location) {
|
||||
return as.getOwner(location).toString().equals(uuid);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,56 +1,56 @@
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import me.markeh.factionsframework.entities.FPlayer;
|
||||
import me.markeh.factionsframework.entities.FPlayers;
|
||||
import me.markeh.factionsframework.entities.Faction;
|
||||
import me.markeh.factionsframework.entities.Factions;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/17/2017.
|
||||
*/
|
||||
public class FactionsHook extends Hook {
|
||||
|
||||
public FactionsHook() {
|
||||
super("Factions");
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
if (isEnabled())
|
||||
plugin.hooks.GriefPreventionHook = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(Player p, Location location) {
|
||||
try {
|
||||
FPlayer fp = FPlayers.getBySender(p);
|
||||
|
||||
Faction faction = Factions.getFactionAt(location);
|
||||
|
||||
return (fp.getFaction().equals(faction) || faction.isNone());
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInClaim(String id, Location location) {
|
||||
Faction faction = Factions.getFactionAt(location);
|
||||
|
||||
return faction.getId().equals(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClaimId(String name) {
|
||||
try {
|
||||
Faction faction = Factions.getByName(name, "");
|
||||
|
||||
return faction.getId();
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import me.markeh.factionsframework.entities.FPlayer;
|
||||
import me.markeh.factionsframework.entities.FPlayers;
|
||||
import me.markeh.factionsframework.entities.Faction;
|
||||
import me.markeh.factionsframework.entities.Factions;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/17/2017.
|
||||
*/
|
||||
public class FactionsHook extends Hook {
|
||||
|
||||
public FactionsHook() {
|
||||
super("Factions");
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
if (isEnabled())
|
||||
plugin.hooks.GriefPreventionHook = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(Player p, Location location) {
|
||||
try {
|
||||
FPlayer fp = FPlayers.getBySender(p);
|
||||
|
||||
Faction faction = Factions.getFactionAt(location);
|
||||
|
||||
return (fp.getFaction().equals(faction) || faction.isNone());
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInClaim(String id, Location location) {
|
||||
Faction faction = Factions.getFactionAt(location);
|
||||
|
||||
return faction.getId().equals(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClaimId(String name) {
|
||||
try {
|
||||
Faction faction = Factions.getByName(name, "");
|
||||
|
||||
return faction.getId();
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,37 +1,37 @@
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import me.ryanhamshire.GriefPrevention.Claim;
|
||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/17/2017.
|
||||
*/
|
||||
public class GriefPreventionHook extends Hook {
|
||||
|
||||
public GriefPreventionHook() {
|
||||
super("GriefPrevention");
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
if (isEnabled())
|
||||
plugin.hooks.GriefPreventionHook = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(Player p, Location location) {
|
||||
try {
|
||||
if (hasBypass(p))
|
||||
return true;
|
||||
|
||||
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(location, false, null);
|
||||
return claim != null && claim.allowBuild(p, Material.STONE) == null;
|
||||
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import me.ryanhamshire.GriefPrevention.Claim;
|
||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/17/2017.
|
||||
*/
|
||||
public class GriefPreventionHook extends Hook {
|
||||
|
||||
public GriefPreventionHook() {
|
||||
super("GriefPrevention");
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
if (isEnabled())
|
||||
plugin.hooks.GriefPreventionHook = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(Player p, Location location) {
|
||||
try {
|
||||
if (hasBypass(p))
|
||||
return true;
|
||||
|
||||
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(location, false, null);
|
||||
return claim != null && claim.allowBuild(p, Material.STONE) == null;
|
||||
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,38 +1,38 @@
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public abstract class Hook {
|
||||
|
||||
final String pluginName;
|
||||
|
||||
protected Hook(String pluginName) {
|
||||
this.pluginName = pluginName;
|
||||
if (isEnabled())
|
||||
EpicHoppers.getInstance().hooks.hooksFile.getConfig().addDefault("hooks." + pluginName, true);
|
||||
}
|
||||
|
||||
protected boolean isEnabled() {
|
||||
return (Bukkit.getPluginManager().isPluginEnabled(pluginName)
|
||||
&& EpicHoppers.getInstance().hooks.hooksFile.getConfig().getBoolean("hooks." + pluginName, true));
|
||||
}
|
||||
|
||||
boolean hasBypass(Player p) {
|
||||
return p.hasPermission(EpicHoppers.getInstance().getDescription().getName() + ".bypass");
|
||||
}
|
||||
|
||||
public abstract boolean canBuild(Player p, Location location);
|
||||
|
||||
public boolean isInClaim(String id, Location location) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getClaimId(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public abstract class Hook {
|
||||
|
||||
final String pluginName;
|
||||
|
||||
protected Hook(String pluginName) {
|
||||
this.pluginName = pluginName;
|
||||
if (isEnabled())
|
||||
EpicHoppers.getInstance().hooks.hooksFile.getConfig().addDefault("hooks." + pluginName, true);
|
||||
}
|
||||
|
||||
protected boolean isEnabled() {
|
||||
return (Bukkit.getPluginManager().isPluginEnabled(pluginName)
|
||||
&& EpicHoppers.getInstance().hooks.hooksFile.getConfig().getBoolean("hooks." + pluginName, true));
|
||||
}
|
||||
|
||||
boolean hasBypass(Player p) {
|
||||
return p.hasPermission(EpicHoppers.getInstance().getDescription().getName() + ".bypass");
|
||||
}
|
||||
|
||||
public abstract boolean canBuild(Player p, Location location);
|
||||
|
||||
public boolean isInClaim(String id, Location location) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getClaimId(String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,43 +1,43 @@
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.kingdoms.constants.land.Land;
|
||||
import org.kingdoms.constants.land.SimpleChunkLocation;
|
||||
import org.kingdoms.constants.player.OfflineKingdomPlayer;
|
||||
import org.kingdoms.manager.game.GameManagement;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/17/2017.
|
||||
*/
|
||||
public class KingdomsHook extends Hook {
|
||||
|
||||
public KingdomsHook() {
|
||||
super("Kingdoms");
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
if (isEnabled())
|
||||
plugin.hooks.KingdomsHook = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(Player p, Location location) {
|
||||
try {
|
||||
if (hasBypass(p)) return true;
|
||||
|
||||
OfflineKingdomPlayer pl = GameManagement.getPlayerManager().getOfflineKingdomPlayer(p);
|
||||
if (pl.getKingdomPlayer().getKingdom() == null) return true;
|
||||
|
||||
SimpleChunkLocation chunkLocation = new SimpleChunkLocation(location.getWorld().getName(), location.getChunk().getX(), location.getChunk().getZ());
|
||||
Land land = GameManagement.getLandManager().getOrLoadLand(chunkLocation);
|
||||
String owner = land.getOwner();
|
||||
|
||||
return pl.getKingdomPlayer().getKingdom().getKingdomName().equals(owner) || owner == null;
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.kingdoms.constants.land.Land;
|
||||
import org.kingdoms.constants.land.SimpleChunkLocation;
|
||||
import org.kingdoms.constants.player.OfflineKingdomPlayer;
|
||||
import org.kingdoms.manager.game.GameManagement;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/17/2017.
|
||||
*/
|
||||
public class KingdomsHook extends Hook {
|
||||
|
||||
public KingdomsHook() {
|
||||
super("Kingdoms");
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
if (isEnabled())
|
||||
plugin.hooks.KingdomsHook = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(Player p, Location location) {
|
||||
try {
|
||||
if (hasBypass(p)) return true;
|
||||
|
||||
OfflineKingdomPlayer pl = GameManagement.getPlayerManager().getOfflineKingdomPlayer(p);
|
||||
if (pl.getKingdomPlayer().getKingdom() == null) return true;
|
||||
|
||||
SimpleChunkLocation chunkLocation = new SimpleChunkLocation(location.getWorld().getName(), location.getChunk().getX(), location.getChunk().getZ());
|
||||
Land land = GameManagement.getLandManager().getOrLoadLand(chunkLocation);
|
||||
String owner = land.getOwner();
|
||||
|
||||
return pl.getKingdomPlayer().getKingdom().getKingdomName().equals(owner) || owner == null;
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,37 +1,37 @@
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
|
||||
import com.intellectualcrafters.plot.api.PlotAPI;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/17/2017.
|
||||
*/
|
||||
public class PlotSquaredHook extends Hook {
|
||||
|
||||
private PlotAPI plotAPI;
|
||||
|
||||
public PlotSquaredHook() {
|
||||
super("PlotSquared");
|
||||
if (isEnabled()) {
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
plugin.hooks.PlotSquaredHook = this;
|
||||
this.plotAPI = new PlotAPI();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(Player p, Location location) {
|
||||
try {
|
||||
return hasBypass(p)
|
||||
|| (plotAPI.getPlot(location) != null
|
||||
&& plotAPI.isInPlot(p)
|
||||
&& plotAPI.getPlot(p) == plotAPI.getPlot(location));
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
|
||||
import com.intellectualcrafters.plot.api.PlotAPI;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/17/2017.
|
||||
*/
|
||||
public class PlotSquaredHook extends Hook {
|
||||
|
||||
private PlotAPI plotAPI;
|
||||
|
||||
public PlotSquaredHook() {
|
||||
super("PlotSquared");
|
||||
if (isEnabled()) {
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
plugin.hooks.PlotSquaredHook = this;
|
||||
this.plotAPI = new PlotAPI();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(Player p, Location location) {
|
||||
try {
|
||||
return hasBypass(p)
|
||||
|| (plotAPI.getPlot(location) != null
|
||||
&& plotAPI.isInPlot(p)
|
||||
&& plotAPI.getPlot(p) == plotAPI.getPlot(location));
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,33 +1,33 @@
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
|
||||
import br.net.fabiozumbi12.RedProtect.Bukkit.API.RedProtectAPI;
|
||||
import br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/17/2017.
|
||||
*/
|
||||
public class RedProtectHook extends Hook {
|
||||
|
||||
public RedProtectHook() {
|
||||
super("RedProtect");
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
if (isEnabled())
|
||||
plugin.hooks.RedProtectHook = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(Player p, Location location) {
|
||||
try {
|
||||
RedProtectAPI rpAPI = RedProtect.get().getAPI();
|
||||
return hasBypass(p) || (rpAPI.getRegion(location) != null && rpAPI.getRegion(location).canBuild(p));
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
|
||||
import br.net.fabiozumbi12.RedProtect.Bukkit.API.RedProtectAPI;
|
||||
import br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/17/2017.
|
||||
*/
|
||||
public class RedProtectHook extends Hook {
|
||||
|
||||
public RedProtectHook() {
|
||||
super("RedProtect");
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
if (isEnabled())
|
||||
plugin.hooks.RedProtectHook = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(Player p, Location location) {
|
||||
try {
|
||||
RedProtectAPI rpAPI = RedProtect.get().getAPI();
|
||||
return hasBypass(p) || (rpAPI.getRegion(location) != null && rpAPI.getRegion(location).canBuild(p));
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,56 +1,56 @@
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
|
||||
import com.palmergames.bukkit.towny.object.Resident;
|
||||
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/17/2017.
|
||||
*/
|
||||
public class TownyHook extends Hook {
|
||||
|
||||
public TownyHook() {
|
||||
super("Towny");
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
if (isEnabled())
|
||||
plugin.hooks.TownyHook = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(Player p, Location location) {
|
||||
try {
|
||||
if (hasBypass(p) || TownyUniverse.isWilderness(location.getBlock())) return true;
|
||||
if (!TownyUniverse.getTownBlock(location).hasTown()) return true;
|
||||
|
||||
Resident r = TownyUniverse.getDataSource().getResident(p.getName());
|
||||
return r.hasTown() && TownyUniverse.getTownName(location).equals(r.getTown().getName());
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInClaim(String id, Location location) {
|
||||
try {
|
||||
return !TownyUniverse.isWilderness(location.getBlock())
|
||||
&& TownyUniverse.getTownBlock(location).getTown().getUID() == Integer.parseInt(id);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClaimId(String name) {
|
||||
try {
|
||||
return TownyUniverse.getDataSource().getTown(name).getUID().toString();
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
|
||||
import com.palmergames.bukkit.towny.object.Resident;
|
||||
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/17/2017.
|
||||
*/
|
||||
public class TownyHook extends Hook {
|
||||
|
||||
public TownyHook() {
|
||||
super("Towny");
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
if (isEnabled())
|
||||
plugin.hooks.TownyHook = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(Player p, Location location) {
|
||||
try {
|
||||
if (hasBypass(p) || TownyUniverse.isWilderness(location.getBlock())) return true;
|
||||
if (!TownyUniverse.getTownBlock(location).hasTown()) return true;
|
||||
|
||||
Resident r = TownyUniverse.getDataSource().getResident(p.getName());
|
||||
return r.hasTown() && TownyUniverse.getTownName(location).equals(r.getTown().getName());
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInClaim(String id, Location location) {
|
||||
try {
|
||||
return !TownyUniverse.isWilderness(location.getBlock())
|
||||
&& TownyUniverse.getTownBlock(location).getTown().getUID() == Integer.parseInt(id);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClaimId(String name) {
|
||||
try {
|
||||
return TownyUniverse.getDataSource().getTown(name).getUID().toString();
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,49 +1,49 @@
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import us.talabrek.ultimateskyblock.api.uSkyBlockAPI;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/17/2017.
|
||||
*/
|
||||
public class USkyBlockHook extends Hook {
|
||||
|
||||
private uSkyBlockAPI usb;
|
||||
|
||||
public USkyBlockHook() {
|
||||
super("USkyBlock");
|
||||
if (isEnabled()) {
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
plugin.hooks.USkyBlockHook = this;
|
||||
this.usb = (uSkyBlockAPI) Bukkit.getPluginManager().getPlugin(pluginName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(Player p, Location location) {
|
||||
try {
|
||||
if (hasBypass(p)) return true;
|
||||
|
||||
for (Player pl : usb.getIslandInfo(location).getOnlineMembers()) {
|
||||
if (pl.equals(p)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return usb.getIslandInfo(location).isLeader(p);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInClaim(String uuid, Location location) {
|
||||
return usb.getIslandInfo(location).getLeader().equals(uuid);
|
||||
}
|
||||
|
||||
}
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import us.talabrek.ultimateskyblock.api.uSkyBlockAPI;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/17/2017.
|
||||
*/
|
||||
public class USkyBlockHook extends Hook {
|
||||
|
||||
private uSkyBlockAPI usb;
|
||||
|
||||
public USkyBlockHook() {
|
||||
super("USkyBlock");
|
||||
if (isEnabled()) {
|
||||
EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
plugin.hooks.USkyBlockHook = this;
|
||||
this.usb = (uSkyBlockAPI) Bukkit.getPluginManager().getPlugin(pluginName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(Player p, Location location) {
|
||||
try {
|
||||
if (hasBypass(p)) return true;
|
||||
|
||||
for (Player pl : usb.getIslandInfo(location).getOnlineMembers()) {
|
||||
if (pl.equals(p)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return usb.getIslandInfo(location).isLeader(p);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInClaim(String uuid, Location location) {
|
||||
return usb.getIslandInfo(location).getLeader().equals(uuid);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,31 +1,31 @@
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/17/2017.
|
||||
*/
|
||||
public class WorldGuardHook extends Hook {
|
||||
|
||||
private EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
|
||||
public WorldGuardHook() {
|
||||
super("WorldGuard");
|
||||
if (isEnabled())
|
||||
plugin.hooks.WorldGuardHook = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(Player p, Location location) {
|
||||
try {
|
||||
return p.hasPermission(plugin.getDescription().getName() + ".bypass") || WorldGuardPlugin.inst().canBuild(p, location);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
package com.songoda.epichoppers.Hooks;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/17/2017.
|
||||
*/
|
||||
public class WorldGuardHook extends Hook {
|
||||
|
||||
private EpicHoppers plugin = EpicHoppers.getInstance();
|
||||
|
||||
public WorldGuardHook() {
|
||||
super("WorldGuard");
|
||||
if (isEnabled())
|
||||
plugin.hooks.WorldGuardHook = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(Player p, Location location) {
|
||||
try {
|
||||
return p.hasPermission(plugin.getDescription().getName() + ".bypass") || WorldGuardPlugin.inst().canBuild(p, location);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,51 +1,51 @@
|
||||
package com.songoda.epichoppers.Hopper;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Filter {
|
||||
|
||||
private List<ItemStack> whiteList = new ArrayList<>();
|
||||
private List<ItemStack> blackList = new ArrayList<>();
|
||||
private List<ItemStack> voidList = new ArrayList<>();
|
||||
|
||||
private Block endPoint;
|
||||
|
||||
public List<ItemStack> getWhiteList() {
|
||||
if (whiteList == null) return new ArrayList<>();
|
||||
return whiteList;
|
||||
}
|
||||
|
||||
public void setWhiteList(List<ItemStack> whiteList) {
|
||||
this.whiteList = whiteList;
|
||||
}
|
||||
|
||||
public List<ItemStack> getBlackList() {
|
||||
if (blackList == null) return new ArrayList<>();
|
||||
return blackList;
|
||||
}
|
||||
|
||||
public void setBlackList(List<ItemStack> blackList) {
|
||||
this.blackList = blackList;
|
||||
}
|
||||
|
||||
public List<ItemStack> getVoidList() {
|
||||
if (voidList == null) return new ArrayList<>();
|
||||
return voidList;
|
||||
}
|
||||
|
||||
public void setVoidList(List<ItemStack> voidList) {
|
||||
this.voidList = voidList;
|
||||
}
|
||||
|
||||
public Block getEndPoint() {
|
||||
return endPoint;
|
||||
}
|
||||
|
||||
public void setEndPoint(Block endPoint) {
|
||||
this.endPoint = endPoint;
|
||||
}
|
||||
}
|
||||
package com.songoda.epichoppers.Hopper;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Filter {
|
||||
|
||||
private List<ItemStack> whiteList = new ArrayList<>();
|
||||
private List<ItemStack> blackList = new ArrayList<>();
|
||||
private List<ItemStack> voidList = new ArrayList<>();
|
||||
|
||||
private Block endPoint;
|
||||
|
||||
public List<ItemStack> getWhiteList() {
|
||||
if (whiteList == null) return new ArrayList<>();
|
||||
return whiteList;
|
||||
}
|
||||
|
||||
public void setWhiteList(List<ItemStack> whiteList) {
|
||||
this.whiteList = whiteList;
|
||||
}
|
||||
|
||||
public List<ItemStack> getBlackList() {
|
||||
if (blackList == null) return new ArrayList<>();
|
||||
return blackList;
|
||||
}
|
||||
|
||||
public void setBlackList(List<ItemStack> blackList) {
|
||||
this.blackList = blackList;
|
||||
}
|
||||
|
||||
public List<ItemStack> getVoidList() {
|
||||
if (voidList == null) return new ArrayList<>();
|
||||
return voidList;
|
||||
}
|
||||
|
||||
public void setVoidList(List<ItemStack> voidList) {
|
||||
this.voidList = voidList;
|
||||
}
|
||||
|
||||
public Block getEndPoint() {
|
||||
return endPoint;
|
||||
}
|
||||
|
||||
public void setEndPoint(Block endPoint) {
|
||||
this.endPoint = endPoint;
|
||||
}
|
||||
}
|
||||
|
@ -1,499 +1,486 @@
|
||||
package com.songoda.epichoppers.Hopper;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.Utils.Methods;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/14/2017.
|
||||
*/
|
||||
public class Hopper {
|
||||
|
||||
private Location location;
|
||||
private Level level;
|
||||
private UUID lastPlayer;
|
||||
private Block syncedBlock;
|
||||
private Filter filter;
|
||||
private boolean walkOnTeleport;
|
||||
|
||||
|
||||
public Hopper(Location location, Level level, UUID lastPlayer, Block syncedBlock, Filter filter, boolean walkOnTeleport) {
|
||||
this.location = location;
|
||||
this.level = level;
|
||||
this.syncedBlock = syncedBlock;
|
||||
this.filter = filter;
|
||||
this.lastPlayer = lastPlayer;
|
||||
this.walkOnTeleport = walkOnTeleport;
|
||||
}
|
||||
|
||||
public Hopper(Block block, Level level, UUID lastPlayer, Block syncedBlock, Filter filter, boolean walkOnTeleport) {
|
||||
this(block.getLocation(), level, lastPlayer, syncedBlock, filter, walkOnTeleport);
|
||||
}
|
||||
|
||||
public void overview(Player player) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
if (!player.hasPermission("epichoppers.overview")) return;
|
||||
|
||||
instance.lastBlock.put(player, location.getBlock());
|
||||
|
||||
Level nextLevel = instance.getLevelManager().getHighestLevel().getLevel() > level.getLevel() ? instance.getLevelManager().getLevel(level.getLevel() + 1) : null;
|
||||
|
||||
Inventory i = Bukkit.createInventory(null, 27, Methods.formatName(level.getLevel(), false));
|
||||
|
||||
ItemStack perl = new ItemStack(Material.ENDER_PEARL, 1);
|
||||
ItemMeta perlmeta = perl.getItemMeta();
|
||||
perlmeta.setDisplayName(instance.getLocale().getMessage("interface.hopper.perltitle"));
|
||||
ArrayList<String> loreperl = new ArrayList<>();
|
||||
String[] parts = instance.getLocale().getMessage("interface.hopper.perllore").split("\\|");
|
||||
for (String line : parts) {
|
||||
loreperl.add(Arconix.pl().getApi().format().formatText(line));
|
||||
}
|
||||
perlmeta.setLore(loreperl);
|
||||
perl.setItemMeta(perlmeta);
|
||||
|
||||
ItemStack filter = new ItemStack(Material.REDSTONE_COMPARATOR, 1);
|
||||
ItemMeta filtermeta = filter.getItemMeta();
|
||||
filtermeta.setDisplayName(instance.getLocale().getMessage("interface.hopper.filtertitle"));
|
||||
ArrayList<String> lorefilter = new ArrayList<>();
|
||||
parts = instance.getLocale().getMessage("interface.hopper.filterlore").split("\\|");
|
||||
for (String line : parts) {
|
||||
lorefilter.add(Arconix.pl().getApi().format().formatText(line));
|
||||
}
|
||||
filtermeta.setLore(lorefilter);
|
||||
filter.setItemMeta(filtermeta);
|
||||
|
||||
|
||||
ItemStack item = new ItemStack(Material.HOPPER, 1);
|
||||
ItemMeta itemmeta = item.getItemMeta();
|
||||
itemmeta.setDisplayName(instance.getLocale().getMessage("interface.hopper.currentlevel", level.getLevel()));
|
||||
List<String> lore = this.level.getDescription();
|
||||
lore.add("");
|
||||
if (nextLevel == null) lore.add(instance.getLocale().getMessage("interface.hopper.alreadymaxed"));
|
||||
else {
|
||||
lore.add(instance.getLocale().getMessage("interface.hopper.nextlevel", nextLevel.getLevel()));
|
||||
lore.addAll(nextLevel.getDescription());
|
||||
}
|
||||
|
||||
itemmeta.setLore(lore);
|
||||
item.setItemMeta(itemmeta);
|
||||
|
||||
ItemStack hook = new ItemStack(Material.TRIPWIRE_HOOK, 1);
|
||||
ItemMeta hookmeta = hook.getItemMeta();
|
||||
hookmeta.setDisplayName(instance.getLocale().getMessage("interface.hopper.synchopper"));
|
||||
ArrayList<String> lorehook = new ArrayList<>();
|
||||
parts = instance.getLocale().getMessage("interface.hopper.synclore").split("\\|");
|
||||
for (String line : parts) {
|
||||
lorehook.add(Arconix.pl().getApi().format().formatText(line));
|
||||
}
|
||||
hookmeta.setLore(lorehook);
|
||||
hook.setItemMeta(hookmeta);
|
||||
|
||||
ItemStack itemXP = new ItemStack(Material.valueOf(instance.getConfig().getString("Interfaces.XP Icon")), 1);
|
||||
ItemMeta itemmetaXP = itemXP.getItemMeta();
|
||||
itemmetaXP.setDisplayName(instance.getLocale().getMessage("interface.hopper.upgradewithxp"));
|
||||
ArrayList<String> loreXP = new ArrayList<>();
|
||||
if (nextLevel != null)
|
||||
loreXP.add(instance.getLocale().getMessage("interface.hopper.upgradewithxplore", nextLevel.getCostExperience()));
|
||||
else
|
||||
loreXP.add(instance.getLocale().getMessage("interface.hopper.alreadymaxed"));
|
||||
itemmetaXP.setLore(loreXP);
|
||||
itemXP.setItemMeta(itemmetaXP);
|
||||
|
||||
ItemStack itemECO = new ItemStack(Material.valueOf(instance.getConfig().getString("Interfaces.Economy Icon")), 1);
|
||||
ItemMeta itemmetaECO = itemECO.getItemMeta();
|
||||
itemmetaECO.setDisplayName(instance.getLocale().getMessage("interface.hopper.upgradewitheconomy"));
|
||||
ArrayList<String> loreECO = new ArrayList<>();
|
||||
if (nextLevel != null)
|
||||
loreECO.add(instance.getLocale().getMessage("interface.hopper.upgradewitheconomylore", Arconix.pl().getApi().format().formatEconomy(nextLevel.getCostEconomy())));
|
||||
else
|
||||
loreECO.add(instance.getLocale().getMessage("interface.hopper.alreadymaxed"));
|
||||
itemmetaECO.setLore(loreECO);
|
||||
itemECO.setItemMeta(itemmetaECO);
|
||||
|
||||
int nu = 0;
|
||||
while (nu != 27) {
|
||||
i.setItem(nu, Methods.getGlass());
|
||||
nu++;
|
||||
}
|
||||
|
||||
boolean canFilter = instance.getConfig().getBoolean("Main.Allow Players To use The Hopper Filter") && player.hasPermission("EpicHoppers.Filter");
|
||||
boolean canTeleport = instance.getConfig().getBoolean("Main.Allow Players To Teleport Through Hoppers") && player.hasPermission("EpicHoppers.Teleport");
|
||||
if (!canFilter && canTeleport)
|
||||
i.setItem(4, perl);
|
||||
else if (!canTeleport && canFilter)
|
||||
i.setItem(4, filter);
|
||||
else if (canFilter) {
|
||||
i.setItem(3, perl);
|
||||
i.setItem(5, filter);
|
||||
}
|
||||
|
||||
if (instance.getConfig().getBoolean("Main.Upgrade With XP") && player.hasPermission("EpicHoppers.Upgrade.XP")) {
|
||||
i.setItem(11, itemXP);
|
||||
}
|
||||
|
||||
i.setItem(13, item);
|
||||
i.setItem(22, hook);
|
||||
|
||||
if (instance.getConfig().getBoolean("Main.Upgrade With Economy") && player.hasPermission("EpicHoppers.Upgrade.ECO")) {
|
||||
i.setItem(15, itemECO);
|
||||
}
|
||||
|
||||
i.setItem(0, Methods.getBackgroundGlass(true));
|
||||
i.setItem(1, Methods.getBackgroundGlass(true));
|
||||
i.setItem(2, Methods.getBackgroundGlass(false));
|
||||
i.setItem(6, Methods.getBackgroundGlass(false));
|
||||
i.setItem(7, Methods.getBackgroundGlass(true));
|
||||
i.setItem(8, Methods.getBackgroundGlass(true));
|
||||
i.setItem(9, Methods.getBackgroundGlass(true));
|
||||
i.setItem(10, Methods.getBackgroundGlass(false));
|
||||
i.setItem(16, Methods.getBackgroundGlass(false));
|
||||
i.setItem(17, Methods.getBackgroundGlass(true));
|
||||
i.setItem(18, Methods.getBackgroundGlass(true));
|
||||
i.setItem(19, Methods.getBackgroundGlass(true));
|
||||
i.setItem(20, Methods.getBackgroundGlass(false));
|
||||
i.setItem(24, Methods.getBackgroundGlass(false));
|
||||
i.setItem(25, Methods.getBackgroundGlass(true));
|
||||
i.setItem(26, Methods.getBackgroundGlass(true));
|
||||
|
||||
player.openInventory(i);
|
||||
instance.inShow.put(player.getUniqueId(), this);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void filter(Player player) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
|
||||
Inventory i = Bukkit.createInventory(null, 54, Arconix.pl().getApi().format().formatText(Methods.formatName(level.getLevel(), false) + " &8-&f Filter"));
|
||||
|
||||
i.setItem(2, Methods.getBackgroundGlass(true));
|
||||
i.setItem(3, Methods.getBackgroundGlass(true));
|
||||
i.setItem(4, Methods.getBackgroundGlass(true));
|
||||
i.setItem(5, Methods.getBackgroundGlass(false));
|
||||
i.setItem(6, Methods.getBackgroundGlass(false));
|
||||
|
||||
i.setItem(11, Methods.getBackgroundGlass(true));
|
||||
i.setItem(15, Methods.getBackgroundGlass(false));
|
||||
|
||||
i.setItem(20, Methods.getBackgroundGlass(true));
|
||||
i.setItem(24, Methods.getBackgroundGlass(true));
|
||||
|
||||
i.setItem(29, Methods.getBackgroundGlass(true));
|
||||
i.setItem(33, Methods.getBackgroundGlass(true));
|
||||
|
||||
i.setItem(38, Methods.getBackgroundGlass(false));
|
||||
i.setItem(42, Methods.getBackgroundGlass(true));
|
||||
|
||||
i.setItem(47, Methods.getBackgroundGlass(false));
|
||||
i.setItem(48, Methods.getBackgroundGlass(false));
|
||||
i.setItem(49, Methods.getBackgroundGlass(true));
|
||||
i.setItem(50, Methods.getBackgroundGlass(true));
|
||||
i.setItem(51, Methods.getBackgroundGlass(true));
|
||||
|
||||
i.setItem(12, Methods.getGlass());
|
||||
i.setItem(14, Methods.getGlass());
|
||||
i.setItem(21, Methods.getGlass());
|
||||
i.setItem(22, Methods.getGlass());
|
||||
i.setItem(23, Methods.getGlass());
|
||||
i.setItem(30, Methods.getGlass());
|
||||
i.setItem(31, Methods.getGlass());
|
||||
i.setItem(32, Methods.getGlass());
|
||||
i.setItem(39, Methods.getGlass());
|
||||
i.setItem(41, Methods.getGlass());
|
||||
|
||||
ItemStack it = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 0);
|
||||
ItemMeta itm = it.getItemMeta();
|
||||
itm.setDisplayName(instance.getLocale().getMessage("interface.filter.whitelist"));
|
||||
it.setItemMeta(itm);
|
||||
int[] whiteSlots = {0, 1, 9, 10, 18, 19};
|
||||
for (int nu : whiteSlots) {
|
||||
i.setItem(nu, it);
|
||||
}
|
||||
|
||||
int num = 0;
|
||||
for (ItemStack o : filter.getWhiteList()) {
|
||||
if (o != null) {
|
||||
i.setItem(whiteSlots[num], o);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
it = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 15);
|
||||
itm = it.getItemMeta();
|
||||
itm.setDisplayName(instance.getLocale().getMessage("interface.filter.blacklist"));
|
||||
it.setItemMeta(itm);
|
||||
int[] blackSlots = {27, 28, 36, 37, 45, 46};
|
||||
for (int nu : blackSlots) {
|
||||
i.setItem(nu, it);
|
||||
}
|
||||
|
||||
num = 0;
|
||||
for (ItemStack o : filter.getBlackList()) {
|
||||
if (o != null) {
|
||||
i.setItem(blackSlots[num], o);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
it = new ItemStack(Material.BARRIER);
|
||||
itm = it.getItemMeta();
|
||||
itm.setDisplayName(instance.getLocale().getMessage("interface.filter.void"));
|
||||
it.setItemMeta(itm);
|
||||
int[] avoid = {7, 8, 16, 17, 25, 26, 34, 35, 43, 44, 52, 53};
|
||||
for (int nu : avoid) {
|
||||
i.setItem(nu, it);
|
||||
}
|
||||
|
||||
num = 0;
|
||||
for (ItemStack o : filter.getVoidList()) {
|
||||
if (o != null) {
|
||||
i.setItem(avoid[num], o);
|
||||
num++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ItemStack itemInfo = new ItemStack(Material.PAPER, 1);
|
||||
ItemMeta itemmetaInfo = itemInfo.getItemMeta();
|
||||
itemmetaInfo.setDisplayName(instance.getLocale().getMessage("interface.filter.infotitle"));
|
||||
ArrayList<String> loreInfo = new ArrayList<>();
|
||||
String[] parts = instance.getLocale().getMessage("interface.filter.infolore").split("\\|");
|
||||
for (String line : parts) {
|
||||
loreInfo.add(Arconix.pl().getApi().format().formatText(line));
|
||||
}
|
||||
itemmetaInfo.setLore(loreInfo);
|
||||
itemInfo.setItemMeta(itemmetaInfo);
|
||||
|
||||
i.setItem(13, itemInfo);
|
||||
|
||||
|
||||
ItemStack hook = new ItemStack(Material.TRIPWIRE_HOOK, 1);
|
||||
ItemMeta hookmeta = hook.getItemMeta();
|
||||
hookmeta.setDisplayName(instance.getLocale().getMessage("interface.hopper.rejectsync"));
|
||||
ArrayList<String> lorehook = new ArrayList<>();
|
||||
parts = instance.getLocale().getMessage("interface.hopper.synclore").split("\\|");
|
||||
for (String line : parts) {
|
||||
lorehook.add(Arconix.pl().getApi().format().formatText(line));
|
||||
}
|
||||
hookmeta.setLore(lorehook);
|
||||
hook.setItemMeta(hookmeta);
|
||||
i.setItem(40, hook);
|
||||
|
||||
player.openInventory(i);
|
||||
instance.inFilter.put(player.getUniqueId(), this);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void compile(Player p) {
|
||||
try {
|
||||
ItemStack[] items2 = p.getOpenInventory().getTopInventory().getContents();
|
||||
|
||||
List<ItemStack> owhite = new ArrayList<>();
|
||||
List<ItemStack> oblack = new ArrayList<>();
|
||||
List<ItemStack> ovoid = new ArrayList<>();
|
||||
|
||||
int[] awhite = {0, 1, 9, 10, 18, 19};
|
||||
int[] ablack = {27, 28, 36, 37, 45, 46};
|
||||
int[] avoid = {7, 8, 16, 17, 25, 26, 34, 35, 43, 44, 52, 53};
|
||||
|
||||
int num = 0;
|
||||
for (ItemStack item : items2) {
|
||||
for (int aa : awhite) {
|
||||
if (aa == num) {
|
||||
if (items2[num] != null && !items2[num].getType().equals(Material.STAINED_GLASS_PANE))
|
||||
owhite.add(items2[num]);
|
||||
}
|
||||
}
|
||||
for (int aa : ablack) {
|
||||
if (aa == num) {
|
||||
if (items2[num] != null && !items2[num].getType().equals(Material.STAINED_GLASS_PANE))
|
||||
oblack.add(items2[num]);
|
||||
}
|
||||
}
|
||||
for (int aa : avoid) {
|
||||
if (aa == num) {
|
||||
if (items2[num] != null && !items2[num].getType().equals(Material.BARRIER))
|
||||
ovoid.add(items2[num]);
|
||||
}
|
||||
}
|
||||
num++;
|
||||
}
|
||||
filter.setWhiteList(owhite);
|
||||
filter.setBlackList(oblack);
|
||||
filter.setVoidList(ovoid);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void upgrade(String type, Player player) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
if (instance.getLevelManager().getLevels().containsKey(this.level.getLevel() + 1)) {
|
||||
|
||||
Level level = instance.getLevelManager().getLevel(this.level.getLevel() + 1);
|
||||
int cost;
|
||||
if (type.equals("XP")) {
|
||||
cost = level.getCostExperience();
|
||||
} else {
|
||||
cost = level.getCostEconomy();
|
||||
}
|
||||
|
||||
if (type.equals("ECO")) {
|
||||
if (instance.getServer().getPluginManager().getPlugin("Vault") != null) {
|
||||
RegisteredServiceProvider<Economy> rsp = instance.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||
net.milkbowl.vault.economy.Economy econ = rsp.getProvider();
|
||||
if (econ.has(player, cost)) {
|
||||
econ.withdrawPlayer(player, cost);
|
||||
upgradeFinal(level, player);
|
||||
} else {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.upgrade.cannotafford"));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage("Vault is not installed.");
|
||||
}
|
||||
} else if (type.equals("XP")) {
|
||||
if (player.getLevel() >= cost || player.getGameMode() == GameMode.CREATIVE) {
|
||||
if (player.getGameMode() != GameMode.CREATIVE) {
|
||||
player.setLevel(player.getLevel() - cost);
|
||||
}
|
||||
upgradeFinal(level, player);
|
||||
} else {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.upgrade.cannotafford"));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Debugger.runReport(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void upgradeFinal(Level level, Player player) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
this.level = level;
|
||||
if (instance.getLevelManager().getHighestLevel() != level) {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.upgrade.success", level.getLevel()));
|
||||
} else {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.upgrade.maxed", level.getLevel()));
|
||||
}
|
||||
Location loc = location.clone().add(.5, .5, .5);
|
||||
if (!instance.v1_8 && !instance.v1_7) {
|
||||
player.getWorld().spawnParticle(org.bukkit.Particle.valueOf(instance.getConfig().getString("Main.Upgrade Particle Type")), loc, 200, .5, .5, .5);
|
||||
} else {
|
||||
player.getWorld().playEffect(loc, org.bukkit.Effect.valueOf(instance.getConfig().getString("Main.Upgrade Particle Type")), 1, 0);
|
||||
//Doesn't resolve --Nova
|
||||
//player.getWorld().spigot().playEffect(loc, org.bukkit.Effect.valueOf(instance.getConfig().getString("Main.Upgrade Particle Type")), 1, 0, (float) 1, (float) 1, (float) 1, 1, 200, 10);
|
||||
}
|
||||
if (instance.getConfig().getBoolean("Main.Sounds Enabled")) {
|
||||
if (instance.getLevelManager().getHighestLevel() != level) {
|
||||
if (!instance.v1_8 && !instance.v1_7) {
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 0.6F, 15.0F);
|
||||
} else {
|
||||
player.playSound(player.getLocation(), Sound.valueOf("LEVEL_UP"), 2F, 15.0F);
|
||||
}
|
||||
} else {
|
||||
if (!instance.v1_11 && !instance.v1_10 && !instance.v1_9 && !instance.v1_8 && !instance.v1_7) {
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 2F, 25.0F);
|
||||
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_CHIME, 2F, 25.0F);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> player.playSound(player.getLocation(), Sound.BLOCK_NOTE_CHIME, 1.2F, 35.0F), 5L);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> player.playSound(player.getLocation(), Sound.BLOCK_NOTE_CHIME, 1.8F, 35.0F), 10L);
|
||||
} else {
|
||||
player.playSound(player.getLocation(), org.bukkit.Sound.valueOf("LEVEL_UP"), 2F, 25.0F);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Debugger.runReport(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void timeout(Player player) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||
if (instance.sync.containsKey(player)) {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.synctimeout"));
|
||||
instance.sync.remove(player);
|
||||
instance.bsync.remove(player);
|
||||
}
|
||||
}, instance.getConfig().getLong("Main.Timeout When Syncing Hoppers"));
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void sync(Block block2, boolean black, Player player) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
|
||||
if (location.getWorld().equals(block2.getLocation().getWorld()) && !player.hasPermission("EpicHoppers.Override") && !player.hasPermission("EpicHoppers.Admin")) {
|
||||
if (location.distance(block2.getLocation()) > level.getRange() && !player.hasPermission("EpicHoppers.Override") && !player.hasPermission("EpicHoppers.Admin")) {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.syncoutofrange"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.syncsuccess"));
|
||||
|
||||
if (!black)
|
||||
this.syncedBlock = block2;
|
||||
else
|
||||
this.filter.setEndPoint(block2);
|
||||
this.lastPlayer = player.getUniqueId();
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return location.clone();
|
||||
}
|
||||
|
||||
public Level getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public UUID getLastPlayer() {
|
||||
return lastPlayer;
|
||||
}
|
||||
|
||||
public boolean isWalkOnTeleport() {
|
||||
return walkOnTeleport;
|
||||
}
|
||||
|
||||
public void setWalkOnTeleport(boolean walkOnTeleport) {
|
||||
this.walkOnTeleport = walkOnTeleport;
|
||||
}
|
||||
|
||||
public Block getSyncedBlock() {
|
||||
return syncedBlock;
|
||||
}
|
||||
|
||||
public void setSyncedBlock(Block syncedBlock) {
|
||||
this.syncedBlock = syncedBlock;
|
||||
}
|
||||
|
||||
public Filter getFilter() {
|
||||
return filter;
|
||||
}
|
||||
}
|
||||
package com.songoda.epichoppers.Hopper;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Utils.Debugger;
|
||||
import com.songoda.epichoppers.Utils.Methods;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/14/2017.
|
||||
*/
|
||||
public class Hopper {
|
||||
|
||||
private Location location;
|
||||
private Level level;
|
||||
private UUID lastPlayer;
|
||||
private Block syncedBlock;
|
||||
private Filter filter;
|
||||
private boolean walkOnTeleport;
|
||||
|
||||
|
||||
public Hopper(Location location, Level level, UUID lastPlayer, Block syncedBlock, Filter filter, boolean walkOnTeleport) {
|
||||
this.location = location;
|
||||
this.level = level;
|
||||
this.syncedBlock = syncedBlock;
|
||||
this.filter = filter;
|
||||
this.lastPlayer = lastPlayer;
|
||||
this.walkOnTeleport = walkOnTeleport;
|
||||
}
|
||||
|
||||
public Hopper(Block block, Level level, UUID lastPlayer, Block syncedBlock, Filter filter, boolean walkOnTeleport) {
|
||||
this(block.getLocation(), level, lastPlayer, syncedBlock, filter, walkOnTeleport);
|
||||
}
|
||||
|
||||
public void overview(Player player) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
if (!player.hasPermission("epichoppers.overview")) return;
|
||||
|
||||
instance.lastBlock.put(player, location.getBlock());
|
||||
|
||||
Level nextLevel = instance.getLevelManager().getHighestLevel().getLevel() > level.getLevel() ? instance.getLevelManager().getLevel(level.getLevel() + 1) : null;
|
||||
|
||||
Inventory i = Bukkit.createInventory(null, 27, Methods.formatName(level.getLevel(), false));
|
||||
|
||||
ItemStack perl = new ItemStack(Material.ENDER_PEARL, 1);
|
||||
ItemMeta perlmeta = perl.getItemMeta();
|
||||
perlmeta.setDisplayName(instance.getLocale().getMessage("interface.hopper.perltitle"));
|
||||
ArrayList<String> loreperl = new ArrayList<>();
|
||||
String[] parts = instance.getLocale().getMessage("interface.hopper.perllore").split("\\|");
|
||||
for (String line : parts) {
|
||||
loreperl.add(Arconix.pl().getApi().format().formatText(line));
|
||||
}
|
||||
perlmeta.setLore(loreperl);
|
||||
perl.setItemMeta(perlmeta);
|
||||
|
||||
ItemStack filter = new ItemStack(Material.COMPARATOR, 1);
|
||||
ItemMeta filtermeta = filter.getItemMeta();
|
||||
filtermeta.setDisplayName(instance.getLocale().getMessage("interface.hopper.filtertitle"));
|
||||
ArrayList<String> lorefilter = new ArrayList<>();
|
||||
parts = instance.getLocale().getMessage("interface.hopper.filterlore").split("\\|");
|
||||
for (String line : parts) {
|
||||
lorefilter.add(Arconix.pl().getApi().format().formatText(line));
|
||||
}
|
||||
filtermeta.setLore(lorefilter);
|
||||
filter.setItemMeta(filtermeta);
|
||||
|
||||
|
||||
ItemStack item = new ItemStack(Material.HOPPER, 1);
|
||||
ItemMeta itemmeta = item.getItemMeta();
|
||||
itemmeta.setDisplayName(instance.getLocale().getMessage("interface.hopper.currentlevel", level.getLevel()));
|
||||
List<String> lore = this.level.getDescription();
|
||||
lore.add("");
|
||||
if (nextLevel == null) lore.add(instance.getLocale().getMessage("interface.hopper.alreadymaxed"));
|
||||
else {
|
||||
lore.add(instance.getLocale().getMessage("interface.hopper.nextlevel", nextLevel.getLevel()));
|
||||
lore.addAll(nextLevel.getDescription());
|
||||
}
|
||||
|
||||
itemmeta.setLore(lore);
|
||||
item.setItemMeta(itemmeta);
|
||||
|
||||
ItemStack hook = new ItemStack(Material.TRIPWIRE_HOOK, 1);
|
||||
ItemMeta hookmeta = hook.getItemMeta();
|
||||
hookmeta.setDisplayName(instance.getLocale().getMessage("interface.hopper.synchopper"));
|
||||
ArrayList<String> lorehook = new ArrayList<>();
|
||||
parts = instance.getLocale().getMessage("interface.hopper.synclore").split("\\|");
|
||||
for (String line : parts) {
|
||||
lorehook.add(Arconix.pl().getApi().format().formatText(line));
|
||||
}
|
||||
hookmeta.setLore(lorehook);
|
||||
hook.setItemMeta(hookmeta);
|
||||
|
||||
ItemStack itemXP = new ItemStack(Material.valueOf(instance.getConfig().getString("Interfaces.XP Icon")), 1);
|
||||
ItemMeta itemmetaXP = itemXP.getItemMeta();
|
||||
itemmetaXP.setDisplayName(instance.getLocale().getMessage("interface.hopper.upgradewithxp"));
|
||||
ArrayList<String> loreXP = new ArrayList<>();
|
||||
if (nextLevel != null)
|
||||
loreXP.add(instance.getLocale().getMessage("interface.hopper.upgradewithxplore", nextLevel.getCostExperience()));
|
||||
else
|
||||
loreXP.add(instance.getLocale().getMessage("interface.hopper.alreadymaxed"));
|
||||
itemmetaXP.setLore(loreXP);
|
||||
itemXP.setItemMeta(itemmetaXP);
|
||||
|
||||
ItemStack itemECO = new ItemStack(Material.valueOf(instance.getConfig().getString("Interfaces.Economy Icon")), 1);
|
||||
ItemMeta itemmetaECO = itemECO.getItemMeta();
|
||||
itemmetaECO.setDisplayName(instance.getLocale().getMessage("interface.hopper.upgradewitheconomy"));
|
||||
ArrayList<String> loreECO = new ArrayList<>();
|
||||
if (nextLevel != null)
|
||||
loreECO.add(instance.getLocale().getMessage("interface.hopper.upgradewitheconomylore", Arconix.pl().getApi().format().formatEconomy(nextLevel.getCostEconomy())));
|
||||
else
|
||||
loreECO.add(instance.getLocale().getMessage("interface.hopper.alreadymaxed"));
|
||||
itemmetaECO.setLore(loreECO);
|
||||
itemECO.setItemMeta(itemmetaECO);
|
||||
|
||||
int nu = 0;
|
||||
while (nu != 27) {
|
||||
i.setItem(nu, Methods.getGlass());
|
||||
nu++;
|
||||
}
|
||||
|
||||
boolean canFilter = instance.getConfig().getBoolean("Main.Allow Players To use The Hopper Filter") && player.hasPermission("EpicHoppers.Filter");
|
||||
boolean canTeleport = instance.getConfig().getBoolean("Main.Allow Players To Teleport Through Hoppers") && player.hasPermission("EpicHoppers.Teleport");
|
||||
if (!canFilter && canTeleport)
|
||||
i.setItem(4, perl);
|
||||
else if (!canTeleport && canFilter)
|
||||
i.setItem(4, filter);
|
||||
else if (canFilter) {
|
||||
i.setItem(3, perl);
|
||||
i.setItem(5, filter);
|
||||
}
|
||||
|
||||
if (instance.getConfig().getBoolean("Main.Upgrade With XP") && player.hasPermission("EpicHoppers.Upgrade.XP")) {
|
||||
i.setItem(11, itemXP);
|
||||
}
|
||||
|
||||
i.setItem(13, item);
|
||||
i.setItem(22, hook);
|
||||
|
||||
if (instance.getConfig().getBoolean("Main.Upgrade With Economy") && player.hasPermission("EpicHoppers.Upgrade.ECO")) {
|
||||
i.setItem(15, itemECO);
|
||||
}
|
||||
|
||||
i.setItem(0, Methods.getBackgroundGlass(true));
|
||||
i.setItem(1, Methods.getBackgroundGlass(true));
|
||||
i.setItem(2, Methods.getBackgroundGlass(false));
|
||||
i.setItem(6, Methods.getBackgroundGlass(false));
|
||||
i.setItem(7, Methods.getBackgroundGlass(true));
|
||||
i.setItem(8, Methods.getBackgroundGlass(true));
|
||||
i.setItem(9, Methods.getBackgroundGlass(true));
|
||||
i.setItem(10, Methods.getBackgroundGlass(false));
|
||||
i.setItem(16, Methods.getBackgroundGlass(false));
|
||||
i.setItem(17, Methods.getBackgroundGlass(true));
|
||||
i.setItem(18, Methods.getBackgroundGlass(true));
|
||||
i.setItem(19, Methods.getBackgroundGlass(true));
|
||||
i.setItem(20, Methods.getBackgroundGlass(false));
|
||||
i.setItem(24, Methods.getBackgroundGlass(false));
|
||||
i.setItem(25, Methods.getBackgroundGlass(true));
|
||||
i.setItem(26, Methods.getBackgroundGlass(true));
|
||||
|
||||
player.openInventory(i);
|
||||
instance.inShow.put(player.getUniqueId(), this);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void filter(Player player) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
|
||||
Inventory i = Bukkit.createInventory(null, 54, Arconix.pl().getApi().format().formatText(Methods.formatName(level.getLevel(), false) + " &8-&f Filter"));
|
||||
|
||||
i.setItem(2, Methods.getBackgroundGlass(true));
|
||||
i.setItem(3, Methods.getBackgroundGlass(true));
|
||||
i.setItem(4, Methods.getBackgroundGlass(true));
|
||||
i.setItem(5, Methods.getBackgroundGlass(false));
|
||||
i.setItem(6, Methods.getBackgroundGlass(false));
|
||||
|
||||
i.setItem(11, Methods.getBackgroundGlass(true));
|
||||
i.setItem(15, Methods.getBackgroundGlass(false));
|
||||
|
||||
i.setItem(20, Methods.getBackgroundGlass(true));
|
||||
i.setItem(24, Methods.getBackgroundGlass(true));
|
||||
|
||||
i.setItem(29, Methods.getBackgroundGlass(true));
|
||||
i.setItem(33, Methods.getBackgroundGlass(true));
|
||||
|
||||
i.setItem(38, Methods.getBackgroundGlass(false));
|
||||
i.setItem(42, Methods.getBackgroundGlass(true));
|
||||
|
||||
i.setItem(47, Methods.getBackgroundGlass(false));
|
||||
i.setItem(48, Methods.getBackgroundGlass(false));
|
||||
i.setItem(49, Methods.getBackgroundGlass(true));
|
||||
i.setItem(50, Methods.getBackgroundGlass(true));
|
||||
i.setItem(51, Methods.getBackgroundGlass(true));
|
||||
|
||||
i.setItem(12, Methods.getGlass());
|
||||
i.setItem(14, Methods.getGlass());
|
||||
i.setItem(21, Methods.getGlass());
|
||||
i.setItem(22, Methods.getGlass());
|
||||
i.setItem(23, Methods.getGlass());
|
||||
i.setItem(30, Methods.getGlass());
|
||||
i.setItem(31, Methods.getGlass());
|
||||
i.setItem(32, Methods.getGlass());
|
||||
i.setItem(39, Methods.getGlass());
|
||||
i.setItem(41, Methods.getGlass());
|
||||
|
||||
ItemStack it = new ItemStack(Material.WHITE_STAINED_GLASS_PANE, 1);
|
||||
ItemMeta itm = it.getItemMeta();
|
||||
itm.setDisplayName(instance.getLocale().getMessage("interface.filter.whitelist"));
|
||||
it.setItemMeta(itm);
|
||||
int[] whiteSlots = {0, 1, 9, 10, 18, 19};
|
||||
for (int nu : whiteSlots) {
|
||||
i.setItem(nu, it);
|
||||
}
|
||||
|
||||
int num = 0;
|
||||
for (ItemStack o : filter.getWhiteList()) {
|
||||
if (o != null) {
|
||||
i.setItem(whiteSlots[num], o);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
it = new ItemStack(Material.BLACK_STAINED_GLASS_PANE, 1);
|
||||
itm = it.getItemMeta();
|
||||
itm.setDisplayName(instance.getLocale().getMessage("interface.filter.blacklist"));
|
||||
it.setItemMeta(itm);
|
||||
int[] blackSlots = {27, 28, 36, 37, 45, 46};
|
||||
for (int nu : blackSlots) {
|
||||
i.setItem(nu, it);
|
||||
}
|
||||
|
||||
num = 0;
|
||||
for (ItemStack o : filter.getBlackList()) {
|
||||
if (o != null) {
|
||||
i.setItem(blackSlots[num], o);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
it = new ItemStack(Material.BARRIER);
|
||||
itm = it.getItemMeta();
|
||||
itm.setDisplayName(instance.getLocale().getMessage("interface.filter.void"));
|
||||
it.setItemMeta(itm);
|
||||
int[] avoid = {7, 8, 16, 17, 25, 26, 34, 35, 43, 44, 52, 53};
|
||||
for (int nu : avoid) {
|
||||
i.setItem(nu, it);
|
||||
}
|
||||
|
||||
num = 0;
|
||||
for (ItemStack o : filter.getVoidList()) {
|
||||
if (o != null) {
|
||||
i.setItem(avoid[num], o);
|
||||
num++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ItemStack itemInfo = new ItemStack(Material.PAPER, 1);
|
||||
ItemMeta itemmetaInfo = itemInfo.getItemMeta();
|
||||
itemmetaInfo.setDisplayName(instance.getLocale().getMessage("interface.filter.infotitle"));
|
||||
ArrayList<String> loreInfo = new ArrayList<>();
|
||||
String[] parts = instance.getLocale().getMessage("interface.filter.infolore").split("\\|");
|
||||
for (String line : parts) {
|
||||
loreInfo.add(Arconix.pl().getApi().format().formatText(line));
|
||||
}
|
||||
itemmetaInfo.setLore(loreInfo);
|
||||
itemInfo.setItemMeta(itemmetaInfo);
|
||||
|
||||
i.setItem(13, itemInfo);
|
||||
|
||||
|
||||
ItemStack hook = new ItemStack(Material.TRIPWIRE_HOOK, 1);
|
||||
ItemMeta hookmeta = hook.getItemMeta();
|
||||
hookmeta.setDisplayName(instance.getLocale().getMessage("interface.hopper.rejectsync"));
|
||||
ArrayList<String> lorehook = new ArrayList<>();
|
||||
parts = instance.getLocale().getMessage("interface.hopper.synclore").split("\\|");
|
||||
for (String line : parts) {
|
||||
lorehook.add(Arconix.pl().getApi().format().formatText(line));
|
||||
}
|
||||
hookmeta.setLore(lorehook);
|
||||
hook.setItemMeta(hookmeta);
|
||||
i.setItem(40, hook);
|
||||
|
||||
player.openInventory(i);
|
||||
instance.inFilter.put(player.getUniqueId(), this);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void compile(Player p) {
|
||||
try {
|
||||
ItemStack[] items2 = p.getOpenInventory().getTopInventory().getContents();
|
||||
|
||||
List<ItemStack> owhite = new ArrayList<>();
|
||||
List<ItemStack> oblack = new ArrayList<>();
|
||||
List<ItemStack> ovoid = new ArrayList<>();
|
||||
|
||||
int[] awhite = {0, 1, 9, 10, 18, 19};
|
||||
int[] ablack = {27, 28, 36, 37, 45, 46};
|
||||
int[] avoid = {7, 8, 16, 17, 25, 26, 34, 35, 43, 44, 52, 53};
|
||||
|
||||
int num = 0;
|
||||
for (ItemStack item : items2) {
|
||||
for (int aa : awhite) {
|
||||
if (aa == num) {
|
||||
if (items2[num] != null && !items2[num].getType().name().contains("STAINED_GLASS"))
|
||||
owhite.add(items2[num]);
|
||||
}
|
||||
}
|
||||
for (int aa : ablack) {
|
||||
if (aa == num) {
|
||||
if (items2[num] != null && !items2[num].getType().name().contains("STAINED_GLASS"))
|
||||
oblack.add(items2[num]);
|
||||
}
|
||||
}
|
||||
for (int aa : avoid) {
|
||||
if (aa == num) {
|
||||
if (items2[num] != null && !items2[num].getType().equals(Material.BARRIER))
|
||||
ovoid.add(items2[num]);
|
||||
}
|
||||
}
|
||||
num++;
|
||||
}
|
||||
filter.setWhiteList(owhite);
|
||||
filter.setBlackList(oblack);
|
||||
filter.setVoidList(ovoid);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void upgrade(String type, Player player) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
if (instance.getLevelManager().getLevels().containsKey(this.level.getLevel() + 1)) {
|
||||
|
||||
Level level = instance.getLevelManager().getLevel(this.level.getLevel() + 1);
|
||||
int cost;
|
||||
if (type.equals("XP")) {
|
||||
cost = level.getCostExperience();
|
||||
} else {
|
||||
cost = level.getCostEconomy();
|
||||
}
|
||||
|
||||
if (type.equals("ECO")) {
|
||||
if (instance.getServer().getPluginManager().getPlugin("Vault") != null) {
|
||||
RegisteredServiceProvider<Economy> rsp = instance.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||
net.milkbowl.vault.economy.Economy econ = rsp.getProvider();
|
||||
if (econ.has(player, cost)) {
|
||||
econ.withdrawPlayer(player, cost);
|
||||
upgradeFinal(level, player);
|
||||
} else {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.upgrade.cannotafford"));
|
||||
}
|
||||
} else {
|
||||
player.sendMessage("Vault is not installed.");
|
||||
}
|
||||
} else if (type.equals("XP")) {
|
||||
if (player.getLevel() >= cost || player.getGameMode() == GameMode.CREATIVE) {
|
||||
if (player.getGameMode() != GameMode.CREATIVE) {
|
||||
player.setLevel(player.getLevel() - cost);
|
||||
}
|
||||
upgradeFinal(level, player);
|
||||
} else {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.upgrade.cannotafford"));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Debugger.runReport(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void upgradeFinal(Level level, Player player) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
this.level = level;
|
||||
if (instance.getLevelManager().getHighestLevel() != level) {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.upgrade.success", level.getLevel()));
|
||||
} else {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.upgrade.maxed", level.getLevel()));
|
||||
}
|
||||
Location loc = location.clone().add(.5, .5, .5);
|
||||
player.getWorld().spawnParticle(org.bukkit.Particle.valueOf(instance.getConfig().getString("Main.Upgrade Particle Type")), loc, 200, .5, .5, .5);
|
||||
|
||||
if (instance.getConfig().getBoolean("Main.Sounds Enabled")) {
|
||||
if (instance.getLevelManager().getHighestLevel() != level) {
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 0.6F, 15.0F);
|
||||
} else {
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 2F, 25.0F);
|
||||
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_CHIME, 2F, 25.0F);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_CHIME, 1.2F, 35.0F), 5L);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_CHIME, 1.8F, 35.0F), 10L);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Debugger.runReport(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void timeout(Player player) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||
if (instance.sync.containsKey(player)) {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.synctimeout"));
|
||||
instance.sync.remove(player);
|
||||
instance.bsync.remove(player);
|
||||
}
|
||||
}, instance.getConfig().getLong("Main.Timeout When Syncing Hoppers"));
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void sync(Block block2, boolean black, Player player) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
|
||||
if (location.getWorld().equals(block2.getLocation().getWorld()) && !player.hasPermission("EpicHoppers.Override") && !player.hasPermission("EpicHoppers.Admin")) {
|
||||
if (location.distance(block2.getLocation()) > level.getRange() && !player.hasPermission("EpicHoppers.Override") && !player.hasPermission("EpicHoppers.Admin")) {
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.syncoutofrange"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
player.sendMessage(instance.getLocale().getMessage("event.hopper.syncsuccess"));
|
||||
|
||||
if (!black)
|
||||
this.syncedBlock = block2;
|
||||
else
|
||||
this.filter.setEndPoint(block2);
|
||||
this.lastPlayer = player.getUniqueId();
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return location.clone();
|
||||
}
|
||||
|
||||
public Level getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public UUID getLastPlayer() {
|
||||
return lastPlayer;
|
||||
}
|
||||
|
||||
public boolean isWalkOnTeleport() {
|
||||
return walkOnTeleport;
|
||||
}
|
||||
|
||||
public void setWalkOnTeleport(boolean walkOnTeleport) {
|
||||
this.walkOnTeleport = walkOnTeleport;
|
||||
}
|
||||
|
||||
public Block getSyncedBlock() {
|
||||
return syncedBlock;
|
||||
}
|
||||
|
||||
public void setSyncedBlock(Block syncedBlock) {
|
||||
this.syncedBlock = syncedBlock;
|
||||
}
|
||||
|
||||
public Filter getFilter() {
|
||||
return filter;
|
||||
}
|
||||
}
|
||||
|
@ -1,49 +1,49 @@
|
||||
package com.songoda.epichoppers.Hopper;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class HopperManager {
|
||||
|
||||
private final Map<Location, Hopper> registeredHoppers = new HashMap<>();
|
||||
|
||||
public void addHopper(Location location, Hopper hopper) {
|
||||
registeredHoppers.put(roundLocation(location), hopper);
|
||||
}
|
||||
|
||||
public Hopper removeHopper(Location location) {
|
||||
return registeredHoppers.remove(location);
|
||||
}
|
||||
|
||||
public Hopper getHopper(Location location) {
|
||||
if (!registeredHoppers.containsKey(roundLocation(location))) {
|
||||
addHopper(location, new Hopper(location, EpicHoppers.getInstance().getLevelManager().getLowestLevel(), null, null, new Filter(), false));
|
||||
}
|
||||
return registeredHoppers.get(roundLocation(location));
|
||||
}
|
||||
|
||||
public Hopper getHopper(Block block) {
|
||||
return getHopper(block.getLocation());
|
||||
}
|
||||
|
||||
public boolean isHopper(Location location) {
|
||||
return registeredHoppers.containsKey(roundLocation(location));
|
||||
}
|
||||
|
||||
public Map<Location, Hopper> getHoppers() {
|
||||
return Collections.unmodifiableMap(registeredHoppers);
|
||||
}
|
||||
|
||||
private Location roundLocation(Location location) {
|
||||
location = location.clone();
|
||||
location.setX(location.getBlockX());
|
||||
location.setY(location.getBlockY());
|
||||
location.setZ(location.getBlockZ());
|
||||
return location;
|
||||
}
|
||||
}
|
||||
package com.songoda.epichoppers.Hopper;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class HopperManager {
|
||||
|
||||
private final Map<Location, Hopper> registeredHoppers = new HashMap<>();
|
||||
|
||||
public void addHopper(Location location, Hopper hopper) {
|
||||
registeredHoppers.put(roundLocation(location), hopper);
|
||||
}
|
||||
|
||||
public Hopper removeHopper(Location location) {
|
||||
return registeredHoppers.remove(location);
|
||||
}
|
||||
|
||||
public Hopper getHopper(Location location) {
|
||||
if (!registeredHoppers.containsKey(roundLocation(location))) {
|
||||
addHopper(location, new Hopper(location, EpicHoppers.getInstance().getLevelManager().getLowestLevel(), null, null, new Filter(), false));
|
||||
}
|
||||
return registeredHoppers.get(roundLocation(location));
|
||||
}
|
||||
|
||||
public Hopper getHopper(Block block) {
|
||||
return getHopper(block.getLocation());
|
||||
}
|
||||
|
||||
public boolean isHopper(Location location) {
|
||||
return registeredHoppers.containsKey(roundLocation(location));
|
||||
}
|
||||
|
||||
public Map<Location, Hopper> getHoppers() {
|
||||
return Collections.unmodifiableMap(registeredHoppers);
|
||||
}
|
||||
|
||||
private Location roundLocation(Location location) {
|
||||
location = location.clone();
|
||||
location.setX(location.getBlockX());
|
||||
location.setY(location.getBlockY());
|
||||
location.setZ(location.getBlockZ());
|
||||
return location;
|
||||
}
|
||||
}
|
||||
|
@ -1,63 +1,63 @@
|
||||
package com.songoda.epichoppers.Hopper;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Level {
|
||||
|
||||
private int level, costExperience, costEconomy, range, amount, blockBreak, suction;
|
||||
|
||||
private List<String> description = new ArrayList<>();
|
||||
|
||||
public Level(int level, int costExperience, int costEconomy, int range, int amount, int suction, int blockBreak) {
|
||||
this.level = level;
|
||||
this.costExperience = costExperience;
|
||||
this.costEconomy = costEconomy;
|
||||
this.range = range;
|
||||
this.amount = amount;
|
||||
this.blockBreak = blockBreak;
|
||||
this.suction = suction;
|
||||
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
|
||||
description.add(instance.getLocale().getMessage("interface.hopper.range", range));
|
||||
description.add(instance.getLocale().getMessage("interface.hopper.amount", amount));
|
||||
if (suction != 0) description.add(instance.getLocale().getMessage("interface.hopper.suction", suction));
|
||||
if (blockBreak != 0) description.add(instance.getLocale().getMessage("interface.hopper.blockbreak", blockBreak));
|
||||
}
|
||||
|
||||
public List<String> getDescription() {
|
||||
return new ArrayList<>(description);
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public int getRange() {
|
||||
return range;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public int getBlockBreak() {
|
||||
return blockBreak;
|
||||
}
|
||||
|
||||
public int getSuction() {
|
||||
return suction;
|
||||
}
|
||||
|
||||
public int getCostExperience() {
|
||||
return costExperience;
|
||||
}
|
||||
|
||||
public int getCostEconomy() {
|
||||
return costEconomy;
|
||||
}
|
||||
}
|
||||
|
||||
package com.songoda.epichoppers.Hopper;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Level {
|
||||
|
||||
private int level, costExperience, costEconomy, range, amount, blockBreak, suction;
|
||||
|
||||
private List<String> description = new ArrayList<>();
|
||||
|
||||
public Level(int level, int costExperience, int costEconomy, int range, int amount, int suction, int blockBreak) {
|
||||
this.level = level;
|
||||
this.costExperience = costExperience;
|
||||
this.costEconomy = costEconomy;
|
||||
this.range = range;
|
||||
this.amount = amount;
|
||||
this.blockBreak = blockBreak;
|
||||
this.suction = suction;
|
||||
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
|
||||
description.add(instance.getLocale().getMessage("interface.hopper.range", range));
|
||||
description.add(instance.getLocale().getMessage("interface.hopper.amount", amount));
|
||||
if (suction != 0) description.add(instance.getLocale().getMessage("interface.hopper.suction", suction));
|
||||
if (blockBreak != 0) description.add(instance.getLocale().getMessage("interface.hopper.blockbreak", blockBreak));
|
||||
}
|
||||
|
||||
public List<String> getDescription() {
|
||||
return new ArrayList<>(description);
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public int getRange() {
|
||||
return range;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public int getBlockBreak() {
|
||||
return blockBreak;
|
||||
}
|
||||
|
||||
public int getSuction() {
|
||||
return suction;
|
||||
}
|
||||
|
||||
public int getCostExperience() {
|
||||
return costExperience;
|
||||
}
|
||||
|
||||
public int getCostEconomy() {
|
||||
return costEconomy;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,35 +1,35 @@
|
||||
package com.songoda.epichoppers.Hopper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class LevelManager {
|
||||
|
||||
private final NavigableMap<Integer, Level> registeredLevels = new TreeMap<>();
|
||||
|
||||
public void addLevel(int level, int costExperiance, int costEconomy, int range, int amount, int suction, int blockBreak) {
|
||||
registeredLevels.put(level, new Level(level, costExperiance, costEconomy, range, amount, suction, blockBreak));
|
||||
}
|
||||
|
||||
public Level getLevel(int level) {
|
||||
return registeredLevels.get(level);
|
||||
}
|
||||
|
||||
public Level getLowestLevel() {
|
||||
return registeredLevels.firstEntry().getValue();
|
||||
}
|
||||
|
||||
public Level getHighestLevel() {
|
||||
return registeredLevels.lastEntry().getValue();
|
||||
}
|
||||
|
||||
public Map<Integer, Level> getLevels() {
|
||||
return Collections.unmodifiableMap(registeredLevels);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
registeredLevels.clear();
|
||||
}
|
||||
}
|
||||
package com.songoda.epichoppers.Hopper;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class LevelManager {
|
||||
|
||||
private final NavigableMap<Integer, Level> registeredLevels = new TreeMap<>();
|
||||
|
||||
public void addLevel(int level, int costExperiance, int costEconomy, int range, int amount, int suction, int blockBreak) {
|
||||
registeredLevels.put(level, new Level(level, costExperiance, costEconomy, range, amount, suction, blockBreak));
|
||||
}
|
||||
|
||||
public Level getLevel(int level) {
|
||||
return registeredLevels.get(level);
|
||||
}
|
||||
|
||||
public Level getLowestLevel() {
|
||||
return registeredLevels.firstEntry().getValue();
|
||||
}
|
||||
|
||||
public Level getHighestLevel() {
|
||||
return registeredLevels.lastEntry().getValue();
|
||||
}
|
||||
|
||||
public Map<Integer, Level> getLevels() {
|
||||
return Collections.unmodifiableMap(registeredLevels);
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
registeredLevels.clear();
|
||||
}
|
||||
}
|
||||
|
@ -1,365 +1,365 @@
|
||||
package com.songoda.epichoppers;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Assists in the creation of multiple localizations and languages,
|
||||
* as well as the generation of default .lang files
|
||||
*
|
||||
* @author Parker Hawke - 2008Choco
|
||||
*/
|
||||
public class Locale {
|
||||
|
||||
private static JavaPlugin plugin;
|
||||
private static final List<Locale> LOCALES = Lists.newArrayList();
|
||||
|
||||
private static final Pattern NODE_PATTERN = Pattern.compile("(\\w+(?:\\.\\w+)*)\\s*=\\s*\"(.*)\"");
|
||||
private static final String FILE_EXTENSION = ".lang";
|
||||
private static File localeFolder;
|
||||
|
||||
private static String defaultLocale;
|
||||
|
||||
private final Map<String, String> nodes = new HashMap<>();
|
||||
|
||||
private final File file;
|
||||
private final String name, region;
|
||||
|
||||
private Locale(String name, String region) {
|
||||
if (plugin == null)
|
||||
throw new IllegalStateException("Cannot generate locales without first initializing the class (Locale#init(JavaPlugin))");
|
||||
|
||||
this.name = name.toLowerCase();
|
||||
this.region = region.toUpperCase();
|
||||
|
||||
String fileName = name + "_" + region + FILE_EXTENSION;
|
||||
this.file = new File(localeFolder, fileName);
|
||||
|
||||
if (this.reloadMessages()) return;
|
||||
|
||||
plugin.getLogger().info("Loaded locale " + fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the language that this locale is based on.
|
||||
* (i.e. "en" for English, or "fr" for French)
|
||||
*
|
||||
* @return the name of the language
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the region that this locale is from.
|
||||
* (i.e. "US" for United States or "CA" for Canada)
|
||||
*
|
||||
* @return the name of the region
|
||||
*/
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the entire locale tag (i.e. "en_US")
|
||||
*
|
||||
* @return the language tag
|
||||
*/
|
||||
public String getLanguageTag() {
|
||||
return name + "_" + region;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file that represents this locale
|
||||
*
|
||||
* @return the locale file (.lang)
|
||||
*/
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a message set for a specific node
|
||||
*
|
||||
* @param node the node to get
|
||||
* @return the message for the specified node
|
||||
*/
|
||||
public String getMessage(String node) {
|
||||
return ChatColor.translateAlternateColorCodes('&', this.getMessageOrDefault(node, node));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a message set for a specific node and replace its params with a supplied arguments.
|
||||
*
|
||||
* @param node the node to get
|
||||
* @param args the replacement arguments
|
||||
* @return the message for the specified node
|
||||
*/
|
||||
public String getMessage(String node, Object... args) {
|
||||
String message = getMessage(node);
|
||||
for (Object arg : args) {
|
||||
message = message.replaceFirst("%.*?%", arg.toString());
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a message set for a specific node
|
||||
*
|
||||
* @param node the node to get
|
||||
* @param defaultValue the default value given that a value for the node was not found
|
||||
*
|
||||
* @return the message for the specified node. Default if none found
|
||||
*/
|
||||
public String getMessageOrDefault(String node, String defaultValue) {
|
||||
return this.nodes.getOrDefault(node, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the key-value map of nodes to messages
|
||||
*
|
||||
* @return node-message map
|
||||
*/
|
||||
public Map<String, String> getMessageNodeMap() {
|
||||
return ImmutableMap.copyOf(nodes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the previous message cache and load new messages directly from file
|
||||
*
|
||||
* @return reload messages from file
|
||||
*/
|
||||
public boolean reloadMessages() {
|
||||
if (!this.file.exists()) {
|
||||
plugin.getLogger().warning("Could not find file for locale " + this.name);
|
||||
return false;
|
||||
}
|
||||
|
||||
this.nodes.clear(); // Clear previous data (if any)
|
||||
|
||||
try(BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||
String line;
|
||||
for (int lineNumber = 0; (line = reader.readLine()) != null; lineNumber++) {
|
||||
if (line.isEmpty() || line.startsWith("#") /* Comment */) continue;
|
||||
|
||||
Matcher matcher = NODE_PATTERN.matcher(line);
|
||||
if (!matcher.find()) {
|
||||
System.err.println("Invalid locale syntax at (line=" + lineNumber + ")");
|
||||
continue;
|
||||
}
|
||||
|
||||
nodes.put(matcher.group(1), matcher.group(2));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the locale class to generate information and search for localizations.
|
||||
* This must be called before any other methods in the Locale class can be invoked.
|
||||
* Note that this will also call {@link #searchForLocales()}, so there is no need to
|
||||
* invoke it for yourself after the initialization
|
||||
*
|
||||
* @param plugin the plugin instance
|
||||
*/
|
||||
public static void init(JavaPlugin plugin) {
|
||||
Locale.plugin = plugin;
|
||||
|
||||
if (localeFolder == null) {
|
||||
localeFolder = new File(plugin.getDataFolder(), "locales/");
|
||||
}
|
||||
|
||||
localeFolder.mkdirs();
|
||||
Locale.searchForLocales();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all .lang file locales under the "locales" folder
|
||||
*/
|
||||
public static void searchForLocales() {
|
||||
if (!localeFolder.exists()) localeFolder.mkdirs();
|
||||
|
||||
for (File file : localeFolder.listFiles()) {
|
||||
String name = file.getName();
|
||||
if (!name.endsWith(".lang")) continue;
|
||||
|
||||
String fileName = name.substring(0, name.lastIndexOf('.'));
|
||||
String[] localeValues = fileName.split("_");
|
||||
|
||||
if (localeValues.length != 2) continue;
|
||||
if (localeExists(localeValues[0] + "_" + localeValues[1])) continue;
|
||||
|
||||
LOCALES.add(new Locale(localeValues[0], localeValues[1]));
|
||||
plugin.getLogger().info("Found and loaded locale \"" + fileName + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a locale by its entire proper name (i.e. "en_US")
|
||||
*
|
||||
* @param name the full name of the locale
|
||||
* @return locale of the specified name
|
||||
*/
|
||||
public static Locale getLocale(String name) {
|
||||
for (Locale locale : LOCALES)
|
||||
if (locale.getLanguageTag().equalsIgnoreCase(name)) return locale;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a locale from the cache by its name (i.e. "en" from "en_US")
|
||||
*
|
||||
* @param name the name of the language
|
||||
* @return locale of the specified language. Null if not cached
|
||||
*/
|
||||
public static Locale getLocaleByName(String name) {
|
||||
for (Locale locale : LOCALES)
|
||||
if (locale.getName().equalsIgnoreCase(name)) return locale;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a locale from the cache by its region (i.e. "US" from "en_US")
|
||||
*
|
||||
* @param region the name of the region
|
||||
* @return locale of the specified region. Null if not cached
|
||||
*/
|
||||
public static Locale getLocaleByRegion(String region) {
|
||||
for (Locale locale : LOCALES)
|
||||
if (locale.getRegion().equalsIgnoreCase(region)) return locale;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a locale exists and is registered or not
|
||||
*
|
||||
* @param name the whole language tag (i.e. "en_US")
|
||||
* @return true if it exists
|
||||
*/
|
||||
public static boolean localeExists(String name) {
|
||||
for (Locale locale : LOCALES)
|
||||
if (locale.getLanguageTag().equals(name)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an immutable list of all currently loaded locales
|
||||
*
|
||||
* @return list of all locales
|
||||
*/
|
||||
public static List<Locale> getLocales() {
|
||||
return ImmutableList.copyOf(LOCALES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a default locale file from the project source directory, to the locale folder
|
||||
*
|
||||
* @param path the path to the file to save
|
||||
* @param fileName the name of the file to save
|
||||
*
|
||||
* @return true if the operation was successful, false otherwise
|
||||
*/
|
||||
public static boolean saveDefaultLocale(String path, String fileName) {
|
||||
if (!localeFolder.exists()) localeFolder.mkdirs();
|
||||
|
||||
if (!fileName.endsWith(FILE_EXTENSION))
|
||||
fileName = (fileName.lastIndexOf(".") == -1 ? fileName : fileName.substring(0, fileName.lastIndexOf('.'))) + FILE_EXTENSION;
|
||||
|
||||
File destinationFile = new File(localeFolder, fileName);
|
||||
if (destinationFile.exists()) {
|
||||
return compareFiles(plugin.getResource(fileName), destinationFile);
|
||||
}
|
||||
|
||||
try (OutputStream outputStream = new FileOutputStream(destinationFile)) {
|
||||
IOUtils.copy(plugin.getResource(fileName), outputStream);
|
||||
|
||||
fileName = fileName.substring(0, fileName.lastIndexOf('.'));
|
||||
String[] localeValues = fileName.split("_");
|
||||
|
||||
if (localeValues.length != 2) return false;
|
||||
|
||||
LOCALES.add(new Locale(localeValues[0], localeValues[1]));
|
||||
if (defaultLocale == null) defaultLocale = fileName;
|
||||
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a default locale file from the project source directory, to the locale folder
|
||||
*
|
||||
* @param fileName the name of the file to save
|
||||
* @return true if the operation was successful, false otherwise
|
||||
*/
|
||||
public static boolean saveDefaultLocale(String fileName) {
|
||||
return saveDefaultLocale("", fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all current locale data
|
||||
*/
|
||||
public static void clearLocaleData() {
|
||||
for (Locale locale : LOCALES)
|
||||
locale.nodes.clear();
|
||||
LOCALES.clear();
|
||||
}
|
||||
|
||||
// Write new changes to existing files, if any at all
|
||||
private static boolean compareFiles(InputStream defaultFile, File existingFile) {
|
||||
// Look for default
|
||||
if (defaultFile == null) {
|
||||
defaultFile = plugin.getResource(defaultLocale != null ? defaultLocale : "en_US");
|
||||
if (defaultFile == null) return false; // No default at all
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
|
||||
List<String> defaultLines, existingLines;
|
||||
try (BufferedReader defaultReader = new BufferedReader(new InputStreamReader(defaultFile));
|
||||
BufferedReader existingReader = new BufferedReader(new FileReader(existingFile));
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter(existingFile, true))) {
|
||||
defaultLines = defaultReader.lines().collect(Collectors.toList());
|
||||
existingLines = existingReader.lines().map(s -> s.split("\\s*=")[0]).collect(Collectors.toList());
|
||||
|
||||
for (String defaultValue : defaultLines) {
|
||||
if (defaultValue.isEmpty() || defaultValue.startsWith("#")) continue;
|
||||
|
||||
String key = defaultValue.split("\\s*=")[0];
|
||||
|
||||
if (!existingLines.contains(key)) {
|
||||
if (!changed) {
|
||||
writer.newLine(); writer.newLine();
|
||||
writer.write("# New messages for " + plugin.getName() + " v" + plugin.getDescription().getVersion());
|
||||
}
|
||||
|
||||
writer.newLine();
|
||||
writer.write(defaultValue);
|
||||
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
package com.songoda.epichoppers;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Assists in the creation of multiple localizations and languages,
|
||||
* as well as the generation of default .lang files
|
||||
*
|
||||
* @author Parker Hawke - 2008Choco
|
||||
*/
|
||||
public class Locale {
|
||||
|
||||
private static JavaPlugin plugin;
|
||||
private static final List<Locale> LOCALES = Lists.newArrayList();
|
||||
|
||||
private static final Pattern NODE_PATTERN = Pattern.compile("(\\w+(?:\\.\\w+)*)\\s*=\\s*\"(.*)\"");
|
||||
private static final String FILE_EXTENSION = ".lang";
|
||||
private static File localeFolder;
|
||||
|
||||
private static String defaultLocale;
|
||||
|
||||
private final Map<String, String> nodes = new HashMap<>();
|
||||
|
||||
private final File file;
|
||||
private final String name, region;
|
||||
|
||||
private Locale(String name, String region) {
|
||||
if (plugin == null)
|
||||
throw new IllegalStateException("Cannot generate locales without first initializing the class (Locale#init(JavaPlugin))");
|
||||
|
||||
this.name = name.toLowerCase();
|
||||
this.region = region.toUpperCase();
|
||||
|
||||
String fileName = name + "_" + region + FILE_EXTENSION;
|
||||
this.file = new File(localeFolder, fileName);
|
||||
|
||||
if (this.reloadMessages()) return;
|
||||
|
||||
plugin.getLogger().info("Loaded locale " + fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the language that this locale is based on.
|
||||
* (i.e. "en" for English, or "fr" for French)
|
||||
*
|
||||
* @return the name of the language
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the region that this locale is from.
|
||||
* (i.e. "US" for United States or "CA" for Canada)
|
||||
*
|
||||
* @return the name of the region
|
||||
*/
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the entire locale tag (i.e. "en_US")
|
||||
*
|
||||
* @return the language tag
|
||||
*/
|
||||
public String getLanguageTag() {
|
||||
return name + "_" + region;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file that represents this locale
|
||||
*
|
||||
* @return the locale file (.lang)
|
||||
*/
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a message set for a specific node
|
||||
*
|
||||
* @param node the node to get
|
||||
* @return the message for the specified node
|
||||
*/
|
||||
public String getMessage(String node) {
|
||||
return ChatColor.translateAlternateColorCodes('&', this.getMessageOrDefault(node, node));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a message set for a specific node and replace its params with a supplied arguments.
|
||||
*
|
||||
* @param node the node to get
|
||||
* @param args the replacement arguments
|
||||
* @return the message for the specified node
|
||||
*/
|
||||
public String getMessage(String node, Object... args) {
|
||||
String message = getMessage(node);
|
||||
for (Object arg : args) {
|
||||
message = message.replaceFirst("%.*?%", arg.toString());
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a message set for a specific node
|
||||
*
|
||||
* @param node the node to get
|
||||
* @param defaultValue the default value given that a value for the node was not found
|
||||
*
|
||||
* @return the message for the specified node. Default if none found
|
||||
*/
|
||||
public String getMessageOrDefault(String node, String defaultValue) {
|
||||
return this.nodes.getOrDefault(node, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the key-value map of nodes to messages
|
||||
*
|
||||
* @return node-message map
|
||||
*/
|
||||
public Map<String, String> getMessageNodeMap() {
|
||||
return ImmutableMap.copyOf(nodes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the previous message cache and load new messages directly from file
|
||||
*
|
||||
* @return reload messages from file
|
||||
*/
|
||||
public boolean reloadMessages() {
|
||||
if (!this.file.exists()) {
|
||||
plugin.getLogger().warning("Could not find file for locale " + this.name);
|
||||
return false;
|
||||
}
|
||||
|
||||
this.nodes.clear(); // Clear previous data (if any)
|
||||
|
||||
try(BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||
String line;
|
||||
for (int lineNumber = 0; (line = reader.readLine()) != null; lineNumber++) {
|
||||
if (line.isEmpty() || line.startsWith("#") /* Comment */) continue;
|
||||
|
||||
Matcher matcher = NODE_PATTERN.matcher(line);
|
||||
if (!matcher.find()) {
|
||||
System.err.println("Invalid locale syntax at (line=" + lineNumber + ")");
|
||||
continue;
|
||||
}
|
||||
|
||||
nodes.put(matcher.group(1), matcher.group(2));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the locale class to generate information and search for localizations.
|
||||
* This must be called before any other methods in the Locale class can be invoked.
|
||||
* Note that this will also call {@link #searchForLocales()}, so there is no need to
|
||||
* invoke it for yourself after the initialization
|
||||
*
|
||||
* @param plugin the plugin instance
|
||||
*/
|
||||
public static void init(JavaPlugin plugin) {
|
||||
Locale.plugin = plugin;
|
||||
|
||||
if (localeFolder == null) {
|
||||
localeFolder = new File(plugin.getDataFolder(), "locales/");
|
||||
}
|
||||
|
||||
localeFolder.mkdirs();
|
||||
Locale.searchForLocales();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all .lang file locales under the "locales" folder
|
||||
*/
|
||||
public static void searchForLocales() {
|
||||
if (!localeFolder.exists()) localeFolder.mkdirs();
|
||||
|
||||
for (File file : localeFolder.listFiles()) {
|
||||
String name = file.getName();
|
||||
if (!name.endsWith(".lang")) continue;
|
||||
|
||||
String fileName = name.substring(0, name.lastIndexOf('.'));
|
||||
String[] localeValues = fileName.split("_");
|
||||
|
||||
if (localeValues.length != 2) continue;
|
||||
if (localeExists(localeValues[0] + "_" + localeValues[1])) continue;
|
||||
|
||||
LOCALES.add(new Locale(localeValues[0], localeValues[1]));
|
||||
plugin.getLogger().info("Found and loaded locale \"" + fileName + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a locale by its entire proper name (i.e. "en_US")
|
||||
*
|
||||
* @param name the full name of the locale
|
||||
* @return locale of the specified name
|
||||
*/
|
||||
public static Locale getLocale(String name) {
|
||||
for (Locale locale : LOCALES)
|
||||
if (locale.getLanguageTag().equalsIgnoreCase(name)) return locale;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a locale from the cache by its name (i.e. "en" from "en_US")
|
||||
*
|
||||
* @param name the name of the language
|
||||
* @return locale of the specified language. Null if not cached
|
||||
*/
|
||||
public static Locale getLocaleByName(String name) {
|
||||
for (Locale locale : LOCALES)
|
||||
if (locale.getName().equalsIgnoreCase(name)) return locale;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a locale from the cache by its region (i.e. "US" from "en_US")
|
||||
*
|
||||
* @param region the name of the region
|
||||
* @return locale of the specified region. Null if not cached
|
||||
*/
|
||||
public static Locale getLocaleByRegion(String region) {
|
||||
for (Locale locale : LOCALES)
|
||||
if (locale.getRegion().equalsIgnoreCase(region)) return locale;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a locale exists and is registered or not
|
||||
*
|
||||
* @param name the whole language tag (i.e. "en_US")
|
||||
* @return true if it exists
|
||||
*/
|
||||
public static boolean localeExists(String name) {
|
||||
for (Locale locale : LOCALES)
|
||||
if (locale.getLanguageTag().equals(name)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an immutable list of all currently loaded locales
|
||||
*
|
||||
* @return list of all locales
|
||||
*/
|
||||
public static List<Locale> getLocales() {
|
||||
return ImmutableList.copyOf(LOCALES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a default locale file from the project source directory, to the locale folder
|
||||
*
|
||||
* @param path the path to the file to save
|
||||
* @param fileName the name of the file to save
|
||||
*
|
||||
* @return true if the operation was successful, false otherwise
|
||||
*/
|
||||
public static boolean saveDefaultLocale(String path, String fileName) {
|
||||
if (!localeFolder.exists()) localeFolder.mkdirs();
|
||||
|
||||
if (!fileName.endsWith(FILE_EXTENSION))
|
||||
fileName = (fileName.lastIndexOf(".") == -1 ? fileName : fileName.substring(0, fileName.lastIndexOf('.'))) + FILE_EXTENSION;
|
||||
|
||||
File destinationFile = new File(localeFolder, fileName);
|
||||
if (destinationFile.exists()) {
|
||||
return compareFiles(plugin.getResource(fileName), destinationFile);
|
||||
}
|
||||
|
||||
try (OutputStream outputStream = new FileOutputStream(destinationFile)) {
|
||||
IOUtils.copy(plugin.getResource(fileName), outputStream);
|
||||
|
||||
fileName = fileName.substring(0, fileName.lastIndexOf('.'));
|
||||
String[] localeValues = fileName.split("_");
|
||||
|
||||
if (localeValues.length != 2) return false;
|
||||
|
||||
LOCALES.add(new Locale(localeValues[0], localeValues[1]));
|
||||
if (defaultLocale == null) defaultLocale = fileName;
|
||||
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a default locale file from the project source directory, to the locale folder
|
||||
*
|
||||
* @param fileName the name of the file to save
|
||||
* @return true if the operation was successful, false otherwise
|
||||
*/
|
||||
public static boolean saveDefaultLocale(String fileName) {
|
||||
return saveDefaultLocale("", fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all current locale data
|
||||
*/
|
||||
public static void clearLocaleData() {
|
||||
for (Locale locale : LOCALES)
|
||||
locale.nodes.clear();
|
||||
LOCALES.clear();
|
||||
}
|
||||
|
||||
// Write new changes to existing files, if any at all
|
||||
private static boolean compareFiles(InputStream defaultFile, File existingFile) {
|
||||
// Look for default
|
||||
if (defaultFile == null) {
|
||||
defaultFile = plugin.getResource(defaultLocale != null ? defaultLocale : "en_US");
|
||||
if (defaultFile == null) return false; // No default at all
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
|
||||
List<String> defaultLines, existingLines;
|
||||
try (BufferedReader defaultReader = new BufferedReader(new InputStreamReader(defaultFile));
|
||||
BufferedReader existingReader = new BufferedReader(new FileReader(existingFile));
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter(existingFile, true))) {
|
||||
defaultLines = defaultReader.lines().collect(Collectors.toList());
|
||||
existingLines = existingReader.lines().map(s -> s.split("\\s*=")[0]).collect(Collectors.toList());
|
||||
|
||||
for (String defaultValue : defaultLines) {
|
||||
if (defaultValue.isEmpty() || defaultValue.startsWith("#")) continue;
|
||||
|
||||
String key = defaultValue.split("\\s*=")[0];
|
||||
|
||||
if (!existingLines.contains(key)) {
|
||||
if (!changed) {
|
||||
writer.newLine(); writer.newLine();
|
||||
writer.write("# New messages for " + plugin.getName() + " v" + plugin.getDescription().getVersion());
|
||||
}
|
||||
|
||||
writer.newLine();
|
||||
writer.write(defaultValue);
|
||||
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
}
|
@ -1,14 +1,14 @@
|
||||
package com.songoda.epichoppers;
|
||||
|
||||
public class References {
|
||||
|
||||
private String prefix;
|
||||
|
||||
public References() {
|
||||
prefix = EpicHoppers.getInstance().getLocale().getMessage("general.nametag.prefix") + " ";
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return this.prefix;
|
||||
}
|
||||
}
|
||||
package com.songoda.epichoppers;
|
||||
|
||||
public class References {
|
||||
|
||||
private String prefix;
|
||||
|
||||
public References() {
|
||||
prefix = EpicHoppers.getInstance().getLocale().getMessage("general.nametag.prefix") + " ";
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return this.prefix;
|
||||
}
|
||||
}
|
||||
|
@ -1,31 +1,31 @@
|
||||
package com.songoda.epichoppers.Utils;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/21/2017.
|
||||
*/
|
||||
public class Debugger {
|
||||
|
||||
|
||||
public static void runReport(Exception e) {
|
||||
if (isDebug()) {
|
||||
System.out.println("==============================================================");
|
||||
System.out.println("The following is an error encountered in EpicHoppers.");
|
||||
System.out.println("--------------------------------------------------------------");
|
||||
e.printStackTrace();
|
||||
System.out.println("==============================================================");
|
||||
}
|
||||
sendReport(e);
|
||||
}
|
||||
|
||||
public static void sendReport(Exception e) {
|
||||
|
||||
}
|
||||
|
||||
public static boolean isDebug() {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
return instance.getConfig().getBoolean("System.Debugger Enabled");
|
||||
}
|
||||
|
||||
}
|
||||
package com.songoda.epichoppers.Utils;
|
||||
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
|
||||
/**
|
||||
* Created by songoda on 3/21/2017.
|
||||
*/
|
||||
public class Debugger {
|
||||
|
||||
|
||||
public static void runReport(Exception e) {
|
||||
if (isDebug()) {
|
||||
System.out.println("==============================================================");
|
||||
System.out.println("The following is an error encountered in EpicHoppers.");
|
||||
System.out.println("--------------------------------------------------------------");
|
||||
e.printStackTrace();
|
||||
System.out.println("==============================================================");
|
||||
}
|
||||
sendReport(e);
|
||||
}
|
||||
|
||||
public static void sendReport(Exception e) {
|
||||
|
||||
}
|
||||
|
||||
public static boolean isDebug() {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
return instance.getConfig().getBoolean("System.Debugger Enabled");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,118 +1,92 @@
|
||||
package com.songoda.epichoppers.Utils;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Hopper.Hopper;
|
||||
import net.minecraft.server.v1_7_R4.AxisAlignedBB;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by songoda on 2/24/2017.
|
||||
*/
|
||||
public class Methods {
|
||||
|
||||
public static boolean isSync(Player p) {
|
||||
try {
|
||||
if (p.getItemInHand().hasItemMeta()
|
||||
&& p.getItemInHand().getType() != Material.AIR
|
||||
&& p.getItemInHand().getItemMeta().hasLore()) {
|
||||
for (String str : p.getItemInHand().getItemMeta().getLore()) {
|
||||
if (str.equals(Arconix.pl().getApi().format().formatText("&7Sync Touch")) || str.equals(Arconix.pl().getApi().format().formatText("&aSync Touch"))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ItemStack getGlass() {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
return Arconix.pl().getApi().getGUI().getGlass(instance.getConfig().getBoolean("Interfaces.Replace Glass Type 1 With Rainbow Glass"), instance.getConfig().getInt("Interfaces.Glass Type 1"));
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ItemStack getBackgroundGlass(boolean type) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
if (type)
|
||||
return Arconix.pl().getApi().getGUI().getGlass(false, instance.getConfig().getInt("Interfaces.Glass Type 2"));
|
||||
else
|
||||
return Arconix.pl().getApi().getGUI().getGlass(false, instance.getConfig().getInt("Interfaces.Glass Type 3"));
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String formatName(int level, boolean full) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
String name = instance.getLocale().getMessage("general.nametag.nameformat", level);
|
||||
|
||||
String info = "";
|
||||
if (full) {
|
||||
info += Arconix.pl().getApi().format().convertToInvisibleString(level + ":");
|
||||
}
|
||||
|
||||
return info + Arconix.pl().getApi().format().formatText(name);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void doParticles(Player p, Location location) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
location.setX(location.getX() + .5);
|
||||
location.setY(location.getY() + .5);
|
||||
location.setZ(location.getZ() + .5);
|
||||
if (!instance.v1_8 && !instance.v1_7) {
|
||||
p.getWorld().spawnParticle(org.bukkit.Particle.valueOf(instance.getConfig().getString("Main.Upgrade Particle Type")), location, 200, .5, .5, .5);
|
||||
} else {
|
||||
p.getWorld().playEffect(location, org.bukkit.Effect.valueOf(instance.getConfig().getString("Main.Upgrade Particle Type")), 1, 0);
|
||||
//Does not resolve --Nova
|
||||
//p.getWorld().spigot().playEffect(location, org.bukkit.Effect.valueOf(instance.getConfig().getString("Main.Upgrade Particle Type")), 1, 0, (float) 1, (float) 1, (float) 1, 1, 200, 10);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Collection<Entity> getNearbyEntities(Location location, double x, double y, double z) {
|
||||
if (location == null) return Collections.emptyList();
|
||||
|
||||
World world = location.getWorld();
|
||||
AxisAlignedBB aabb = AxisAlignedBB.a(location.getX() - x, location.getY() - y, location.getZ() - z, location.getX() + x, location.getY() + y, location.getZ() + z);
|
||||
List<net.minecraft.server.v1_7_R4.Entity> entityList = ((CraftWorld) world).getHandle().getEntities(null, aabb, null);
|
||||
List<Entity> bukkitEntityList = new ArrayList<>();
|
||||
|
||||
for (Object entity : entityList) {
|
||||
bukkitEntityList.add(((net.minecraft.server.v1_7_R4.Entity) entity).getBukkitEntity());
|
||||
}
|
||||
|
||||
return bukkitEntityList;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
package com.songoda.epichoppers.Utils;
|
||||
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import com.songoda.epichoppers.Hopper.Hopper;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by songoda on 2/24/2017.
|
||||
*/
|
||||
public class Methods {
|
||||
|
||||
public static boolean isSync(Player p) {
|
||||
try {
|
||||
if (p.getItemInHand().hasItemMeta()
|
||||
&& p.getItemInHand().getType() != Material.AIR
|
||||
&& p.getItemInHand().getItemMeta().hasLore()) {
|
||||
for (String str : p.getItemInHand().getItemMeta().getLore()) {
|
||||
if (str.equals(Arconix.pl().getApi().format().formatText("&7Sync Touch")) || str.equals(Arconix.pl().getApi().format().formatText("&aSync Touch"))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ItemStack getGlass() {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
return Arconix.pl().getApi().getGUI().getGlass(instance.getConfig().getBoolean("Interfaces.Replace Glass Type 1 With Rainbow Glass"), instance.getConfig().getInt("Interfaces.Glass Type 1"));
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ItemStack getBackgroundGlass(boolean type) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
if (type)
|
||||
return Arconix.pl().getApi().getGUI().getGlass(false, instance.getConfig().getInt("Interfaces.Glass Type 2"));
|
||||
else
|
||||
return Arconix.pl().getApi().getGUI().getGlass(false, instance.getConfig().getInt("Interfaces.Glass Type 3"));
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String formatName(int level, boolean full) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
String name = instance.getLocale().getMessage("general.nametag.nameformat", level);
|
||||
|
||||
String info = "";
|
||||
if (full) {
|
||||
info += Arconix.pl().getApi().format().convertToInvisibleString(level + ":");
|
||||
}
|
||||
|
||||
return info + Arconix.pl().getApi().format().formatText(name);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void doParticles(Player p, Location location) {
|
||||
try {
|
||||
EpicHoppers instance = EpicHoppers.getInstance();
|
||||
location.setX(location.getX() + .5);
|
||||
location.setY(location.getY() + .5);
|
||||
location.setZ(location.getZ() + .5);
|
||||
p.getWorld().spawnParticle(org.bukkit.Particle.valueOf(instance.getConfig().getString("Main.Upgrade Particle Type")), location, 200, .5, .5, .5);
|
||||
} catch (Exception e) {
|
||||
Debugger.runReport(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,257 +1,239 @@
|
||||
package com.songoda.epichoppers.Utils;
|
||||
|
||||
import com.songoda.arconix.api.utils.ConfigWrapper;
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Created by songo on 6/4/2017.
|
||||
*/
|
||||
public class SettingsManager implements Listener {
|
||||
|
||||
private String pluginName = "EpicHoppers";
|
||||
private final EpicHoppers instance;
|
||||
|
||||
private static ConfigWrapper defs;
|
||||
|
||||
private Map<Player, String> cat = new HashMap<>();
|
||||
|
||||
public SettingsManager(EpicHoppers instance) {
|
||||
this.instance = instance;
|
||||
instance.saveResource("SettingDefinitions.yml", true);
|
||||
defs = new ConfigWrapper(instance, "", "SettingDefinitions.yml");
|
||||
defs.createNewFile("Loading data file", "EpicHoppers SettingDefinitions file");
|
||||
instance.getServer().getPluginManager().registerEvents(this, instance);
|
||||
}
|
||||
|
||||
public Map<Player, String> current = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent e) {
|
||||
if (e.getInventory() == null
|
||||
|| e.getCurrentItem() == null
|
||||
|| !e.getCurrentItem().hasItemMeta()
|
||||
|| !e.getCurrentItem().getItemMeta().hasDisplayName()
|
||||
|| e.getWhoClicked().getOpenInventory().getTopInventory() != e.getInventory()) {
|
||||
return;
|
||||
}
|
||||
if (e.getInventory().getTitle().equals(pluginName + " Settings Manager")) {
|
||||
|
||||
if (e.getCurrentItem().getType().equals(Material.STAINED_GLASS_PANE)) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
String type = ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName());
|
||||
cat.put((Player) e.getWhoClicked(), type);
|
||||
openEditor((Player) e.getWhoClicked());
|
||||
e.setCancelled(true);
|
||||
} else if (e.getInventory().getTitle().equals(pluginName + " Settings Editor")) {
|
||||
|
||||
if (e.getCurrentItem().getType().equals(Material.STAINED_GLASS_PANE)) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Player p = (Player) e.getWhoClicked();
|
||||
e.setCancelled(true);
|
||||
|
||||
String key = cat.get(p) + "." + ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName());
|
||||
|
||||
if (instance.getConfig().get(key).getClass().getName().equals("java.lang.Boolean")) {
|
||||
boolean bool = (Boolean) instance.getConfig().get(key);
|
||||
if (!bool)
|
||||
instance.getConfig().set(key, true);
|
||||
else
|
||||
instance.getConfig().set(key, false);
|
||||
finishEditing(p);
|
||||
} else {
|
||||
editObject(p, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChat(AsyncPlayerChatEvent e) {
|
||||
final Player p = e.getPlayer();
|
||||
if (!current.containsKey(p)) {
|
||||
return;
|
||||
}
|
||||
switch (instance.getConfig().get(current.get(p)).getClass().getName()) {
|
||||
case "java.lang.Integer":
|
||||
instance.getConfig().set(current.get(p), Integer.parseInt(e.getMessage()));
|
||||
break;
|
||||
case "java.lang.Double":
|
||||
instance.getConfig().set(current.get(p), Double.parseDouble(e.getMessage()));
|
||||
break;
|
||||
case "java.lang.String":
|
||||
instance.getConfig().set(current.get(p), e.getMessage());
|
||||
break;
|
||||
}
|
||||
finishEditing(p);
|
||||
e.setCancelled(true);
|
||||
|
||||
}
|
||||
|
||||
public void finishEditing(Player p) {
|
||||
current.remove(p);
|
||||
instance.saveConfig();
|
||||
openEditor(p);
|
||||
}
|
||||
|
||||
|
||||
public void editObject(Player p, String current) {
|
||||
this.current.put(p, ChatColor.stripColor(current));
|
||||
p.closeInventory();
|
||||
p.sendMessage("");
|
||||
p.sendMessage(Arconix.pl().getApi().format().formatText("&7Please enter a value for &6" + current + "&7."));
|
||||
if (instance.getConfig().get(current).getClass().getName().equals("java.lang.Integer")) {
|
||||
p.sendMessage(Arconix.pl().getApi().format().formatText("&cUse only numbers."));
|
||||
}
|
||||
p.sendMessage("");
|
||||
}
|
||||
|
||||
public void openSettingsManager(Player p) {
|
||||
Inventory i = Bukkit.createInventory(null, 27, pluginName + " Settings Manager");
|
||||
int nu = 0;
|
||||
while (nu != 27) {
|
||||
i.setItem(nu, Methods.getGlass());
|
||||
nu++;
|
||||
}
|
||||
|
||||
int spot = 10;
|
||||
for (String key : instance.getConfig().getConfigurationSection("").getKeys(false)) {
|
||||
ItemStack item = new ItemStack(Material.WOOL, 1, (byte) (spot - 9));
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setLore(Collections.singletonList(Arconix.pl().getApi().format().formatText("&6Click To Edit This Category.")));
|
||||
meta.setDisplayName(Arconix.pl().getApi().format().formatText("&f&l" + key));
|
||||
item.setItemMeta(meta);
|
||||
i.setItem(spot, item);
|
||||
spot++;
|
||||
}
|
||||
p.openInventory(i);
|
||||
}
|
||||
|
||||
public void openEditor(Player p) {
|
||||
Inventory i = Bukkit.createInventory(null, 54, pluginName + " Settings Editor");
|
||||
|
||||
int num = 0;
|
||||
for (String key : instance.getConfig().getConfigurationSection(cat.get(p)).getKeys(true)) {
|
||||
String fKey = cat.get(p) + "." + key;
|
||||
ItemStack item = new ItemStack(Material.DIAMOND_HELMET);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(Arconix.pl().getApi().format().formatText("&6" + key));
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
switch (instance.getConfig().get(fKey).getClass().getName()) {
|
||||
case "java.lang.Boolean":
|
||||
|
||||
item.setType(Material.LEVER);
|
||||
boolean bool = (Boolean) instance.getConfig().get(fKey);
|
||||
|
||||
if (!bool)
|
||||
lore.add(Arconix.pl().getApi().format().formatText("&c" + false));
|
||||
else
|
||||
lore.add(Arconix.pl().getApi().format().formatText("&a" + true));
|
||||
|
||||
break;
|
||||
case "java.lang.String":
|
||||
item.setType(Material.PAPER);
|
||||
String str = (String) instance.getConfig().get(fKey);
|
||||
lore.add(Arconix.pl().getApi().format().formatText("&9" + str));
|
||||
break;
|
||||
case "java.lang.Integer":
|
||||
item.setType(Material.WATCH);
|
||||
|
||||
int in = (Integer) instance.getConfig().get(fKey);
|
||||
lore.add(Arconix.pl().getApi().format().formatText("&5" + in));
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
if (defs.getConfig().contains(fKey)) {
|
||||
String text = defs.getConfig().getString(key);
|
||||
|
||||
Pattern regex = Pattern.compile("(.{1,28}(?:\\s|$))|(.{0,28})", Pattern.DOTALL);
|
||||
Matcher m = regex.matcher(text);
|
||||
while (m.find()) {
|
||||
if (m.end() != text.length() || m.group().length() != 0)
|
||||
lore.add(Arconix.pl().getApi().format().formatText("&7" + m.group()));
|
||||
}
|
||||
}
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
|
||||
i.setItem(num, item);
|
||||
num++;
|
||||
}
|
||||
p.openInventory(i);
|
||||
}
|
||||
|
||||
public void updateSettings() {
|
||||
for (settings s : settings.values()) {
|
||||
if (instance.getConfig().contains("settings." + s.oldSetting)) {
|
||||
instance.getConfig().addDefault(s.setting, instance.getConfig().get("settings." + s.oldSetting));
|
||||
instance.getConfig().set("settings." + s.oldSetting, null);
|
||||
} else if (s.setting.equals("Main.Upgrade Particle Type")) {
|
||||
if (instance.v1_7 || instance.v1_8)
|
||||
instance.getConfig().addDefault(s.setting, "WITCH_MAGIC");
|
||||
else
|
||||
instance.getConfig().addDefault(s.setting, s.option);
|
||||
} else
|
||||
instance.getConfig().addDefault(s.setting, s.option);
|
||||
}
|
||||
}
|
||||
|
||||
public enum settings {
|
||||
o1("Upgrading-enabled", "Main.Allow Hopper Upgrading", true),
|
||||
o2("Upgrade-with-eco", "Main.Upgrade With Economy", true),
|
||||
o3("Upgrade-with-xp", "Main.Upgrade With XP", true),
|
||||
o4("Teleport-hoppers", "Main.Allow Players To Teleport Through Hoppers", true),
|
||||
o5("Filter-hoppers", "Main.Allow Players To use The Hopper Filter", true),
|
||||
o6("EnderChest-support", "Main.Support Enderchests", true),
|
||||
o7("Upgrade-particle-type", "Main.Upgrade Particle Type", "SPELL_WITCH"),
|
||||
o8("Hop-Tick", "Main.Amount of Ticks Between Hops", 8L),
|
||||
o9("Tele-Tick", "Main.Amount of Ticks Between Teleport", 10L),
|
||||
o10("Sync-Timeout", "Main.Timeout When Syncing Hoppers", 300L),
|
||||
o11("hopper-Limit", "Main.Max Hoppers Per Chunk", -1),
|
||||
o12("Helpful-Tips", "Main.Display Helpful Tips For Operators", true),
|
||||
o13("Sounds", "Main.Sounds Enabled", true),
|
||||
o14("BlockBreak-Particle-Type", "Main.BlockBreak Particle Type", "LAVA"),
|
||||
o15("BlockBreak-Blacklist", "Main.BlockBreak Blacklisted Blocks", Arrays.asList("BEDROCK")),
|
||||
|
||||
o16("Rainbow-Glass", "Interfaces.Replace Glass Type 1 With Rainbow Glass", false),
|
||||
o17("ECO-Icon", "Interfaces.Economy Icon", "DOUBLE_PLANT"),
|
||||
o18("XP-Icon", "Interfaces.XP Icon", "EXP_BOTTLE"),
|
||||
o19("Glass-Type-1", "Interfaces.Glass Type 1", 7),
|
||||
o20("Glass-Type-2", "Interfaces.Glass Type 2", 11),
|
||||
o21("Glass-Type-3", "Interfaces.Glass Type 3", 3),
|
||||
|
||||
o22("Debug-Mode", "System.Debugger Enabled", false);
|
||||
|
||||
private String setting;
|
||||
private String oldSetting;
|
||||
private Object option;
|
||||
|
||||
settings(String oldSetting, String setting, Object option) {
|
||||
this.oldSetting = oldSetting;
|
||||
this.setting = setting;
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
}
|
||||
package com.songoda.epichoppers.Utils;
|
||||
|
||||
import com.songoda.arconix.api.methods.formatting.TextComponent;
|
||||
import com.songoda.arconix.api.utils.ConfigWrapper;
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epichoppers.EpicHoppers;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Created by songo on 6/4/2017.
|
||||
*/
|
||||
public class SettingsManager implements Listener {
|
||||
|
||||
private String pluginName = "EpicHoppers";
|
||||
|
||||
private static final Pattern SETTINGS_PATTERN = Pattern.compile("(.{1,28}(?:\\s|$))|(.{0,28})", Pattern.DOTALL);
|
||||
|
||||
private static ConfigWrapper defs;
|
||||
|
||||
private Map<Player, String> cat = new HashMap<>();
|
||||
|
||||
private final EpicHoppers instance;
|
||||
|
||||
public SettingsManager(EpicHoppers plugin) {
|
||||
this.instance = plugin;
|
||||
|
||||
plugin.saveResource("SettingDefinitions.yml", true);
|
||||
defs = new ConfigWrapper(plugin, "", "SettingDefinitions.yml");
|
||||
defs.createNewFile("Loading data file", pluginName + " SettingDefinitions file");
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
private Map<Player, String> current = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
ItemStack clickedItem = event.getCurrentItem();
|
||||
|
||||
if (event.getInventory() != event.getWhoClicked().getOpenInventory().getTopInventory()
|
||||
|| clickedItem == null || !clickedItem.hasItemMeta()
|
||||
|| !clickedItem.getItemMeta().hasDisplayName()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getInventory().getTitle().equals(pluginName + " Settings Manager")) {
|
||||
event.setCancelled(true);
|
||||
if (clickedItem.getType().name().contains("STAINED_GLASS")) return;
|
||||
|
||||
String type = ChatColor.stripColor(clickedItem.getItemMeta().getDisplayName());
|
||||
this.cat.put((Player) event.getWhoClicked(), type);
|
||||
this.openEditor((Player) event.getWhoClicked());
|
||||
} else if (event.getInventory().getTitle().equals(pluginName + " Settings Editor")) {
|
||||
event.setCancelled(true);
|
||||
if (clickedItem.getType().name().contains("STAINED_GLASS")) return;
|
||||
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
|
||||
String key = cat.get(player) + "." + ChatColor.stripColor(clickedItem.getItemMeta().getDisplayName());
|
||||
|
||||
if (instance.getConfig().get(key).getClass().getName().equals("java.lang.Boolean")) {
|
||||
this.instance.getConfig().set(key, !instance.getConfig().getBoolean(key));
|
||||
this.finishEditing(player);
|
||||
} else {
|
||||
this.editObject(player, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChat(AsyncPlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (!current.containsKey(player)) return;
|
||||
|
||||
String value = current.get(player);
|
||||
FileConfiguration config = instance.getConfig();
|
||||
if (config.isInt(value)) {
|
||||
config.set(value, Integer.parseInt(event.getMessage()));
|
||||
} else if (config.isDouble(value)) {
|
||||
config.set(value, Double.parseDouble(event.getMessage()));
|
||||
} else if (config.isString(value)) {
|
||||
config.set(value, event.getMessage());
|
||||
}
|
||||
|
||||
this.finishEditing(player);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
public void finishEditing(Player player) {
|
||||
this.current.remove(player);
|
||||
this.instance.saveConfig();
|
||||
this.openEditor(player);
|
||||
}
|
||||
|
||||
|
||||
public void editObject(Player player, String current) {
|
||||
this.current.put(player, ChatColor.stripColor(current));
|
||||
|
||||
player.closeInventory();
|
||||
player.sendMessage("");
|
||||
player.sendMessage(TextComponent.formatText("&7Please enter a value for &6" + current + "&7."));
|
||||
if (instance.getConfig().isInt(current) || instance.getConfig().isDouble(current)) {
|
||||
player.sendMessage(TextComponent.formatText("&cUse only numbers."));
|
||||
}
|
||||
player.sendMessage("");
|
||||
}
|
||||
|
||||
public void openSettingsManager(Player player) {
|
||||
Inventory inventory = Bukkit.createInventory(null, 27, pluginName + " Settings Manager");
|
||||
ItemStack glass = Methods.getGlass();
|
||||
for (int i = 0; i < inventory.getSize(); i++) {
|
||||
inventory.setItem(i, glass);
|
||||
}
|
||||
|
||||
int slot = 10;
|
||||
for (String key : instance.getConfig().getDefaultSection().getKeys(false)) {
|
||||
ItemStack item = new ItemStack(Material.WHITE_WOOL, 1, (byte) (slot - 9)); //ToDo: Make this function as it was meant to.
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setLore(Collections.singletonList(TextComponent.formatText("&6Click To Edit This Category.")));
|
||||
meta.setDisplayName(TextComponent.formatText("&f&l" + key));
|
||||
item.setItemMeta(meta);
|
||||
inventory.setItem(slot, item);
|
||||
slot++;
|
||||
}
|
||||
|
||||
player.openInventory(inventory);
|
||||
}
|
||||
|
||||
public void openEditor(Player player) {
|
||||
Inventory inventory = Bukkit.createInventory(null, 54, pluginName + " Settings Editor");
|
||||
FileConfiguration config = instance.getConfig();
|
||||
|
||||
int slot = 0;
|
||||
for (String key : config.getConfigurationSection(cat.get(player)).getKeys(true)) {
|
||||
String fKey = cat.get(player) + "." + key;
|
||||
ItemStack item = new ItemStack(Material.DIAMOND_HELMET);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(TextComponent.formatText("&6" + key));
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
if (config.isBoolean(fKey)) {
|
||||
item.setType(Material.LEVER);
|
||||
lore.add(TextComponent.formatText(config.getBoolean(fKey) ? "&atrue" : "&cfalse"));
|
||||
} else if (config.isString(fKey)) {
|
||||
item.setType(Material.PAPER);
|
||||
lore.add(TextComponent.formatText("&9" + config.getString(fKey)));
|
||||
} else if (config.isInt(fKey)) {
|
||||
item.setType(Material.CLOCK);
|
||||
lore.add(TextComponent.formatText("&5" + config.getInt(fKey)));
|
||||
}
|
||||
|
||||
if (defs.getConfig().contains(fKey)) {
|
||||
String text = defs.getConfig().getString(key);
|
||||
|
||||
Matcher m = SETTINGS_PATTERN.matcher(text);
|
||||
while (m.find()) {
|
||||
if (m.end() != text.length() || m.group().length() != 0)
|
||||
lore.add(TextComponent.formatText("&7" + m.group()));
|
||||
}
|
||||
}
|
||||
|
||||
meta.setLore(lore);
|
||||
item.setItemMeta(meta);
|
||||
|
||||
inventory.setItem(slot, item);
|
||||
slot++;
|
||||
}
|
||||
|
||||
player.openInventory(inventory);
|
||||
}
|
||||
|
||||
public void updateSettings() {
|
||||
FileConfiguration config = instance.getConfig();
|
||||
|
||||
for (Setting setting : Setting.values()) {
|
||||
if (config.contains("settings." + setting.oldSetting)) {
|
||||
config.addDefault(setting.setting, instance.getConfig().get("settings." + setting.oldSetting));
|
||||
config.set("settings." + setting.oldSetting, null);
|
||||
} else if (setting.setting.equals("Main.Upgrade Particle Type")) {
|
||||
config.addDefault(setting.setting, setting.option);
|
||||
} else {
|
||||
config.addDefault(setting.setting, setting.option);
|
||||
}
|
||||
}
|
||||
|
||||
config.set("settings", null);
|
||||
}
|
||||
public enum Setting {
|
||||
o1("Upgrading-enabled", "Main.Allow Hopper Upgrading", true),
|
||||
o2("Upgrade-with-eco", "Main.Upgrade With Economy", true),
|
||||
o3("Upgrade-with-xp", "Main.Upgrade With XP", true),
|
||||
o4("Teleport-hoppers", "Main.Allow Players To Teleport Through Hoppers", true),
|
||||
o5("Filter-hoppers", "Main.Allow Players To use The Hopper Filter", true),
|
||||
o6("EnderChest-support", "Main.Support Enderchests", true),
|
||||
o7("Upgrade-particle-type", "Main.Upgrade Particle Type", "SPELL_WITCH"),
|
||||
o8("Hop-Tick", "Main.Amount of Ticks Between Hops", 8L),
|
||||
o9("Tele-Tick", "Main.Amount of Ticks Between Teleport", 10L),
|
||||
o10("Sync-Timeout", "Main.Timeout When Syncing Hoppers", 300L),
|
||||
o11("hopper-Limit", "Main.Max Hoppers Per Chunk", -1),
|
||||
o12("Helpful-Tips", "Main.Display Helpful Tips For Operators", true),
|
||||
o13("Sounds", "Main.Sounds Enabled", true),
|
||||
o14("BlockBreak-Particle-Type", "Main.BlockBreak Particle Type", "LAVA"),
|
||||
o15("BlockBreak-Blacklist", "Main.BlockBreak Blacklisted Blocks", Arrays.asList("BEDROCK")),
|
||||
|
||||
o16("Rainbow-Glass", "Interfaces.Replace Glass Type 1 With Rainbow Glass", false),
|
||||
o17("ECO-Icon", "Interfaces.Economy Icon", "SUNFLOWER"),
|
||||
o18("XP-Icon", "Interfaces.XP Icon", "EXPERIENCE_BOTTLE"),
|
||||
o19("Glass-Type-1", "Interfaces.Glass Type 1", 7),
|
||||
o20("Glass-Type-2", "Interfaces.Glass Type 2", 11),
|
||||
o21("Glass-Type-3", "Interfaces.Glass Type 3", 3),
|
||||
|
||||
o22("Debug-Mode", "System.Debugger Enabled", false);
|
||||
|
||||
private String setting;
|
||||
private String oldSetting;
|
||||
private Object option;
|
||||
|
||||
Setting(String oldSetting, String setting, Object option) {
|
||||
this.oldSetting = oldSetting;
|
||||
this.setting = setting;
|
||||
this.option = option;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,14 +1,14 @@
|
||||
ECO-Icon: 'This is the default icon that will be used for the Economy upgrade button.'
|
||||
XP-Icon: 'This is the default icon that will be used for the Experience upgrade button.'
|
||||
Upgrading-enabled: 'Setting this to true will allow users to access the upgrade window.'
|
||||
Upgrade-with-eco: 'Setting this to true will allow users to use Economy to upgrade their hoppers.'
|
||||
Upgrade-with-xp: 'Setting this to true will allow users to use Experience to upgrade their hoppers.'
|
||||
On-upgrade-particles: 'Setting this to true will cause particles to emit when a hopper is upgraded.'
|
||||
Teleport-hoppers: 'These are the default levels, the amount of levels can be expanded if you want, just add another level to the bottom of the list while keeping numeric order. Allows you to enable or disable teleporting with hoppers'
|
||||
Hop-Tick: 'This is the tick speed for synced hoppers.'
|
||||
Sync-Timeout: 'This is the timeout that if reached will cancel a sync.'
|
||||
Glass-Type: 'This is the id of the glass used for the background in the guis.'
|
||||
Rainbow-Glass: 'If this is enabled the glass background will be randomized colors. '
|
||||
Limit-Hoppers-Per-Chunk: 'If enabled this will limit the amount hoppers per chunk'
|
||||
Hopper-Limit: 'This is the amount of allowed hoppers per chunk.'
|
||||
Upgrade-particle-type: 'This is the type of particle an upgrade will emit.'
|
||||
ECO-Icon: 'This is the default icon that will be used for the Economy upgrade button.'
|
||||
XP-Icon: 'This is the default icon that will be used for the Experience upgrade button.'
|
||||
Upgrading-enabled: 'Setting this to true will allow users to access the upgrade window.'
|
||||
Upgrade-with-eco: 'Setting this to true will allow users to use Economy to upgrade their hoppers.'
|
||||
Upgrade-with-xp: 'Setting this to true will allow users to use Experience to upgrade their hoppers.'
|
||||
On-upgrade-particles: 'Setting this to true will cause particles to emit when a hopper is upgraded.'
|
||||
Teleport-hoppers: 'These are the default levels, the amount of levels can be expanded if you want, just add another level to the bottom of the list while keeping numeric order. Allows you to enable or disable teleporting with hoppers'
|
||||
Hop-Tick: 'This is the tick speed for synced hoppers.'
|
||||
Sync-Timeout: 'This is the timeout that if reached will cancel a sync.'
|
||||
Glass-Type: 'This is the id of the glass used for the background in the guis.'
|
||||
Rainbow-Glass: 'If this is enabled the glass background will be randomized colors. '
|
||||
Limit-Hoppers-Per-Chunk: 'If enabled this will limit the amount hoppers per chunk'
|
||||
Hopper-Limit: 'This is the amount of allowed hoppers per chunk.'
|
||||
Upgrade-particle-type: 'This is the type of particle an upgrade will emit.'
|
||||
|
@ -1,53 +1,53 @@
|
||||
#General Messages
|
||||
|
||||
general.nametag.prefix = "&7[&6EpicHoppers&7]"
|
||||
general.nametag.next = "&9Next"
|
||||
general.nametag.back = "&9Back"
|
||||
general.nametag.nameformat = "&eLevel %level% &fHopper"
|
||||
|
||||
#Interface Messages
|
||||
|
||||
interface.hopper.upgradewithxp = "&aUpgrade with XP"
|
||||
interface.hopper.upgradewithxplore = "&7Cost: &a%cost% Levels"
|
||||
interface.hopper.upgradewitheconomy = "&aUpgrade with ECO"
|
||||
interface.hopper.upgradewitheconomylore = "&7Cost: &a$%cost%"
|
||||
interface.hopper.currentlevel = "&6Hopper Level &7%level%"
|
||||
interface.hopper.nextlevel = "&6Next Level &7%level%"
|
||||
interface.hopper.range = "&7Range: &6%range%"
|
||||
interface.hopper.amount = "&7Amount: &6%amount%"
|
||||
interface.hopper.suction = "&7Suction: &6%suction%"
|
||||
interface.hopper.blockbreak = "&7Block Break: &6Every %ticks% ticks"
|
||||
interface.hopper.alreadymaxed = "&7This hopper is already maxed out!"
|
||||
interface.hopper.synclore = "|&7Left-Click then click a another|&7hopper or chest to sync!||&7Right-Click to desync."
|
||||
interface.hopper.perltitle = "&6Click to Teleport"
|
||||
interface.hopper.perllore = "|&7Left-Click to teleport to|&7the end of the chain.||&7Right-Click to toggle walk|&7on teleport."
|
||||
interface.hopper.filtertitle = "&cClick to Filter"
|
||||
interface.hopper.filterlore = "|&7This allows you to choose|&7which items go where."
|
||||
interface.hopper.synchopper = "&6Click to Sync This hopper"
|
||||
interface.hopper.rejectsync = "&6Click to Sync Rejected Items"
|
||||
interface.filter.infotitle = "&aFilter Guide"
|
||||
interface.filter.infolore = "&7Items placed in the top left|&7space will be whitelisted.||&7Items placed in the right|&7will be void.||&7Items placed in the bottom left|&7will be blacklisted.||&cUsing the whitelist will disable|&cboth the blacklist and the void."
|
||||
interface.filter.whitelist = "&f&lWhite List"
|
||||
interface.filter.blacklist = "&8&lBlack List"
|
||||
interface.filter.void = "&c&lVoid"
|
||||
|
||||
#Event Messages
|
||||
|
||||
event.general.nopermission = "&cYou do not have permission to do that."
|
||||
event.upgrade.cannotafford = "&cYou cannot afford this upgrade."
|
||||
event.upgrade.success = "&7You successfully upgraded this hopper to &6level %level%&7!"
|
||||
event.upgrade.maxed = "&7You maxed out this hopper at &6level %level%&7."
|
||||
event.inventory.noroom = "&7You do not have space in your inventory for this."
|
||||
event.hopper.syncsuccess = "&aSynchronization Successful."
|
||||
event.hopper.desync = "&7You have desynchronized this hopper."
|
||||
event.hopper.syncnext = "&7Click another hopper or container to sync."
|
||||
event.hopper.syncself = "&cYou can't sync a hopper to itself."
|
||||
event.hopper.synctimeout = "&cSyncing timed out."
|
||||
event.hopper.syncoutofrange = "&cThis block is out of your hoppers range."
|
||||
event.hopper.syncdidnotplace = "&cSorry! You need to have placed this hopper to sync things to it."
|
||||
event.hopper.toomany = "&cYou can only place %amount% hoppers per chunk..."
|
||||
event.hopper.walkteleenabled = "Walk on teleporting has been enabled for this hopper."
|
||||
event.hopper.walkteledisabled = "Walk on teleporting has been disabled for this hopper."
|
||||
event.hopper.onlyone = "&cYou may only place a single item at a time."
|
||||
event.hopper.syncchest = "&7You have synchronized your &9%name% &7with this chest."
|
||||
#General Messages
|
||||
|
||||
general.nametag.prefix = "&7[&6EpicHoppers&7]"
|
||||
general.nametag.next = "&9Next"
|
||||
general.nametag.back = "&9Back"
|
||||
general.nametag.nameformat = "&eLevel %level% &fHopper"
|
||||
|
||||
#Interface Messages
|
||||
|
||||
interface.hopper.upgradewithxp = "&aUpgrade with XP"
|
||||
interface.hopper.upgradewithxplore = "&7Cost: &a%cost% Levels"
|
||||
interface.hopper.upgradewitheconomy = "&aUpgrade with ECO"
|
||||
interface.hopper.upgradewitheconomylore = "&7Cost: &a$%cost%"
|
||||
interface.hopper.currentlevel = "&6Hopper Level &7%level%"
|
||||
interface.hopper.nextlevel = "&6Next Level &7%level%"
|
||||
interface.hopper.range = "&7Range: &6%range%"
|
||||
interface.hopper.amount = "&7Amount: &6%amount%"
|
||||
interface.hopper.suction = "&7Suction: &6%suction%"
|
||||
interface.hopper.blockbreak = "&7Block Break: &6Every %ticks% ticks"
|
||||
interface.hopper.alreadymaxed = "&7This hopper is already maxed out!"
|
||||
interface.hopper.synclore = "|&7Left-Click then click a another|&7hopper or chest to sync!||&7Right-Click to desync."
|
||||
interface.hopper.perltitle = "&6Click to Teleport"
|
||||
interface.hopper.perllore = "|&7Left-Click to teleport to|&7the end of the chain.||&7Right-Click to toggle walk|&7on teleport."
|
||||
interface.hopper.filtertitle = "&cClick to Filter"
|
||||
interface.hopper.filterlore = "|&7This allows you to choose|&7which items go where."
|
||||
interface.hopper.synchopper = "&6Click to Sync This hopper"
|
||||
interface.hopper.rejectsync = "&6Click to Sync Rejected Items"
|
||||
interface.filter.infotitle = "&aFilter Guide"
|
||||
interface.filter.infolore = "&7Items placed in the top left|&7space will be whitelisted.||&7Items placed in the right|&7will be void.||&7Items placed in the bottom left|&7will be blacklisted.||&cUsing the whitelist will disable|&cboth the blacklist and the void."
|
||||
interface.filter.whitelist = "&f&lWhite List"
|
||||
interface.filter.blacklist = "&8&lBlack List"
|
||||
interface.filter.void = "&c&lVoid"
|
||||
|
||||
#Event Messages
|
||||
|
||||
event.general.nopermission = "&cYou do not have permission to do that."
|
||||
event.upgrade.cannotafford = "&cYou cannot afford this upgrade."
|
||||
event.upgrade.success = "&7You successfully upgraded this hopper to &6level %level%&7!"
|
||||
event.upgrade.maxed = "&7You maxed out this hopper at &6level %level%&7."
|
||||
event.inventory.noroom = "&7You do not have space in your inventory for this."
|
||||
event.hopper.syncsuccess = "&aSynchronization Successful."
|
||||
event.hopper.desync = "&7You have desynchronized this hopper."
|
||||
event.hopper.syncnext = "&7Click another hopper or container to sync."
|
||||
event.hopper.syncself = "&cYou can't sync a hopper to itself."
|
||||
event.hopper.synctimeout = "&cSyncing timed out."
|
||||
event.hopper.syncoutofrange = "&cThis block is out of your hoppers range."
|
||||
event.hopper.syncdidnotplace = "&cSorry! You need to have placed this hopper to sync things to it."
|
||||
event.hopper.toomany = "&cYou can only place %amount% hoppers per chunk..."
|
||||
event.hopper.walkteleenabled = "Walk on teleporting has been enabled for this hopper."
|
||||
event.hopper.walkteledisabled = "Walk on teleporting has been disabled for this hopper."
|
||||
event.hopper.onlyone = "&cYou may only place a single item at a time."
|
||||
event.hopper.syncchest = "&7You have synchronized your &9%name% &7with this chest."
|
||||
event.hopper.desyncchest = "&7You have desynchronized your &9%name% &7with this chest."
|
@ -1,13 +1,14 @@
|
||||
name: EpicHoppers
|
||||
description: EpicHoppers
|
||||
main: com.songoda.epichoppers.EpicHoppers
|
||||
depend: [Arconix]
|
||||
softdepend: [Towny, RedProtect, Kingdoms, PlotsSquared, GriefPrevention, USkyBlock, ASkyBlock, WorldGuard, Factions, Vault]
|
||||
version: 2.3.2
|
||||
author: Songoda
|
||||
commands:
|
||||
epichoppers:
|
||||
description: View information on this plugin.
|
||||
default: true
|
||||
aliases: [sc, eh, synccraft]
|
||||
name: EpicHoppers
|
||||
description: EpicHoppers
|
||||
main: com.songoda.epichoppers.EpicHoppers
|
||||
depend: [Arconix]
|
||||
softdepend: [Towny, RedProtect, Kingdoms, PlotsSquared, GriefPrevention, USkyBlock, ASkyBlock, WorldGuard, Factions, Vault]
|
||||
version: 2.3.2
|
||||
author: Songoda
|
||||
api-version: 1.13
|
||||
commands:
|
||||
epichoppers:
|
||||
description: View information on this plugin.
|
||||
default: true
|
||||
aliases: [sc, eh, synccraft]
|
||||
usage: /eh
|
Loading…
Reference in New Issue
Block a user