This commit is contained in:
disclearing 2019-01-21 22:08:39 +00:00
parent 59b3106d29
commit f9bc3ed0fb
524 changed files with 35067 additions and 1 deletions

202
LICENSE.md Normal file
View File

@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Binary file not shown.

BIN
Plugins REQUIRED/KoTH.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Popura-1.0-SNAPSHOT.jar Normal file

Binary file not shown.

10
READ ME.txt Normal file
View File

@ -0,0 +1,10 @@
------------------------------------------------------
1. Minetweak.jar is the custom spigot
2. Put Popura into the plugin folder
3. The .JAR files are in the folders. To easily get them just search .JAR
4. All files contain the src code
5. Upon loading the plugins you will recieve an error w/ Popura. It's because you need to hook into the MySQL database.
6. Enjoy!
------------------------------------------------------

View File

@ -1 +1 @@
# ViperMC-2016-or-some-shit Viper

6
ViperCore/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
*.iml
bin/
META-INF/
target/
.idea/
upload.sh

Binary file not shown.

Binary file not shown.

BIN
ViperCore/libs/KoTH.jar Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

92
ViperCore/pom.xml Normal file
View File

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>net.libhalt.bukkit.kaede</groupId>
<artifactId>ViperCore</artifactId>
<version>0.0.8</version>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sk89q-repo</id>
<url>http://maven.sk89q.com/repo/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
<finalName>${project.artifactId}</finalName>
</build>
<dependencies>
<!--Spigot API-->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.8-R0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/paperspigot-api-1.7.10-R0.1-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-server</artifactId>
<version>1.8-R0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/paperspigot-1.7.10-R0.1-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>io.syuu</groupId>
<artifactId>GenericUtils</artifactId>
<version>0.0.8</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/GenricUtils-1.0-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>io.syuu</groupId>
<artifactId>Popura</artifactId>
<version>0.0.8</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/Popura-1.0-SNAPSHOT.jar</systemPath>
</dependency>
<dependency>
<groupId>vault</groupId>
<artifactId>vault</artifactId>
<version>LATEST</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/Vault-1.4.1.jar</systemPath>
</dependency>
<dependency>
<groupId>subside.plugins</groupId>
<artifactId>KoTH</artifactId>
<version>LATEST</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/KoTH.jar</systemPath>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldguard</artifactId>
<version>6.1.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,76 @@
package cloth.bugs;
import com.igodlik3.subclaims.FactionsUtils;
import net.libhalt.bukkit.kaede.HCFactionPlugin;
import net.syuu.popura.faction.FactionType;
import net.syuu.popura.faction.bean.Faction;
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.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;
/**
* Created by Brennan on 6/18/2017.
*/
public class FenceGateBug implements Listener
{
HCFactionPlugin plugin;
public FenceGateBug(HCFactionPlugin instance){
this.plugin = instance;
}
@EventHandler
public void openDoor(PlayerInteractEvent e)
{
final Player p = e.getPlayer();
if(e.getClickedBlock() != null)
{
if(e.getAction().equals(Action.RIGHT_CLICK_BLOCK))
{
if(e.getClickedBlock().getType() == Material.FENCE_GATE)
{
if(FactionsUtils.getFactionAt(e.getClickedBlock().getLocation()) != null)
{
if(FactionsUtils.getFactionAt(e.getClickedBlock().getLocation()).getFactionType() != FactionType.WARZONE)
{
Faction pFaction = FactionsUtils.getFaction(p);
Faction lFaction = FactionsUtils.getFactionAt(e.getClickedBlock().getLocation());
if(pFaction == null)
{
if(p.getLocation().subtract(0, 1, 0).getBlock().getType() == Material.AIR || p.getLocation().subtract(0, 1, 0).getBlock().getType() == Material.FENCE_GATE)
{
return;
}
p.setVelocity(p.getLocation().getDirection().multiply(-1).setY(0));
return;
}
if(!pFaction.equals(lFaction))
{
if(p.getLocation().subtract(0, 1, 0).getBlock().getType() == Material.AIR || p.getLocation().subtract(0, 1, 0).getBlock().getType() == Material.FENCE_GATE)
{
return;
}
p.setVelocity(p.getLocation().getDirection().multiply(-1).setY(0));
return;
}
}
}
}
}
}
}
}

View File

@ -0,0 +1,55 @@
package cloth.pearls;
import net.libhalt.bukkit.kaede.HCFactionPlugin;
import net.libhalt.bukkit.kaede.manager.EnderPearlManager;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.EnderPearl;
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.ItemStack;
/**
* Created by Brennan on 6/27/2017.
*/
public class PearlInteractEvent implements Listener
{
HCFactionPlugin plugin;
public PearlInteractEvent(HCFactionPlugin instance){
this.plugin = instance;
}
@EventHandler
public void onInteract(PlayerInteractEvent e)
{
Player p = e.getPlayer();
if(p.getItemInHand() != null)
{
if(p.getItemInHand().getType() == Material.ENDER_PEARL)
{
if(e.getAction() == Action.RIGHT_CLICK_AIR)
{
if(!EnderPearlManager.isCooldownActive(e.getPlayer()))
{
e.setCancelled(true);
if(p.getItemInHand().getAmount() == 1)
{
p.setItemInHand(new ItemStack(Material.AIR));
} else {
p.getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
}
EnderPearl pearl = e.getPlayer().launchProjectile(EnderPearl.class);
return;
}
}
}
}
}
}

View File

@ -0,0 +1,41 @@
package cloth.portals;
import com.igodlik3.subclaims.FactionsUtils;
import net.libhalt.bukkit.kaede.HCFactionPlugin;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerPortalEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
/**
* Created by Brennan on 6/15/2017.
*/
public class NetherPortalEvent implements Listener
{
HCFactionPlugin plugin;
public NetherPortalEvent(HCFactionPlugin instance)
{
this.plugin = instance;
}
@EventHandler
public void onTeleport(PlayerPortalEvent e)
{
if(FactionsUtils.getFactionAt(e.getPlayer().getLocation()) != null)
{
String name = FactionsUtils.getFactionAt(e.getPlayer().getLocation()).getName();
if(name.equals("Spawn"))
{
if(e.getCause() == PlayerTeleportEvent.TeleportCause.NETHER_PORTAL){
e.setCancelled(true);
e.getPlayer().sendMessage(plugin.configdata.getConfigMessage("nether-portal-in-spawn").replaceAll("&", "§"));
return;
}
}
}
}
}

View File

@ -0,0 +1,64 @@
package cloth.xp;
import net.libhalt.bukkit.kaede.HCFactionPlugin;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
/**
* Created by Brennan on 6/16/2017.
*/
public class XpBottleCommand implements CommandExecutor
{
HCFactionPlugin plugin;
public XpBottleCommand(HCFactionPlugin instance)
{
this.plugin = instance;
}
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(!(sender instanceof Player))
{
sender.sendMessage("Only players can use this command.");
return true;
}
Player p = (Player) sender;
if(p.getLevel() < 30)
{
String message = plugin.configdata.getConfigMessage("xp-bottle-insufficient").replaceAll("&", "§");
p.sendMessage(message);
return true;
}
if(p.getInventory().firstEmpty() == -1)
{
String message = plugin.configdata.getConfigMessage("xp-bottle-inventory").replaceAll("&", "§");
p.sendMessage(message);
return true;
}
String message = plugin.configdata.getConfigMessage("xp-bottle-created").replaceAll("&", "§");
p.sendMessage(message);
p.setLevel(p.getLevel() - 30);
giveBottle(p);
return true;
}
public void giveBottle(Player p){
String bottlename = plugin.configdata.getConfigMessage("xp-bottle-name").replaceAll("&", "§");
ItemStack bottle = new ItemStack(Material.EXP_BOTTLE);
ItemMeta meta = bottle.getItemMeta();
meta.setDisplayName(bottlename);
bottle.setItemMeta(meta);
p.getInventory().addItem(bottle);
return;
}
}

View File

@ -0,0 +1,59 @@
package cloth.xp;
import net.libhalt.bukkit.kaede.HCFactionPlugin;
import org.bukkit.Material;
import org.bukkit.Sound;
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.ItemStack;
/**
* Created by Brennan on 6/16/2017.
*/
public class XpBottleEvent implements Listener
{
HCFactionPlugin plugin;
public XpBottleEvent(HCFactionPlugin instance)
{
this.plugin = instance;
}
@EventHandler
public void onInteract(PlayerInteractEvent e) {
if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK)
{
if(e.getPlayer().getItemInHand() != null)
{
if(e.getPlayer().getItemInHand().getType() == Material.EXP_BOTTLE)
{
if(e.getPlayer().getItemInHand().hasItemMeta())
{
if(e.getPlayer().getItemInHand().getItemMeta().hasDisplayName())
{
String xp_bottle_name = plugin.configdata.getConfigMessage("xp-bottle-name").replaceAll("&","§");
if(e.getPlayer().getItemInHand().getItemMeta().getDisplayName().equals(xp_bottle_name))
{
e.setCancelled(true);
if(e.getPlayer().getItemInHand().getAmount() > 1) {
e.getPlayer().getItemInHand().setAmount(e.getPlayer().getItemInHand().getAmount() - 1);
} else {
e.getPlayer().setItemInHand(new ItemStack(Material.AIR));
}
String message = plugin.configdata.getConfigMessage("xp-bottle-received").replaceAll("&", "§");
e.getPlayer().sendMessage(message);
e.getPlayer().setLevel(e.getPlayer().getLevel() + 30);
e.getPlayer().playSound(e.getPlayer().getLocation(), Sound.ORB_PICKUP, 1, 1);
return;
}
}
}
}
}
}
}
}

View File

@ -0,0 +1,30 @@
package com.confinement.filter;
import net.libhalt.bukkit.kaede.HCFactionPlugin;
import net.libhalt.bukkit.kaede.utils.Manager;
import org.bukkit.plugin.java.*;
import org.bukkit.command.*;
import com.confinement.filter.commands.*;
import org.bukkit.*;
import org.bukkit.event.*;
import org.bukkit.plugin.*;
import com.confinement.filter.listeners.*;
public class Filter extends Manager
{
public Filter(HCFactionPlugin plugin) {
super(plugin);
}
public void init() {
getPlugin().getCommand("cobble").setExecutor((CommandExecutor)new CobblestoneCommand());
getPlugin().getCommand("stone").setExecutor((CommandExecutor)new StoneCommand());
getPlugin().getCommand("mobdrops").setExecutor((CommandExecutor)new MobDropsCommand());
Bukkit.getServer().getPluginManager().registerEvents((Listener)new CobblestoneListener(), (Plugin)getPlugin());
Bukkit.getServer().getPluginManager().registerEvents((Listener)new StoneListener(), (Plugin)getPlugin());
Bukkit.getServer().getPluginManager().registerEvents((Listener)new MobDropsListener(), (Plugin)getPlugin());
}
public void onDisable() {
}
}

View File

@ -0,0 +1,30 @@
package com.confinement.filter.commands;
import java.util.*;
import org.bukkit.command.*;
import org.bukkit.entity.*;
import org.bukkit.*;
public class CobblestoneCommand implements CommandExecutor
{
public static final ArrayList<UUID> cantPickup;
static {
cantPickup = new ArrayList<UUID>();
}
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
final Player player = (Player)sender;
if (cmd.getName().equalsIgnoreCase("cobble") && sender instanceof Player) {
if (args.length == 0 && !CobblestoneCommand.cantPickup.contains(player.getUniqueId())) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7You are now &cunable &7to pickup cobblestone."));
CobblestoneCommand.cantPickup.add(player.getUniqueId());
}
else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7You are now &aable &7to pickup cobblestone."));
CobblestoneCommand.cantPickup.remove(player.getUniqueId());
}
}
return true;
}
}

View File

@ -0,0 +1,30 @@
package com.confinement.filter.commands;
import java.util.*;
import org.bukkit.command.*;
import org.bukkit.entity.*;
import org.bukkit.*;
public class MobDropsCommand implements CommandExecutor
{
public static final ArrayList<String> cantPickupMobs;
static {
cantPickupMobs = new ArrayList<String>();
}
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
final Player player = (Player)sender;
if (cmd.getName().equalsIgnoreCase("mobdrops") && sender instanceof Player) {
if (args.length == 0 && !MobDropsCommand.cantPickupMobs.contains(player.getUniqueId().toString())) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7You are now &cunable &7to pickup mob drops."));
MobDropsCommand.cantPickupMobs.add(player.getUniqueId().toString());
}
else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7You are now &aable &7to pickup mob drops."));
MobDropsCommand.cantPickupMobs.remove(player.getUniqueId().toString());
}
}
return true;
}
}

View File

@ -0,0 +1,30 @@
package com.confinement.filter.commands;
import java.util.*;
import org.bukkit.command.*;
import org.bukkit.entity.*;
import org.bukkit.*;
public class StoneCommand implements CommandExecutor
{
public static final ArrayList<UUID> cantPickupStone;
static {
cantPickupStone = new ArrayList<UUID>();
}
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
final Player player = (Player)sender;
if (cmd.getName().equalsIgnoreCase("stone") && sender instanceof Player) {
if (args.length == 0 && !StoneCommand.cantPickupStone.contains(player.getUniqueId())) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7You are now &cunable &7to pickup stone!!"));
StoneCommand.cantPickupStone.add(player.getUniqueId());
}
else {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&7You are now &aable &7to pickup stone."));
StoneCommand.cantPickupStone.remove(player.getUniqueId());
}
}
return true;
}
}

View File

@ -0,0 +1,27 @@
package com.confinement.filter.listeners;
import org.bukkit.*;
import com.confinement.filter.commands.*;
import org.bukkit.entity.*;
import org.bukkit.inventory.*;
import org.bukkit.event.*;
import org.bukkit.event.player.*;
public class CobblestoneListener implements Listener
{
@EventHandler
public void onPlayerPickup(final PlayerPickupItemEvent event) {
final Player player = event.getPlayer();
final ItemStack item = event.getItem().getItemStack();
final Material itemType = item.getType();
if (itemType == Material.COBBLESTONE && CobblestoneCommand.cantPickup.contains(player.getUniqueId())) {
event.setCancelled(true);
}
}
@EventHandler
public void onLeave(final PlayerQuitEvent event) {
final Player player = event.getPlayer();
CobblestoneCommand.cantPickup.remove(player.getUniqueId());
}
}

View File

@ -0,0 +1,35 @@
package com.confinement.filter.listeners;
import org.bukkit.*;
import com.confinement.filter.commands.*;
import org.bukkit.entity.*;
import org.bukkit.inventory.*;
import org.bukkit.event.*;
import org.bukkit.event.player.*;
public class MobDropsListener implements Listener
{
@EventHandler
public void onPlayerPickup(final PlayerPickupItemEvent event) {
final Player player = event.getPlayer();
final ItemStack item = event.getItem().getItemStack();
final Material itemType = item.getType();
if ((itemType == Material.BONE || itemType == Material.ROTTEN_FLESH || itemType == Material.BOW ||
itemType == Material.SPIDER_EYE || itemType == Material.STRING || itemType == Material.ARROW ||
itemType == Material.POTATO
/*||itemType == Material.IRON_HELMET || itemType == Material.IRON_HELMET ||
itemType == Material.IRON_CHESTPLATE || itemType == Material.IRON_LEGGINGS || itemType == Material.IRON_BOOTS
|| itemType == Material.GOLD_HELMET || itemType == Material.GOLD_CHESTPLATE || itemType == Material.GOLD_LEGGINGS ||
itemType == Material.GOLD_BOOTS || itemType == Material.CHAINMAIL_HELMET || itemType == Material.CHAINMAIL_CHESTPLATE ||
itemType == Material.CHAINMAIL_LEGGINGS || itemType == Material.CHAINMAIL_BOOTS || itemType == Material.LEATHER_HELMET ||
itemType == Material.LEATHER_CHESTPLATE || itemType == Material.LEATHER_LEGGINGS || itemType == Material.LEATHER_BOOTS */) && MobDropsCommand.cantPickupMobs.contains(player.getUniqueId().toString())) {
event.setCancelled(true);
}
}
@EventHandler
public void onLeave(final PlayerQuitEvent event) {
final Player player = event.getPlayer();
MobDropsCommand.cantPickupMobs.remove(player.getUniqueId().toString());
}
}

View File

@ -0,0 +1,27 @@
package com.confinement.filter.listeners;
import org.bukkit.*;
import com.confinement.filter.commands.*;
import org.bukkit.entity.*;
import org.bukkit.inventory.*;
import org.bukkit.event.*;
import org.bukkit.event.player.*;
public class StoneListener implements Listener
{
@EventHandler
public void onPlayerPickup(final PlayerPickupItemEvent event) {
final Player player = event.getPlayer();
final ItemStack item = event.getItem().getItemStack();
final Material itemType = item.getType();
if (itemType == Material.STONE && StoneCommand.cantPickupStone.contains(player.getUniqueId())) {
event.setCancelled(true);
}
}
@EventHandler
public void onLeave(final PlayerQuitEvent event) {
final Player player = event.getPlayer();
StoneCommand.cantPickupStone.remove(player.getUniqueId());
}
}

View File

@ -0,0 +1,677 @@
package com.igodlik3;
import org.bukkit.inventory.*;
import org.bukkit.material.*;
import org.bukkit.enchantments.*;
import java.util.*;
import org.apache.commons.lang.*;
import org.bukkit.configuration.file.*;
import org.bukkit.inventory.meta.*;
import net.minecraft.util.com.google.gson.*;
import org.bukkit.*;
import java.lang.reflect.*;
public class ItemBuilder
{
private ItemStack item;
private ItemMeta meta;
private Material material;
private int amount;
private MaterialData data;
private short damage;
private Map<Enchantment, Integer> enchantments;
private String displayname;
private List<String> lore;
private boolean andSymbol;
private boolean unsafeStackSize;
public ItemBuilder(Material material) {
this.material = Material.STONE;
this.amount = 1;
this.damage = 0;
this.enchantments = new HashMap<Enchantment, Integer>();
this.lore = new ArrayList<String>();
this.andSymbol = true;
this.unsafeStackSize = false;
if (material == null) {
material = Material.AIR;
}
this.item = new ItemStack(material);
this.material = material;
}
public ItemBuilder(Material material, int amount) {
this.material = Material.STONE;
this.amount = 1;
this.damage = 0;
this.enchantments = new HashMap<Enchantment, Integer>();
this.lore = new ArrayList<String>();
this.andSymbol = true;
this.unsafeStackSize = false;
if (material == null) {
material = Material.AIR;
}
if ((amount > material.getMaxStackSize() || amount <= 0) && !this.unsafeStackSize) {
amount = 1;
}
this.amount = amount;
this.item = new ItemStack(material, amount);
this.material = material;
}
public ItemBuilder(Material material, int amount, final String displayname) {
this.material = Material.STONE;
this.amount = 1;
this.damage = 0;
this.enchantments = new HashMap<Enchantment, Integer>();
this.lore = new ArrayList<String>();
this.andSymbol = true;
this.unsafeStackSize = false;
if (material == null) {
material = Material.AIR;
}
Validate.notNull((Object)displayname, "The Displayname is null.");
this.item = new ItemStack(material, amount);
this.material = material;
if ((amount > material.getMaxStackSize() || amount <= 0) && !this.unsafeStackSize) {
amount = 1;
}
this.amount = amount;
this.displayname = displayname;
}
public ItemBuilder(Material material, final String displayname) {
this.material = Material.STONE;
this.amount = 1;
this.damage = 0;
this.enchantments = new HashMap<Enchantment, Integer>();
this.lore = new ArrayList<String>();
this.andSymbol = true;
this.unsafeStackSize = false;
if (material == null) {
material = Material.AIR;
}
Validate.notNull((Object)displayname, "The Displayname is null.");
this.item = new ItemStack(material);
this.material = material;
this.displayname = displayname;
}
public ItemBuilder(final ItemStack item) {
this.material = Material.STONE;
this.amount = 1;
this.damage = 0;
this.enchantments = new HashMap<Enchantment, Integer>();
this.lore = new ArrayList<String>();
this.andSymbol = true;
this.unsafeStackSize = false;
Validate.notNull((Object)item, "The Item is null.");
this.item = item;
if (item.hasItemMeta()) {
this.meta = item.getItemMeta();
}
this.material = item.getType();
this.amount = item.getAmount();
this.data = item.getData();
this.damage = item.getDurability();
this.enchantments = (Map<Enchantment, Integer>)item.getEnchantments();
if (item.hasItemMeta()) {
this.displayname = item.getItemMeta().getDisplayName();
}
if (item.hasItemMeta()) {
this.lore = (List<String>)item.getItemMeta().getLore();
}
}
public ItemBuilder(final FileConfiguration cfg, final String path) {
this(cfg.getItemStack(path));
}
public ItemBuilder(final ItemBuilder builder) {
this.material = Material.STONE;
this.amount = 1;
this.damage = 0;
this.enchantments = new HashMap<Enchantment, Integer>();
this.lore = new ArrayList<String>();
this.andSymbol = true;
this.unsafeStackSize = false;
Validate.notNull((Object)builder, "The ItemBuilder is null.");
this.item = builder.item;
this.meta = builder.meta;
this.material = builder.material;
this.amount = builder.amount;
this.damage = builder.damage;
this.data = builder.data;
this.damage = builder.damage;
this.enchantments = builder.enchantments;
this.displayname = builder.displayname;
this.lore = builder.lore;
}
public ItemBuilder amount(int amount) {
if ((amount > this.material.getMaxStackSize() || amount <= 0) && !this.unsafeStackSize) {
amount = 1;
}
this.amount = amount;
return this;
}
public ItemBuilder data(final MaterialData data) {
Validate.notNull((Object)data, "The Data is null.");
this.data = data;
return this;
}
@Deprecated
public ItemBuilder damage(final short damage) {
this.damage = damage;
return this;
}
public ItemBuilder durability(final short damage) {
this.damage = damage;
return this;
}
public ItemBuilder material(final Material material) {
Validate.notNull((Object)material, "The Material is null.");
this.material = material;
return this;
}
public ItemBuilder meta(final ItemMeta meta) {
Validate.notNull((Object)meta, "The Meta is null.");
this.meta = meta;
return this;
}
public ItemBuilder enchant(final Enchantment enchant, final int level) {
Validate.notNull((Object)enchant, "The Enchantment is null.");
this.enchantments.put(enchant, level);
return this;
}
public ItemBuilder enchant(final Map<Enchantment, Integer> enchantments) {
Validate.notNull((Object)enchantments, "The Enchantments are null.");
this.enchantments = enchantments;
return this;
}
public ItemBuilder displayname(final String displayname) {
Validate.notNull((Object)displayname, "The Displayname is null.");
this.displayname = (this.andSymbol ? ChatColor.translateAlternateColorCodes('&', displayname) : displayname);
return this;
}
public ItemBuilder lore(final String line) {
Validate.notNull((Object)line, "The Line is null.");
this.lore.add(this.andSymbol ? ChatColor.translateAlternateColorCodes('&', line) : line);
return this;
}
public ItemBuilder lore(final List<String> lore) {
Validate.notNull((Object)lore, "The Lores are null.");
this.lore = lore;
return this;
}
@Deprecated
public ItemBuilder lores(final String... lines) {
Validate.notNull((Object)lines, "The Lines are null.");
for (final String line : lines) {
this.lore(this.andSymbol ? ChatColor.translateAlternateColorCodes('&', line) : line);
}
return this;
}
public ItemBuilder lore(final String... lines) {
Validate.notNull((Object)lines, "The Lines are null.");
for (final String line : lines) {
this.lore(this.andSymbol ? ChatColor.translateAlternateColorCodes('&', line) : line);
}
return this;
}
public ItemBuilder lore(final String line, final int index) {
Validate.notNull((Object)line, "The Line is null.");
this.lore.set(index, this.andSymbol ? ChatColor.translateAlternateColorCodes('&', line) : line);
return this;
}
public ItemBuilder unbreakable(final boolean unbreakable) {
this.meta.spigot().setUnbreakable(unbreakable);
return this;
}
@Deprecated
public ItemBuilder owner(final String user) {
Validate.notNull((Object)user, "The Username is null.");
if (this.material == Material.SKULL_ITEM || this.material == Material.SKULL) {
final SkullMeta smeta = (SkullMeta)this.meta;
smeta.setOwner(user);
this.meta = (ItemMeta)smeta;
}
return this;
}
public Unsafe unsafe() {
return new Unsafe(this);
}
@Deprecated
public ItemBuilder replaceAndSymbol() {
this.replaceAndSymbol(!this.andSymbol);
return this;
}
public ItemBuilder replaceAndSymbol(final boolean replace) {
this.andSymbol = replace;
return this;
}
public ItemBuilder toggleReplaceAndSymbol() {
this.replaceAndSymbol(!this.andSymbol);
return this;
}
public ItemBuilder unsafeStackSize(final boolean allow) {
this.unsafeStackSize = allow;
return this;
}
public ItemBuilder toggleUnsafeStackSize() {
this.unsafeStackSize(!this.unsafeStackSize);
return this;
}
public String getDisplayname() {
return this.displayname;
}
public int getAmount() {
return this.amount;
}
public Map<Enchantment, Integer> getEnchantments() {
return this.enchantments;
}
@Deprecated
public short getDamage() {
return this.damage;
}
public short getDurability() {
return this.damage;
}
public List<String> getLores() {
return this.lore;
}
public boolean getAndSymbol() {
return this.andSymbol;
}
public Material getMaterial() {
return this.material;
}
public ItemMeta getMeta() {
return this.meta;
}
public MaterialData getData() {
return this.data;
}
@Deprecated
public List<String> getLore() {
return this.lore;
}
public ItemBuilder toConfig(final FileConfiguration cfg, final String path) {
cfg.set(path, (Object)this.build());
return this;
}
public ItemBuilder fromConfig(final FileConfiguration cfg, final String path) {
return new ItemBuilder(cfg, path);
}
public static void toConfig(final FileConfiguration cfg, final String path, final ItemBuilder builder) {
cfg.set(path, (Object)builder.build());
}
public String toJson() {
return new Gson().toJson((Object)this);
}
public static String toJson(final ItemBuilder builder) {
return new Gson().toJson((Object)builder);
}
public static ItemBuilder fromJson(final String json) {
return (ItemBuilder)new Gson().fromJson(json, (Class)ItemBuilder.class);
}
public ItemBuilder applyJson(final String json, final boolean overwrite) {
final ItemBuilder b = (ItemBuilder)new Gson().fromJson(json, (Class)ItemBuilder.class);
if (overwrite) {
return b;
}
if (b.displayname != null) {
this.displayname = b.displayname;
}
if (b.data != null) {
this.data = b.data;
}
if (b.material != null) {
this.material = b.material;
}
if (b.lore != null) {
this.lore = b.lore;
}
if (b.enchantments != null) {
this.enchantments = b.enchantments;
}
if (b.item != null) {
this.item = b.item;
}
this.damage = b.damage;
this.amount = b.amount;
return this;
}
public ItemStack build() {
this.item.setType(this.material);
this.item.setAmount(this.amount);
this.item.setDurability(this.damage);
this.meta = this.item.getItemMeta();
if (this.data != null) {
this.item.setData(this.data);
}
if (this.enchantments.size() > 0) {
this.item.addUnsafeEnchantments((Map)this.enchantments);
}
if (this.displayname != null) {
this.meta.setDisplayName(this.displayname);
}
if (this.lore.size() > 0) {
this.meta.setLore((List)this.lore);
}
this.item.setItemMeta(this.meta);
return this.item;
}
static /* synthetic */ void access$1(final ItemBuilder itemBuilder, final ItemStack item) {
itemBuilder.item = item;
}
public class Unsafe
{
protected final ReflectionUtils utils;
protected final ItemBuilder builder;
public Unsafe(final ItemBuilder builder) {
this.utils = new ReflectionUtils();
this.builder = builder;
}
public Unsafe setString(final String key, final String value) {
ItemBuilder.access$1(this.builder, this.utils.setString(this.builder.item, key, value));
return this;
}
public String getString(final String key) {
return this.utils.getString(this.builder.item, key);
}
public Unsafe setInt(final String key, final int value) {
ItemBuilder.access$1(this.builder, this.utils.setInt(this.builder.item, key, value));
return this;
}
public int getInt(final String key) {
return this.utils.getInt(this.builder.item, key);
}
public Unsafe setDouble(final String key, final double value) {
ItemBuilder.access$1(this.builder, this.utils.setDouble(this.builder.item, key, value));
return this;
}
public double getDouble(final String key) {
return this.utils.getDouble(this.builder.item, key);
}
public Unsafe setBoolean(final String key, final boolean value) {
ItemBuilder.access$1(this.builder, this.utils.setBoolean(this.builder.item, key, value));
return this;
}
public boolean getBoolean(final String key) {
return this.utils.getBoolean(this.builder.item, key);
}
public boolean containsKey(final String key) {
return this.utils.hasKey(this.builder.item, key);
}
public ItemBuilder builder() {
return this.builder;
}
public class ReflectionUtils
{
public String getString(final ItemStack item, final String key) {
Object compound = this.getNBTTagCompound(this.getItemAsNMSStack(item));
if (compound == null) {
compound = this.getNewNBTTagCompound();
}
try {
return (String)compound.getClass().getMethod("getString", String.class).invoke(compound, key);
}
catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
ex.printStackTrace();
return null;
}
}
public ItemStack setString(final ItemStack item, final String key, final String value) {
Object nmsItem = this.getItemAsNMSStack(item);
Object compound = this.getNBTTagCompound(nmsItem);
if (compound == null) {
compound = this.getNewNBTTagCompound();
}
try {
compound.getClass().getMethod("setString", String.class, String.class).invoke(compound, key, value);
nmsItem = this.setNBTTag(compound, nmsItem);
}
catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
ex.printStackTrace();
}
return this.getItemAsBukkitStack(nmsItem);
}
public int getInt(final ItemStack item, final String key) {
Object compound = this.getNBTTagCompound(this.getItemAsNMSStack(item));
if (compound == null) {
compound = this.getNewNBTTagCompound();
}
try {
return (int)compound.getClass().getMethod("getInt", String.class).invoke(compound, key);
}
catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
ex.printStackTrace();
return -1;
}
}
public ItemStack setInt(final ItemStack item, final String key, final int value) {
Object nmsItem = this.getItemAsNMSStack(item);
Object compound = this.getNBTTagCompound(nmsItem);
if (compound == null) {
compound = this.getNewNBTTagCompound();
}
try {
compound.getClass().getMethod("setInt", String.class, Integer.class).invoke(compound, key, value);
nmsItem = this.setNBTTag(compound, nmsItem);
}
catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
ex.printStackTrace();
}
return this.getItemAsBukkitStack(nmsItem);
}
public double getDouble(final ItemStack item, final String key) {
Object compound = this.getNBTTagCompound(this.getItemAsNMSStack(item));
if (compound == null) {
compound = this.getNewNBTTagCompound();
}
try {
return (double)compound.getClass().getMethod("getDouble", String.class).invoke(compound, key);
}
catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
ex.printStackTrace();
return Double.NaN;
}
}
public ItemStack setDouble(final ItemStack item, final String key, final double value) {
Object nmsItem = this.getItemAsNMSStack(item);
Object compound = this.getNBTTagCompound(nmsItem);
if (compound == null) {
compound = this.getNewNBTTagCompound();
}
try {
compound.getClass().getMethod("setDouble", String.class, Double.class).invoke(compound, key, value);
nmsItem = this.setNBTTag(compound, nmsItem);
}
catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
ex.printStackTrace();
}
return this.getItemAsBukkitStack(nmsItem);
}
public boolean getBoolean(final ItemStack item, final String key) {
Object compound = this.getNBTTagCompound(this.getItemAsNMSStack(item));
if (compound == null) {
compound = this.getNewNBTTagCompound();
}
try {
return (boolean)compound.getClass().getMethod("getBoolean", String.class).invoke(compound, key);
}
catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
ex.printStackTrace();
return false;
}
}
public ItemStack setBoolean(final ItemStack item, final String key, final boolean value) {
Object nmsItem = this.getItemAsNMSStack(item);
Object compound = this.getNBTTagCompound(nmsItem);
if (compound == null) {
compound = this.getNewNBTTagCompound();
}
try {
compound.getClass().getMethod("setBoolean", String.class, Boolean.class).invoke(compound, key, value);
nmsItem = this.setNBTTag(compound, nmsItem);
}
catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
ex.printStackTrace();
}
return this.getItemAsBukkitStack(nmsItem);
}
public boolean hasKey(final ItemStack item, final String key) {
Object compound = this.getNBTTagCompound(this.getItemAsNMSStack(item));
if (compound == null) {
compound = this.getNewNBTTagCompound();
}
try {
return (boolean)compound.getClass().getMethod("hasKey", String.class).invoke(compound, key);
}
catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
e.printStackTrace();
return false;
}
}
public Object getNewNBTTagCompound() {
final String ver = Bukkit.getServer().getClass().getPackage().getName().split(".")[3];
try {
return Class.forName("net.minecraft.server." + ver + ".NBTTagCompound").newInstance();
}
catch (ClassNotFoundException | IllegalAccessException | InstantiationException ex) {
ex.printStackTrace();
return null;
}
}
public Object setNBTTag(final Object tag, final Object item) {
try {
item.getClass().getMethod("setTag", item.getClass()).invoke(item, tag);
return item;
}
catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
ex.printStackTrace();
return null;
}
}
public Object getNBTTagCompound(final Object nmsStack) {
try {
return nmsStack.getClass().getMethod("getTag", (Class<?>[])new Class[0]).invoke(nmsStack, new Object[0]);
}
catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
ex.printStackTrace();
return null;
}
}
public Object getItemAsNMSStack(final ItemStack item) {
try {
final Method m = this.getCraftItemStackClass().getMethod("asNMSCopy", ItemStack.class);
return m.invoke(this.getCraftItemStackClass(), item);
}
catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ex) {
ex.printStackTrace();
return null;
}
}
public ItemStack getItemAsBukkitStack(final Object nmsStack) {
try {
final Method m = this.getCraftItemStackClass().getMethod("asCraftMirror", nmsStack.getClass());
return (ItemStack)m.invoke(this.getCraftItemStackClass(), nmsStack);
}
catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
ex.printStackTrace();
return null;
}
}
public Class<?> getCraftItemStackClass() {
final String ver = Bukkit.getServer().getClass().getPackage().getName().split(".")[3];
try {
return Class.forName("org.bukkit.craftbukkit." + ver + ".inventory.CraftItemStack");
}
catch (ClassNotFoundException ex) {
ex.printStackTrace();
return null;
}
}
}
}
}

View File

@ -0,0 +1,97 @@
package com.igodlik3.conquest;
import net.libhalt.bukkit.kaede.HCFactionPlugin;
import net.libhalt.bukkit.kaede.utils.ConfigurationWrapper;
import net.libhalt.bukkit.kaede.utils.Manager;
import org.bukkit.configuration.Configuration;
import com.igodlik3.conquest.utils.*;
import com.igodlik3.conquest.event.*;
import org.bukkit.*;
import org.bukkit.event.*;
import com.igodlik3.conquest.loot.*;
import com.igodlik3.conquest.listener.*;
import org.bukkit.plugin.*;
import com.igodlik3.conquest.commands.*;
import org.bukkit.command.*;
import com.igodlik3.conquest.task.*;
public class Conquest extends Manager
{
private static Conquest instance;
private ConquestManager conquestManager;
private LootManager lootManager;
private ConfigurationWrapper config;
public Configuration getConfig(){
return config.getConfig();
}
private Config storage;
public Conquest(HCFactionPlugin plugin) {
super(plugin);
}
@Override
public void init() {
this.setUpConfig();
(Conquest.instance = this).registerManagers();
this.registerListeners();
this.registerCommands();
}
@Override
public void tear() {
if (this.conquestManager.getRunningGame() != null) {
this.conquestManager.setRunningGame(null);
}
}
private void registerListeners() {
final PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents((Listener)new ScoreboardListener(), this.getPlugin());
pm.registerEvents((Listener)new SelectionListener(), this.getPlugin());
pm.registerEvents((Listener)new ChestListener(), this.getPlugin());
pm.registerEvents((Listener)new PlayerListener(), this.getPlugin());
}
private void registerCommands() {
registerCommand("conquest" , (CommandExecutor)new CmdConquest());
}
private void registerManagers() {
this.conquestManager = new ConquestManager();
this.lootManager = new LootManager();
new ConquestTask().runTaskTimer(getPlugin(), 20L, 20L);
}
private void setUpConfig() {
config = new ConfigurationWrapper("conquest.yml", this.getPlugin());
config.saveDefault();
final Config config = new Config("plugins/" + getPlugin().getName() + "/storage", "conqueset-storage.yml", getPlugin());
config.create();
if (!config.exists() || config.toFile().exists()) {
config.saveConfig();
}
this.storage = config;
}
public static Conquest getInstance() {
return Conquest.instance;
}
public ConquestManager getConquestManager() {
return this.conquestManager;
}
public LootManager getLootManager() {
return this.lootManager;
}
public Config getStorage() {
return this.storage;
}
}

View File

@ -0,0 +1,269 @@
package com.igodlik3.conquest.commands;
import org.bukkit.configuration.*;
import com.igodlik3.conquest.loot.*;
import com.igodlik3.conquest.*;
import org.bukkit.command.*;
import org.bukkit.entity.*;
import com.igodlik3.conquest.utils.*;
import com.igodlik3.conquest.listener.*;
import com.igodlik3.conquest.event.*;
import org.bukkit.*;
import java.util.*;
import org.bukkit.block.*;
public class CmdConquest implements CommandExecutor
{
private Configuration config;
private ConquestManager cm;
private LootManager lm;
private ChestLootManager chest;
private ChestKey key;
public CmdConquest() {
this.config = (Configuration)Conquest.getInstance().getConfig();
this.cm = Conquest.getInstance().getConquestManager();
this.lm = Conquest.getInstance().getLootManager();
this.chest = new ChestLootManager();
this.key = new ChestKey();
}
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
if (!(sender instanceof Player)) {
return true;
}
final Player player = (Player)sender;
if (args.length == 0) {
this.sendUsage(player);
}
else if (args[0].equalsIgnoreCase("create")) {
if (!this.hasPermission(player)) {
return true;
}
if (args.length < 2) {
this.sendUsage(player);
}
else {
final String name = args[1];
if (this.cm.gameExists(name)) {
player.sendMessage(Utils.color(this.config.getString("Messages.ALREADY-EXIST")));
return true;
}
this.cm.saveOrUpdateGame(new ConquestGame(name));
player.sendMessage(Utils.color(this.config.getString("Messages.CREATED").replaceAll("%NAME%", name)));
}
}
else if (args[0].equalsIgnoreCase("delete")) {
if (!this.hasPermission(player)) {
return true;
}
if (args.length < 2) {
this.sendUsage(player);
}
else {
final String name = args[1];
final ConquestGame game = this.cm.getGame(name);
if (game == null) {
player.sendMessage(Utils.color(this.config.getString("Messages.DOESNT-EXIST")));
}
else if (this.cm.getRunningGame() != null && game.getName().equals(this.cm.getRunningGame().getName())) {
player.sendMessage(Utils.color(this.config.getString("Messages.CONQUEST-RUNNING")));
}
else {
this.cm.deleteGame(game);
player.sendMessage(Utils.color(this.config.getString("Messages.DELETED").replaceAll("%NAME%", name)));
}
}
}
else if (args[0].equalsIgnoreCase("start")) {
if (!this.hasPermission(player)) {
return true;
}
if (args.length < 2) {
this.sendUsage(player);
}
else {
if (this.cm.getRunningGame() != null) {
player.sendMessage(Utils.color(this.config.getString("Messages.CONQUEST-RUNNING")));
return true;
}
final ConquestGame game2 = this.cm.getGame(args[1]);
if (game2 == null) {
player.sendMessage(Utils.color(this.config.getString("Messages.DOESNT-EXIST")));
return true;
}
if (!game2.isComplete()) {
player.sendMessage(Utils.color(this.config.getString("Messages.INCOMPLET-CONQUEST")));
return true;
}
this.cm.startConquest(game2);
this.cm.setRunningGame(game2);
}
}
else if (args[0].equalsIgnoreCase("stop")) {
if (!this.hasPermission(player)) {
return true;
}
final ConquestGame game2 = this.cm.getRunningGame();
if (game2 == null) {
player.sendMessage(Utils.color(this.config.getString("Messages.NONE-RUNNING-CONQUEST")));
return true;
}
this.cm.setRunningGame(null);
this.cm.resetRunningGameData();
Bukkit.broadcastMessage(Utils.color(this.config.getString("Messages.CONQUEST-STOPPED").replaceAll("%NAME%", game2.getName())));
}
else if (args[0].equalsIgnoreCase("area")) {
if (!this.hasPermission(player)) {
return true;
}
if (args.length < 3) {
this.sendUsage(player);
}
else {
final ConquestGame game2 = this.cm.getGame(args[1]);
if (game2 == null) {
player.sendMessage(Utils.color(this.config.getString("Messages.DOESNT-EXIST")));
return true;
}
if (this.cm.getRunningGame() != null && game2.getName().equals(this.cm.getRunningGame().getName())) {
player.sendMessage(Utils.color(this.config.getString("Messages.CONQUEST-RUNNING")));
return true;
}
if (!SelectionListener.isCorrectSelection(player)) {
player.sendMessage(Utils.color(this.config.getString("Messages.NO-SELECTION")));
return true;
}
ConquestArea.Type type;
try {
type = ConquestArea.Type.valueOf(args[2].toUpperCase());
}
catch (IllegalArgumentException e) {
player.sendMessage(Utils.color(this.config.getString("Messages.INVALID-AREA")));
return true;
}
final Location loc1 = SelectionListener.getSelection(player).get(0);
final Location loc2 = SelectionListener.getSelection(player).get(1);
final boolean wasComplete = game2.isComplete();
game2.setArea(type, new ConquestArea(game2, type, loc1, loc2));
this.cm.saveOrUpdateGame(game2);
player.sendMessage(Utils.color(this.config.getString("Messages.AREA-UPTADED")));
if (!wasComplete && game2.isComplete()) {
player.sendMessage(Utils.color(this.config.getString("Messages.CONQUEST-READY").replaceAll("%NAME%", args[1])));
}
}
}
else if (args[0].equalsIgnoreCase("list")) {
if (!this.hasPermission(player)) {
return true;
}
final Set<String> games = this.cm.listGames();
if (games == null || games.isEmpty()) {
player.sendMessage(Utils.color(this.config.getString("Messages.NONE-CONQUEST")));
}
else {
for (final String game3 : games) {
player.sendMessage(Utils.color("&c- &e" + game3));
}
}
}
else if (args[0].equalsIgnoreCase("tp")) {
if (!this.hasPermission(player)) {
return true;
}
if (args.length < 2) {
this.sendUsage(player);
}
else {
final String name = args[1];
final ConquestGame game = this.cm.getGame(name);
if (game == null) {
player.sendMessage(Utils.color(this.config.getString("Messages.DOESNT-EXIST")));
return true;
}
final Location loc3 = this.cm.getConquestCubo(game.getArea(ConquestArea.Type.RED)).getCenter();
player.teleport(loc3);
player.sendMessage(Utils.color(this.config.getString("Messages.TELEPORTATION")));
}
}
else if (args[0].equalsIgnoreCase("editloot")) {
if (!this.hasPermission(player)) {
return true;
}
this.lm.openLoot(player, true);
}
else if (args[0].equalsIgnoreCase("wand")) {
if (!this.hasPermission(player)) {
return true;
}
SelectionListener.getWand(player);
}
else if (args[0].equalsIgnoreCase("loot")) {
this.lm.openLoot(player, false);
}
else if (args[0].equalsIgnoreCase("chest")) {
if (!this.hasPermission(player)) {
return true;
}
if (args.length < 2) {
this.sendUsage(player);
}
else if (args[1].equalsIgnoreCase("create")) {
final Block block = player.getTargetBlock((HashSet)null, 10);
if ((block != null && block.getType() == Material.CHEST) || block.getType() == Material.ENDER_CHEST || block.getType() == Material.TRAPPED_CHEST) {
if (this.chest.isChestLoot(block.getLocation())) {
player.sendMessage(Utils.color(this.config.getString("Messages.ALREADY-CHESTLOOT")));
}
else {
player.sendMessage(Utils.color(this.config.getString("Messages.CHEST-LOOT-CREATED")));
this.chest.addLocation(block.getLocation());
}
}
else {
player.sendMessage(Utils.color(this.config.getString("Messages.NOT-A-CHEST")));
}
}
else if (args[1].equalsIgnoreCase("delete")) {
final Block block = player.getTargetBlock((HashSet)null, 10);
if ((block != null && block.getType() == Material.CHEST) || block.getType() == Material.ENDER_CHEST || block.getType() == Material.TRAPPED_CHEST) {
if (this.chest.isChestLoot(block.getLocation())) {
player.sendMessage(Utils.color(this.config.getString("Messages.CHEST-LOOT-REMOVED")));
this.chest.removeLocation(block.getLocation());
}
else {
player.sendMessage(Utils.color(this.config.getString("Messages.NOT-A-CHESTLOOT")));
}
}
else {
player.sendMessage(Utils.color(this.config.getString("Messages.NOT-A-CHEST")));
}
}
else if (args[1].equalsIgnoreCase("key")) {
this.key.giveKey(player);
player.sendMessage(Utils.color("&aKey received !"));
}
}
return true;
}
private void sendUsage(final Player player) {
if (this.hasPermission(player)) {
for (final String stg : this.config.getStringList("Messages.USAGE.STAFF")) {
player.sendMessage(Utils.color(stg));
}
}
else {
for (final String stg : this.config.getStringList("Messages.USAGE.PLAYER")) {
player.sendMessage(Utils.color(stg));
}
}
}
private boolean hasPermission(final Player player) {
if (player.hasPermission("Conquest.Admin")) {
return true;
}
player.sendMessage(Utils.color(this.config.getString("Messages.NO-PERM")));
return false;
}
}

View File

@ -0,0 +1,45 @@
package com.igodlik3.conquest.event;
import org.bukkit.*;
public class ConquestArea
{
private ConquestGame game;
private Type type;
private Location loc1;
private Location loc2;
public ConquestArea(final ConquestGame game, final Type type, final Location loc1, final Location loc2) {
this.game = game;
this.type = type;
this.loc1 = loc1;
this.loc2 = loc2;
}
public ConquestGame getGame() {
return this.game;
}
public Type getType() {
return this.type;
}
public Location getLoc1() {
return this.loc1;
}
public Location getLoc2() {
return this.loc2;
}
public enum Type
{
RED("RED", 0),
GREEN("GREEN", 1),
BLUE("BLUE", 2),
YELLOW("YELLOW", 3);
private Type(final String s, final int n) {
}
}
}

View File

@ -0,0 +1,93 @@
package com.igodlik3.conquest.event;
import net.syuu.popura.PopuraPlugin;
import net.syuu.popura.faction.bean.Faction;
import net.syuu.popura.faction.bean.FactionPlayer;
import org.bukkit.entity.*;
import java.util.*;
import com.igodlik3.conquest.*;
public class ConquestData
{
private Map<String, Integer> factionsPoints;
private Map<ConquestArea.Type, Integer> capTime;
private Set<Faction> containedFactions;
private Map<ConquestArea.Type, Player> firstCapper;
public ConquestData() {
this.factionsPoints = new HashMap<String, Integer>();
this.capTime = new HashMap<ConquestArea.Type, Integer>();
this.containedFactions = new HashSet<Faction>();
this.firstCapper = new HashMap<ConquestArea.Type, Player>();
}
public Map<String, Integer> getFactionsPoints() {
return this.factionsPoints;
}
public int getFactionPoints(final Player player) {
final FactionPlayer factionPlayer = PopuraPlugin.getInstance().getPopura().getFactionDataManager().getPlayer(player);
return factionPlayer.getFaction() != null ? this.getFactionPoints(factionPlayer.getFaction()) : -1;
}
public int getFactionPoints(final Faction faction) {
return this.factionsPoints.containsKey(faction.getName()) ? this.factionsPoints.get(faction.getName()) : -1;
}
public void setFactionsPoints(final Faction faction, final int points, final boolean contained) {
if (contained) {
this.containedFactions.add(faction);
}
this.factionsPoints.put(faction.getName(), points);
}
public void setFactionsPoints(final Player player, final int points) {
final FactionPlayer factionPlayer = PopuraPlugin.getInstance().getPopura().getFactionDataManager().getPlayer(player);
if (factionPlayer.getFaction() != null) {
this.setFactionsPoints(factionPlayer.getFaction(), points, true);
}
}
public boolean capPoint(final Faction faction, final ConquestArea.Type type) {
this.containedFactions.add(faction);
if (!this.capTime.containsKey(type)) {
this.capTime.put(type, 0);
return false;
}
final int time = this.capTime.get(type) + 1;
this.capTime.put(type, time);
final boolean capped = time >= Conquest.getInstance().getConfig().getInt("CONQUEST.Cap-Time");
if (capped) {
this.capTime.put(type, 0);
}
return capped;
}
public int getCapTime(final ConquestArea.Type type) {
final Integer time = this.capTime.get(type);
return (time == null) ? 0 : time;
}
public void resetTime(final ConquestArea.Type type) {
this.capTime.put(type, 0);
}
public Set<Faction> getContainedFactions() {
return this.containedFactions;
}
public Player getFirstCapper(final ConquestArea.Type type) {
return this.firstCapper.get(type);
}
public void setFirstCapper(final ConquestArea.Type type, final Player capper) {
if (capper == null) {
this.firstCapper.remove(type);
}
else {
this.firstCapper.put(type, capper);
}
}
}

View File

@ -0,0 +1,39 @@
package com.igodlik3.conquest.event;
public class ConquestGame
{
private ConquestArea[] areas;
private String name;
public ConquestGame(final String name) {
this.areas = new ConquestArea[ConquestArea.Type.values().length];
this.name = name;
}
public void setArea(final ConquestArea.Type type, final ConquestArea area) {
this.areas[type.ordinal()] = area;
}
public String getName() {
return this.name;
}
public ConquestArea getArea(final ConquestArea.Type type) {
return this.areas[type.ordinal()];
}
public ConquestArea[] getAreas() {
return this.areas;
}
public boolean isComplete() {
ConquestArea[] areas;
for (int length = (areas = this.areas).length, i = 0; i < length; ++i) {
final ConquestArea area = areas[i];
if (area == null) {
return false;
}
}
return true;
}
}

View File

@ -0,0 +1,115 @@
package com.igodlik3.conquest.event;
import com.igodlik3.conquest.*;
import com.igodlik3.conquest.utils.*;
import org.bukkit.configuration.*;
import org.bukkit.*;
import java.util.*;
public class ConquestManager
{
private ConquestData runningGameData;
private Configuration config;
private Configuration data;
private Map<ConquestArea, Cuboid> cuboCache;
public ConquestManager() {
this.config = (Configuration)Conquest.getInstance().getConfig();
this.data = (Configuration)Conquest.getInstance().getStorage().getConfig();
this.cuboCache = new HashMap<ConquestArea, Cuboid>();
}
public boolean gameExists(final String name) {
return this.data.contains("conquest." + name);
}
public void saveOrUpdateGame(final ConquestGame game) {
final ConfigurationSection section = this.gameExists("conquest." + game.getName()) ? this.data.getConfigurationSection("conquest." + game.getName()) : this.data.createSection("conquest." + game.getName());
for (int i = 0; i < ConquestArea.Type.values().length; ++i) {
final ConquestArea area = game.getArea(ConquestArea.Type.values()[i]);
if (area == null) {
section.set("area." + i, (Object)null);
}
else {
section.set("area." + i + ".loc1", (Object)Utils.stringifyLocation(area.getLoc1()));
section.set("area." + i + ".loc2", (Object)Utils.stringifyLocation(area.getLoc2()));
}
Conquest.getInstance().getStorage().saveConfig();
}
}
public ConquestGame getGame(final String name) {
if (!this.gameExists(name)) {
return null;
}
final ConfigurationSection section = this.data.getConfigurationSection("conquest." + name);
final ConquestGame game = new ConquestGame(name);
for (int i = 0; i < ConquestArea.Type.values().length; ++i) {
if (section.contains("area." + i)) {
game.setArea(ConquestArea.Type.values()[i], new ConquestArea(game, ConquestArea.Type.values()[i], Utils.destringifyLocation(section.getString("area." + i + ".loc1")), Utils.destringifyLocation(section.getString("area." + i + ".loc2"))));
}
}
return game;
}
public void startConquest(final ConquestGame game) {
this.setRunningGame(game);
Bukkit.broadcastMessage(Utils.color(this.config.getString("Messages.CONQUEST-STARTED").replaceAll("%NAME%", game.getName()).replaceAll("%POINTS%", String.valueOf(this.config.getInt("CONQUEST.Required-Points")))));
}
public Cuboid getConquestCubo(final ConquestArea area) {
if (this.cuboCache.containsKey(area)) {
return this.cuboCache.get(area);
}
final Cuboid cubo = new Cuboid(area.getLoc1(), area.getLoc2());
this.cuboCache.put(area, cubo);
return cubo;
}
public void deleteGame(final ConquestGame game) {
this.deleteGame(game.getName());
}
public void deleteGame(final String name) {
if (!this.gameExists(name)) {
return;
}
this.data.set("conquest." + name, (Object)null);
Conquest.getInstance().getStorage().saveConfig();
}
public Set<String> listGames() {
if (this.data.isConfigurationSection("conquest")) {
return (Set<String>)this.data.getConfigurationSection("conquest").getKeys(false);
}
return null;
}
public ConquestGame getRunningGame() {
if (!this.data.contains("conquest.running")) {
return null;
}
return this.getGame(this.data.getString("conquest.running"));
}
public boolean setRunningGame(final ConquestGame game) {
this.data.set("conquest.running", (Object)((game != null) ? game.getName() : null));
Conquest.getInstance().getStorage().saveConfig();
if (game == null) {
this.runningGameData = null;
}
else {
this.runningGameData = new ConquestData();
}
return true;
}
public void resetRunningGameData() {
this.data.set("rdata", (Object)null);
Conquest.getInstance().getStorage().saveConfig();
}
public ConquestData getRunningGameData() {
return this.runningGameData;
}
}

View File

@ -0,0 +1,44 @@
package com.igodlik3.conquest.listener;
import net.syuu.popura.PopuraPlugin;
import net.syuu.popura.faction.bean.Faction;
import net.syuu.popura.faction.bean.FactionPlayer;
import org.bukkit.configuration.*;
import com.igodlik3.conquest.*;
import org.bukkit.event.entity.*;
import org.bukkit.entity.*;
import com.igodlik3.conquest.utils.*;
import com.igodlik3.conquest.event.*;
import java.util.*;
import org.bukkit.event.*;
public class PlayerListener implements Listener
{
private Configuration config;
private ConquestManager cm;
public PlayerListener() {
this.config = (Configuration)Conquest.getInstance().getConfig();
this.cm = Conquest.getInstance().getConquestManager();
}
@EventHandler
public void onPlayerDeath(final PlayerDeathEvent event) {
final Player player = event.getEntity();
if (this.config.getBoolean("CONQUEST.Penality.enabled") && this.cm.getRunningGame() != null) {
final ConquestData ca = this.cm.getRunningGameData();
final FactionPlayer fp = PopuraPlugin.getInstance().getPopura().getFactionDataManager().getPlayer(player);
if (fp.getFaction() != null) {
final Faction faction = fp.getFaction();
final int penality = this.config.getInt("CONQUEST.Penality.points");
if (ca.getFactionPoints(faction) >= penality) {
ca.setFactionsPoints(faction, ca.getFactionPoints(faction) - penality, false);
for (final Player pls : faction.getOnlineMembers()) {
pls.sendMessage(Utils.color(this.config.getString("Messages.PENALITY").replaceAll("%POINTS%", String.valueOf(penality))));
}
}
}
}
}
}

View File

@ -0,0 +1,75 @@
package com.igodlik3.conquest.listener;
import net.syuu.popura.PopuraPlugin;
import org.bukkit.configuration.*;
import com.igodlik3.conquest.*;
import net.libhalt.bukkit.kaede.event.*;
import org.bukkit.event.*;
import com.igodlik3.conquest.event.*;
import java.util.*;
public class ScoreboardListener implements Listener
{
private String[] placeholders;
private ConquestManager cm;
private Configuration config;
public ScoreboardListener() {
this.cm = Conquest.getInstance().getConquestManager();
this.config = (Configuration)Conquest.getInstance().getConfig();
this.placeholders = new String[] { "%CONQUEST_RED%", "%CONQUEST_GREEN%", "%CONQUEST_BLUE%", "%CONQUEST_YELLOW%", "%FACTION_1_NAME%", "%FACTION_1_POINT%", "%FACTION_2_NAME%", "%FACTION_2_POINT%", "%FACTION_3_NAME%", "%FACTION_3_POINT%", "%FACTION_4_NAME%", "%FACTION_4_POINT%" };
}
@EventHandler
public void onScoreboardUpdate(final ScoreboardTextAboutToUpdateEvent event) {
String[] placeholders;
for (int length = (placeholders = this.placeholders).length, i = 0; i < length; ++i) {
final String string = placeholders[i];
if (event.getText() != null && event.getText().contains(string)) {
if (this.cm.getRunningGame() == null) {
event.setText((String)null);
}
else {
event.setText(this.convertPlaceholder(event.getText()));
}
}
}
}
private String convertPlaceholder(String text) {
final ConquestGame game = this.cm.getRunningGame();
if (game != null) {
ConquestArea[] areas;
for (int length = (areas = game.getAreas()).length, j = 0; j < length; ++j) {
final ConquestArea area = areas[j];
if (text.contains("%CONQUEST_" + area.getType().name() + "%")) {
final String time = String.valueOf(this.config.getInt("CONQUEST.Cap-Time") - this.cm.getRunningGameData().getCapTime(area.getType())) + "s";
text = text.replaceAll("%CONQUEST_" + area.getType().name() + "%", time);
}
}
final List<Map.Entry<String, Integer>> ranking = new LinkedList<Map.Entry<String, Integer>>(this.cm.getRunningGameData().getFactionsPoints().entrySet());
Collections.sort(ranking, new Comparator<Map.Entry<String, Integer>>() {
@Override
public int compare(final Map.Entry<String, Integer> o1, final Map.Entry<String, Integer> o2) {
return o2.getValue() - o1.getValue();
}
});
for (int i = 1; i < 5; ++i) {
final Map.Entry<String, Integer> entry = (i > ranking.size()) ? null : ranking.get(i - 1);
if (text.contains("%FACTION_" + i + "_NAME%")) {
if (entry == null) {
return null;
}
text = text.replaceAll("%FACTION_" + i + "_NAME%", PopuraPlugin.getInstance().getPopura().getFactionDataManager().getFaction((String)entry.getKey()).getName());
}
if (text.contains("%FACTION_" + i + "_POINT%")) {
if (entry == null) {
return null;
}
text = text.replaceAll("%FACTION_" + i + "_POINT%", new StringBuilder().append(entry.getValue()).toString());
}
}
}
return text;
}
}

View File

@ -0,0 +1,74 @@
package com.igodlik3.conquest.listener;
import com.igodlik3.ItemBuilder;
import org.bukkit.entity.*;
import org.bukkit.event.player.*;
import org.bukkit.event.block.*;
import org.bukkit.*;
import org.bukkit.block.*;
import org.bukkit.inventory.*;
import org.bukkit.event.*;
import java.util.*;
import com.igodlik3.conquest.utils.*;
public class SelectionListener implements Listener
{
private static Map<Player, Map<String, Location>> selectionMap;
static {
SelectionListener.selectionMap = new HashMap<Player, Map<String, Location>>();
}
@EventHandler
public void onInteract(final PlayerInteractEvent event) {
final Player player = event.getPlayer();
final Block block = event.getClickedBlock();
final Map<String, Location> map = SelectionListener.selectionMap.containsKey(player) ? SelectionListener.selectionMap.get(player) : new HashMap<String, Location>();
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (event.getItem() != null && event.getItem().getType() == Material.GOLD_HOE) {
final ItemStack item = event.getItem();
if (this.isWand(item)) {
event.setCancelled(true);
map.put("1", block.getLocation());
SelectionListener.selectionMap.put(player, map);
player.sendMessage(Utils.color("&dSelected the 2# point !"));
}
}
}
else if (event.getAction() == Action.LEFT_CLICK_BLOCK && event.getItem() != null && event.getItem().getType() == Material.GOLD_HOE) {
final ItemStack item = event.getItem();
if (this.isWand(item)) {
event.setCancelled(true);
map.put("2", block.getLocation());
SelectionListener.selectionMap.put(player, map);
player.sendMessage(Utils.color("&dSelected the 1# point !"));
}
}
}
public static boolean isCorrectSelection(final Player player) {
return SelectionListener.selectionMap.containsKey(player) && SelectionListener.selectionMap.get(player).size() == 2;
}
public static List<Location> getSelection(final Player player) {
final List<Location> result = new ArrayList<Location>();
if (!isCorrectSelection(player)) {
return null;
}
final Location loc1 = SelectionListener.selectionMap.get(player).get("1");
final Location loc2 = SelectionListener.selectionMap.get(player).get("2");
result.add(loc1);
result.add(loc2);
return result;
}
private boolean isWand(final ItemStack item) {
return item.hasItemMeta() && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equalsIgnoreCase(Utils.color("&e&lRegion &6Wand"));
}
public static void getWand(final Player player) {
final ItemStack wand = new ItemBuilder(Material.GOLD_HOE).displayname("&e&lRegion &6Wand").build();
player.getInventory().addItem(new ItemStack[] { wand });
player.updateInventory();
}
}

View File

@ -0,0 +1,53 @@
package com.igodlik3.conquest.loot;
import com.igodlik3.ItemBuilder;
import org.bukkit.configuration.*;
import com.igodlik3.conquest.*;
import org.bukkit.entity.*;
import org.bukkit.inventory.*;
import org.bukkit.*;
import com.igodlik3.conquest.utils.*;
import java.text.*;
import java.util.*;
public class ChestKey
{
private Configuration config;
public ChestKey() {
this.config = (Configuration)Conquest.getInstance().getConfig();
}
public void removeKey(final Player player) {
final int amount = player.getItemInHand().getAmount();
if (amount == 1) {
player.setItemInHand((ItemStack)null);
}
else {
player.getItemInHand().setAmount(amount - 1);
}
}
public boolean isKey(final ItemStack item) {
if (item != null && item.getType() == Material.TRIPWIRE_HOOK && item.hasItemMeta() && item.getItemMeta().hasDisplayName()) {
final String display = item.getItemMeta().getDisplayName();
final String d = this.config.getString("CONQUEST.Loot.Key.name");
return display.equalsIgnoreCase(Utils.color(d));
}
return false;
}
public void giveKey(final Player player) {
ItemStack key = null;
final List<String> lore = (List<String>)this.config.getStringList("CONQUEST.Loot.Key.lore");
final List<String> formatted = new ArrayList<String>();
final String display = this.config.getString("CONQUEST.Loot.Key.name");
final DateFormat dateFormat = new SimpleDateFormat(this.config.getString("Messages.Date-Format"));
final Date date = new Date();
for (final String stg : lore) {
formatted.add(Utils.color(stg).replaceAll("%DATE%", dateFormat.format(date)).replaceAll("%PLAYER%", player.getName()));
}
key = new ItemBuilder(Material.TRIPWIRE_HOOK).displayname(display).lore(formatted).build();
player.getInventory().addItem(new ItemStack[] { key });
}
}

View File

@ -0,0 +1,82 @@
package com.igodlik3.conquest.loot;
import net.syuu.popura.PopuraPlugin;
import net.syuu.popura.faction.bean.FactionPlayer;
import org.bukkit.configuration.*;
import com.igodlik3.conquest.*;
import org.bukkit.event.player.*;
import org.bukkit.event.block.*;
import com.igodlik3.conquest.utils.*;
import org.bukkit.inventory.*;
import org.bukkit.*;
import org.bukkit.entity.*;
import org.bukkit.block.*;
import java.util.*;
import org.bukkit.event.*;
public class ChestListener implements Listener
{
private Configuration config;
private ChestLootManager manager;
private LootManager lm;
private ChestKey key;
public ChestListener() {
this.config = (Configuration)Conquest.getInstance().getConfig();
this.manager = new ChestLootManager();
this.lm = Conquest.getInstance().getLootManager();
this.key = new ChestKey();
}
@EventHandler
public void onInteract(final PlayerInteractEvent event) {
final Player player = event.getPlayer();
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
final Block block = event.getClickedBlock();
if (this.manager.isChestLoot(block.getLocation())) {
event.setCancelled(true);
final ItemStack item = event.getItem();
if (this.key.isKey(item)) {
final int lootNumber = this.config.getInt("CONQUEST.Loot-Number");
if (this.lm.getLootList().isEmpty()) {
player.sendMessage(Utils.color("&4&lLoot not found ! &cPlease fill the chest loot with items &e/conquest editloot"));
return;
}
final List<ItemStack> set = new ArrayList<ItemStack>(this.lm.getLootList());
if (set.size() < lootNumber) {
player.sendMessage(Utils.color("&cPlease fill the chest loot with items. &eLoot size: " + set.size() + " &7- &eLoot needed: " + lootNumber));
return;
}
final Random r = new Random();
final FactionPlayer fp = PopuraPlugin.getInstance().getPopura().getFactionDataManager().getPlayer(player);
Bukkit.broadcastMessage(Utils.color(this.config.getString("Messages.LOOT")).replaceAll("%PLAYER%", player.getName()).replaceAll("%FACTION%", fp.getFaction().getName()));
for (int i = 0; i < lootNumber; ++i) {
final ItemStack is = set.get(r.nextInt(set.size()));
player.getInventory().addItem(new ItemStack[] { is });
Bukkit.broadcastMessage(Utils.color("&7- &e" + this.stringifyItem(is)));
}
player.updateInventory();
this.key.removeKey(player);
}
else {
player.sendMessage(Utils.color(this.config.getString("Messages.CHEST-LOOT-NO-KEY")));
}
}
}
}
private String stringifyItem(final ItemStack item) {
String itemName;
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()) {
itemName = item.getItemMeta().getDisplayName();
}
else {
final String matName = item.getType().toString().replace("_", " ").toLowerCase();
itemName = String.valueOf(Character.toUpperCase(matName.charAt(0))) + matName.substring(1);
}
if (item.getAmount() > 1) {
return String.valueOf(item.getAmount()) + "x " + itemName;
}
return itemName;
}
}

View File

@ -0,0 +1,63 @@
package com.igodlik3.conquest.loot;
import org.bukkit.configuration.*;
import com.igodlik3.conquest.*;
import org.bukkit.*;
import com.igodlik3.conquest.utils.*;
import java.util.*;
public class ChestLootManager
{
private Configuration storage;
public ChestLootManager() {
this.storage = (Configuration)Conquest.getInstance().getStorage().getConfig();
}
public boolean isChestLoot(final Location loc) {
final List<Location> list = this.getLocations();
if (list.isEmpty()) {
return false;
}
for (final Location l : list) {
if (l != null && l.getBlockX() == loc.getBlockX() && l.getBlockZ() == loc.getBlockZ() && l.getBlockY() == loc.getBlockY()) {
return true;
}
}
return false;
}
public List<Location> getLocations() {
final List<Location> list = new ArrayList<Location>();
if (!this.storage.contains("chestloot.location")) {
return list;
}
for (final String stg : this.storage.getStringList("chestloot.location")) {
list.add(Utils.destringifyLocation(stg));
}
return list;
}
public void removeLocation(final Location loc) {
final String string = Utils.stringifyLocation(loc);
final List<String> strings = new ArrayList<String>(this.storage.getStringList("chestloot.location"));
for (final String stg : this.storage.getStringList("chestloot.location")) {
if (stg.equals(string)) {
strings.remove(string);
}
}
this.storage.set("chestloot.location", (Object)strings);
Conquest.getInstance().getStorage().saveConfig();
}
public void addLocation(final Location location) {
final String string = Utils.stringifyLocation(location);
final List<String> strings = new ArrayList<String>(this.storage.getStringList("chestloot.location"));
if (strings.contains(string)) {
return;
}
strings.add(string);
this.storage.set("chestloot.location", (Object)strings);
Conquest.getInstance().getStorage().saveConfig();
}
}

View File

@ -0,0 +1,125 @@
package com.igodlik3.conquest.loot;
import org.bukkit.configuration.*;
import com.igodlik3.conquest.*;
import org.bukkit.plugin.*;
import org.bukkit.*;
import org.bukkit.inventory.*;
import java.util.*;
import org.bukkit.entity.*;
import com.igodlik3.conquest.utils.*;
import org.bukkit.event.*;
import org.bukkit.event.inventory.*;
public class LootManager implements Listener
{
private Configuration storage;
private Set<UUID> lootEditors;
private Inventory inv;
private List<ItemStack> lootList;
public LootManager() {
this.storage = (Configuration)Conquest.getInstance().getStorage().getConfig();
this.lootEditors = new HashSet<UUID>();
this.lootList = new ArrayList<ItemStack>();
this.reloadLoot();
Bukkit.getPluginManager().registerEvents((Listener)this, Conquest.getInstance().getPlugin());
}
public void loadLoot() {
final Object value = this.storage.get("Loot");
if (value != null) {
ItemStack[] contents = null;
if (value instanceof ItemStack[]) {
contents = (ItemStack[])value;
}
else if (value instanceof List) {
contents = (ItemStack[]) ((List)value).toArray(new ItemStack[0]);
}
this.inv.setContents(contents);
ItemStack[] array;
for (int length = (array = contents).length, i = 0; i < length; ++i) {
final ItemStack is = array[i];
if (is != null && is.getType() != Material.AIR) {
this.lootList.add(is);
}
}
}
}
public void saveLoot() {
this.storage.set("Loot", (Object)this.inv.getContents());
Conquest.getInstance().getStorage().saveConfig();
this.lootList.clear();
ItemStack[] contents;
for (int length = (contents = this.inv.getContents()).length, i = 0; i < length; ++i) {
final ItemStack is = contents[i];
if (is != null && is.getType() != Material.AIR) {
this.lootList.add(is);
}
}
}
public void reloadLoot() {
final int size = 36;
this.inv = Bukkit.createInventory((InventoryHolder)null, size, "Conquest Loot");
this.loadLoot();
}
public ItemStack getRandomLoot() {
final Random r = new Random();
return this.lootList.get(r.nextInt(this.lootList.size()));
}
public void openLoot(final Player player, final boolean access) {
player.openInventory(this.inv);
if (access) {
this.lootEditors.add(player.getUniqueId());
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onInventoryClose(final InventoryCloseEvent event) {
final Player player = (Player)event.getPlayer();
final UUID uuid = player.getUniqueId();
final Inventory inv = event.getInventory();
boolean eventInv = false;
if (inv != null && inv.getName() != null) {
if (inv.getName().equalsIgnoreCase("Conquest Loot")) {
eventInv = true;
}
if (eventInv) {
final String name = inv.getName();
if (this.lootEditors.contains(uuid)) {
this.saveLoot();
player.sendMessage(Utils.color("&aSaving loot for &d" + name + " &a!"));
this.lootEditors.remove(uuid);
}
}
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onInventoryClick(final InventoryClickEvent event) {
final Player player = (Player)event.getWhoClicked();
final UUID uuid = player.getUniqueId();
final Inventory inv = event.getInventory();
boolean eventInv = false;
if (inv != null && inv.getName() != null) {
if (inv.getName().equalsIgnoreCase("Conquest Loot")) {
eventInv = true;
}
if (eventInv && !this.lootEditors.contains(uuid)) {
event.setCancelled(true);
}
}
}
public Inventory getInv() {
return this.inv;
}
public List<ItemStack> getLootList() {
return this.lootList;
}
}

View File

@ -0,0 +1,119 @@
package com.igodlik3.conquest.task;
import net.syuu.popura.PopuraPlugin;
import net.syuu.popura.faction.bean.Faction;
import net.syuu.popura.faction.bean.FactionPlayer;
import org.bukkit.scheduler.*;
import org.bukkit.configuration.*;
import com.igodlik3.conquest.*;
import org.bukkit.entity.*;
import com.igodlik3.conquest.loot.*;
import com.igodlik3.conquest.event.*;
import com.igodlik3.conquest.utils.*;
import java.util.*;
import org.bukkit.*;
public class ConquestTask extends BukkitRunnable
{
private Configuration config;
public ConquestTask() {
this.config = (Configuration)Conquest.getInstance().getConfig();
}
public void run() {
if (Conquest.getInstance().getConquestManager().getRunningGame() == null) {
return;
}
final ConquestManager manager = Conquest.getInstance().getConquestManager();
final ConquestData data = manager.getRunningGameData();
final ConquestGame game = manager.getRunningGame();
ConquestArea.Type[] values;
for (int length = (values = ConquestArea.Type.values()).length, j = 0; j < length; ++j) {
final ConquestArea.Type type = values[j];
final ConquestArea area = game.getArea(type);
final Cuboid cubo = manager.getConquestCubo(area);
final List<Player> containedPlayers = new ArrayList<Player>();
final List<Faction> containedFactions = new ArrayList<Faction>();
for(Player player : Bukkit.getOnlinePlayers()){
final FactionPlayer fp = PopuraPlugin.getInstance().getPopura().getFactionDataManager().getPlayer(player);
if (fp.getFaction() != null) {
if (cubo.contains(player.getLocation())) {
containedPlayers.add(player);
if (!containedFactions.contains(fp.getFaction())) {
containedFactions.add(fp.getFaction());
}
}
}
}
if (containedFactions.size() == 0) {
data.resetTime(type);
data.setFirstCapper(area.getType(), null);
}
else {
if (data.getFirstCapper(area.getType()) != null && !containedFactions.contains(data.getFirstCapper(area.getType()))) {
data.setFirstCapper(area.getType(), null);
}
if (data.getFirstCapper(area.getType()) == null) {
data.setFirstCapper(area.getType(), containedPlayers.get(0));
}
final FactionPlayer fp2 = PopuraPlugin.getInstance().getPopura().getFactionDataManager().getPlayer(data.getFirstCapper(area.getType()));
if (fp2.getFaction() != null && data.capPoint(fp2.getFaction(), type)) {
int points = data.getFactionPoints(data.getFirstCapper(area.getType()));
points = ((points == -1) ? 1 : (points + 1));
data.setFactionsPoints(data.getFirstCapper(area.getType()), points);
if (String.valueOf(points).endsWith("0")) {
Bukkit.broadcastMessage(Utils.color(this.config.getString("Messages.CONQUEST-CAPPING").replaceAll("%POINTS%", String.valueOf(points)).replaceAll("%AREA%", this.getColor(area.getType()) + area.getType().name()).replaceAll("%FACTION%", fp2.getFaction().getName())));
}
if (data.getFactionPoints(data.getFirstCapper(area.getType())) >= this.config.getInt("CONQUEST.Required-Points")) {
manager.setRunningGame(null);
manager.resetRunningGameData();
Player player2 = null;
for (final Player testPlayer : containedPlayers) {
final FactionPlayer fp3 = PopuraPlugin.getInstance().getPopura().getFactionDataManager().getPlayer(testPlayer);
if (fp3.getFaction() == data.getFirstCapper(area.getType())) {
player2 = testPlayer;
break;
}
}
if (player2 == null) {
for(Player testPlayer : Bukkit.getOnlinePlayers()){
final FactionPlayer fp4 = PopuraPlugin.getInstance().getPopura().getFactionDataManager().getPlayer(testPlayer);
if (fp4.getFaction() == data.getFirstCapper(area.getType())) {
player2 = testPlayer;
break;
}
}
}
final FactionPlayer fp5 = PopuraPlugin.getInstance().getPopura().getFactionDataManager().getPlayer(player2);
Bukkit.broadcastMessage(Utils.color(this.config.getString("Messages.Conquest.CONQUEST-WIN").replaceAll("%FACTION%", fp5.getFaction().getName()).replaceAll("%POINTS%", String.valueOf(this.config.getInt("CONQUEST.Required-Points")))));
final ChestKey key = new ChestKey();
for (int i = 0; i < this.config.getInt("Conquest.Loot.Key.amount"); ++i) {
key.giveKey(player2);
}
}
}
}
}
}
private ChatColor getColor(final ConquestArea.Type type) {
switch (type) {
case RED: {
return ChatColor.RED;
}
case YELLOW: {
return ChatColor.YELLOW;
}
case BLUE: {
return ChatColor.BLUE;
}
case GREEN: {
return ChatColor.GREEN;
}
default: {
return null;
}
}
}
}

View File

@ -0,0 +1,88 @@
package com.igodlik3.conquest.utils;
import org.bukkit.configuration.file.*;
import com.google.common.base.*;
import com.google.common.io.*;
import java.util.logging.*;
import java.nio.charset.*;
import org.bukkit.configuration.*;
import java.io.*;
import org.bukkit.plugin.*;
public class Config
{
File f;
FileConfiguration cfg;
String path_;
String fileName_;
private Plugin main;
public Config(final String path, final String fileName, final Plugin JavaPluginExtender) {
this.main = JavaPluginExtender;
this.path_ = path;
this.fileName_ = fileName;
}
public void create() {
this.f = new File(this.path_, this.fileName_);
this.cfg = (FileConfiguration)YamlConfiguration.loadConfiguration(this.f);
}
public void setDefault(final String filename) {
final InputStream defConfigStream = this.main.getResource(filename);
if (defConfigStream == null) {
return;
}
YamlConfiguration defConfig;
if (this.isStrictlyUTF8()) {
defConfig = YamlConfiguration.loadConfiguration((Reader)new InputStreamReader(defConfigStream, Charsets.UTF_8));
}
else {
defConfig = new YamlConfiguration();
byte[] contents;
try {
contents = ByteStreams.toByteArray(defConfigStream);
}
catch (IOException e) {
this.main.getLogger().log(Level.SEVERE, "Unexpected failure reading " + filename, e);
return;
}
final String text = new String(contents, Charset.defaultCharset());
if (!text.equals(new String(contents, Charsets.UTF_8))) {
this.main.getLogger().warning("Default system encoding may have misread " + filename + " from plugin jar");
}
try {
defConfig.loadFromString(text);
}
catch (InvalidConfigurationException e2) {
this.main.getLogger().log(Level.SEVERE, "Cannot load configuration from jar", (Throwable)e2);
}
}
this.cfg.setDefaults((Configuration)defConfig);
}
private boolean isStrictlyUTF8() {
return this.main.getDescription().getAwareness().contains(PluginAwareness.Flags.UTF8);
}
public void saveConfig() {
try {
this.cfg.save(this.f);
}
catch (IOException e) {
e.printStackTrace();
}
}
public FileConfiguration getConfig() {
return this.cfg;
}
public File toFile() {
return this.f;
}
public boolean exists() {
return this.f.exists();
}
}

View File

@ -0,0 +1,473 @@
package com.igodlik3.conquest.utils;
import org.bukkit.block.*;
import org.bukkit.configuration.serialization.*;
import java.util.logging.*;
import java.util.*;
import org.bukkit.*;
public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializable
{
protected final String worldName;
protected final int x1;
protected final int y1;
protected final int z1;
protected final int x2;
protected final int y2;
protected final int z2;
public Cuboid(final Location location1, final Location location2) {
if (!location1.getWorld().equals(location2.getWorld())) {
Logger.getLogger("Les locations doivent \u00eatre dans un m\u00eame monde.");
}
this.worldName = location1.getWorld().getName();
this.x1 = Math.min(location1.getBlockX(), location2.getBlockX());
this.y1 = Math.min(location1.getBlockY(), location2.getBlockY());
this.z1 = Math.min(location1.getBlockZ(), location2.getBlockZ());
this.x2 = Math.max(location1.getBlockX(), location2.getBlockX());
this.y2 = Math.max(location1.getBlockY(), location2.getBlockY());
this.z2 = Math.max(location1.getBlockZ(), location2.getBlockZ());
}
public Cuboid(final Location location) {
this(location, location);
}
public Cuboid(final Cuboid cuboid) {
this(cuboid.getWorld().getName(), cuboid.x1, cuboid.y1, cuboid.z1, cuboid.x2, cuboid.y2, cuboid.z2);
}
private Cuboid(final String string, final int n, final int n2, final int n3, final int n4, final int n5, final int n6) {
this.worldName = string;
this.x1 = Math.min(n, n4);
this.x2 = Math.max(n, n4);
this.y1 = Math.min(n2, n5);
this.y2 = Math.max(n2, n5);
this.z1 = Math.min(n3, n6);
this.z2 = Math.max(n3, n6);
}
public Cuboid(final Map<String, Object> map) {
this.worldName = (String) map.get("worldName");
this.x1 = (int) map.get("x1");
this.x2 = (int) map.get("x2");
this.y1 = (int)map.get("y1");
this.y2 = (int)map.get("y2");
this.z1 = (int)map.get("z1");
this.z2 = (int) map.get("z2");
}
public Map<String, Object> serialize() {
final HashMap<String, Object> hashMap = new HashMap<String, Object>();
hashMap.put("worldName", this.worldName);
hashMap.put("x1", this.x1);
hashMap.put("y1", this.y1);
hashMap.put("z1", this.z1);
hashMap.put("x2", this.x2);
hashMap.put("y2", this.y2);
hashMap.put("z2", this.z2);
return hashMap;
}
public Location getLowerNE() {
return new Location(this.getWorld(), (double)this.x1, (double)this.y1, (double)this.z1);
}
public Location getUpperSW() {
return new Location(this.getWorld(), (double)this.x2, (double)this.y2, (double)this.z2);
}
public List<Block> getBlocks() {
final Iterator<Block> iterator = this.iterator();
final ArrayList<Block> arrayList = new ArrayList<Block>();
while (iterator.hasNext()) {
arrayList.add(iterator.next());
}
return arrayList;
}
public Location getCenter() {
final int i = this.getUpperX() + 1;
final int j = this.getUpperY() + 1;
final int k = this.getUpperZ() + 1;
return new Location(this.getWorld(), this.getLowerX() + (i - this.getLowerX()) / 2.0, this.getLowerY() + (j - this.getLowerY()) / 2.0, this.getLowerZ() + (k - this.getLowerZ()) / 2.0);
}
public World getWorld() {
final World world = Bukkit.getWorld(this.worldName);
if (world == null) {
Logger.getLogger("Le monde " + this.worldName + "n'est pas charg\u00e9 !");
}
return world;
}
public int getSizeX() {
return this.x2 - this.x1 + 1;
}
public int getSizeY() {
return this.y2 - this.y1 + 1;
}
public int getSizeZ() {
return this.z2 - this.z1 + 1;
}
public int getLowerX() {
return this.x1;
}
public int getLowerY() {
return this.y1;
}
public int getLowerZ() {
return this.z1;
}
public int getUpperX() {
return this.x2;
}
public int getUpperY() {
return this.y2;
}
public int getUpperZ() {
return this.z2;
}
public Block[] corners() {
final Block[] arrayOfBlock = new Block[8];
final World localWorld = this.getWorld();
arrayOfBlock[0] = localWorld.getBlockAt(this.x1, this.y1, this.z1);
arrayOfBlock[1] = localWorld.getBlockAt(this.x1, this.y1, this.z2);
arrayOfBlock[2] = localWorld.getBlockAt(this.x1, this.y2, this.z1);
arrayOfBlock[3] = localWorld.getBlockAt(this.x1, this.y2, this.z2);
arrayOfBlock[4] = localWorld.getBlockAt(this.x2, this.y1, this.z1);
arrayOfBlock[5] = localWorld.getBlockAt(this.x2, this.y1, this.z2);
arrayOfBlock[6] = localWorld.getBlockAt(this.x2, this.y2, this.z1);
arrayOfBlock[7] = localWorld.getBlockAt(this.x2, this.y2, this.z2);
return arrayOfBlock;
}
public Cuboid expand(final CuboidDirection paramCuboidDirection, final int paramInt) {
switch (paramCuboidDirection) {
case Both: {
return new Cuboid(this.worldName, this.x1 - paramInt, this.y1, this.z1, this.x2, this.y2, this.z2);
}
case East: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2 + paramInt, this.y2, this.z2);
}
case Down: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z1 - paramInt, this.x2, this.y2, this.z2);
}
case Horizontal: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y2, this.z2 + paramInt);
}
case South: {
return new Cuboid(this.worldName, this.x1, this.y1 - paramInt, this.z1, this.x2, this.y2, this.z2);
}
case North: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y2 + paramInt, this.z2);
}
default: {
throw new IllegalArgumentException("Invalid direction " + paramCuboidDirection);
}
}
}
public Cuboid shift(final CuboidDirection paramCuboidDirection, final int paramInt) {
return this.expand(paramCuboidDirection, paramInt).expand(paramCuboidDirection.opposite(), -paramInt);
}
public Cuboid outset(final CuboidDirection paramCuboidDirection, final int paramInt) {
Cuboid localCuboid = null;
switch (paramCuboidDirection) {
case Unknown: {
localCuboid = this.expand(CuboidDirection.North, paramInt).expand(CuboidDirection.South, paramInt).expand(CuboidDirection.East, paramInt).expand(CuboidDirection.West, paramInt);
break;
}
case Up: {
localCuboid = this.expand(CuboidDirection.Down, paramInt).expand(CuboidDirection.Up, paramInt);
break;
}
case Vertical: {
localCuboid = this.outset(CuboidDirection.Horizontal, paramInt).outset(CuboidDirection.Vertical, paramInt);
break;
}
default: {
throw new IllegalArgumentException("Invalid direction " + paramCuboidDirection);
}
}
return localCuboid;
}
public Cuboid inset(final CuboidDirection cuboidDirection, final int n) {
return this.outset(cuboidDirection, -n);
}
public boolean contains(final int n, final int n2, final int n3) {
return n >= this.x1 && n <= this.x2 && n2 >= this.y1 && n2 <= this.y2 && n3 >= this.z1 && n3 <= this.z2;
}
public boolean contains(final Block block) {
return this.contains(block.getLocation());
}
public boolean contains(final Location location) {
return this.worldName.equals(location.getWorld().getName()) && this.contains(location.getBlockX(), location.getBlockY(), location.getBlockZ());
}
public int getVolume() {
return this.getSizeX() * this.getSizeY() * this.getSizeZ();
}
public byte getAverageLightLevel() {
long l = 0L;
int i = 0;
for (final Block localBlock : this) {
if (localBlock.isEmpty()) {
l += localBlock.getLightLevel();
++i;
}
}
return (byte)((i > 0) ? ((byte)(l / i)) : 0);
}
public Cuboid contract() {
return this.contract(CuboidDirection.Down).contract(CuboidDirection.South).contract(CuboidDirection.East).contract(CuboidDirection.Up).contract(CuboidDirection.North).contract(CuboidDirection.West);
}
public Cuboid contract(final CuboidDirection paramCuboidDirection) {
Cuboid localCuboid = this.getFace(paramCuboidDirection.opposite());
switch (paramCuboidDirection) {
case South: {
while (localCuboid.containsOnly(0) && localCuboid.getLowerY() > this.getLowerY()) {
localCuboid = localCuboid.shift(CuboidDirection.Down, 1);
}
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, localCuboid.getUpperY(), this.z2);
}
case North: {
while (localCuboid.containsOnly(0) && localCuboid.getUpperY() < this.getUpperY()) {
localCuboid = localCuboid.shift(CuboidDirection.Up, 1);
}
return new Cuboid(this.worldName, this.x1, localCuboid.getLowerY(), this.z1, this.x2, this.y2, this.z2);
}
case Both: {
while (localCuboid.containsOnly(0) && localCuboid.getLowerX() > this.getLowerX()) {
localCuboid = localCuboid.shift(CuboidDirection.North, 1);
}
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, localCuboid.getUpperX(), this.y2, this.z2);
}
case East: {
while (localCuboid.containsOnly(0) && localCuboid.getUpperX() < this.getUpperX()) {
localCuboid = localCuboid.shift(CuboidDirection.South, 1);
}
return new Cuboid(this.worldName, localCuboid.getLowerX(), this.y1, this.z1, this.x2, this.y2, this.z2);
}
case Down: {
while (localCuboid.containsOnly(0) && localCuboid.getLowerZ() > this.getLowerZ()) {
localCuboid = localCuboid.shift(CuboidDirection.East, 1);
}
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y2, localCuboid.getUpperZ());
}
case Horizontal: {
while (localCuboid.containsOnly(0) && localCuboid.getUpperZ() < this.getUpperZ()) {
localCuboid = localCuboid.shift(CuboidDirection.West, 1);
}
return new Cuboid(this.worldName, this.x1, this.y1, localCuboid.getLowerZ(), this.x2, this.y2, this.z2);
}
default: {
throw new IllegalArgumentException("Invalid direction " + paramCuboidDirection);
}
}
}
public Cuboid getFace(final CuboidDirection paramCuboidDirection) {
switch (paramCuboidDirection) {
case South: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y1, this.z2);
}
case North: {
return new Cuboid(this.worldName, this.x1, this.y2, this.z1, this.x2, this.y2, this.z2);
}
case Both: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x1, this.y2, this.z2);
}
case East: {
return new Cuboid(this.worldName, this.x2, this.y1, this.z1, this.x2, this.y2, this.z2);
}
case Down: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y2, this.z1);
}
case Horizontal: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z2, this.x2, this.y2, this.z2);
}
default: {
throw new IllegalArgumentException("Invalid direction " + paramCuboidDirection);
}
}
}
public boolean containsOnly(final int paramInt) {
for (final Block block : this) {
if (block.getTypeId() != paramInt) {
return false;
}
}
return true;
}
public Cuboid getBoundingCuboid(final Cuboid paramCuboid) {
if (paramCuboid == null) {
return this;
}
final int i = Math.min(this.getLowerX(), paramCuboid.getLowerX());
final int j = Math.min(this.getLowerY(), paramCuboid.getLowerY());
final int k = Math.min(this.getLowerZ(), paramCuboid.getLowerZ());
final int m = Math.max(this.getUpperX(), paramCuboid.getUpperX());
final int n = Math.max(this.getUpperY(), paramCuboid.getUpperY());
final int i2 = Math.max(this.getUpperZ(), paramCuboid.getUpperZ());
return new Cuboid(this.worldName, i, j, k, m, n, i2);
}
public Block getRelativeBlock(final int n, final int n2, final int n3) {
return this.getWorld().getBlockAt(this.x1 + n, this.y1 + n2, this.z1 + n3);
}
public Block getRelativeBlock(final World world, final int n, final int n2, final int n3) {
return world.getBlockAt(this.x1 + n, this.y1 + n2, this.z1 + n3);
}
public List<Chunk> getChunks() {
final ArrayList<Chunk> arrayList = new ArrayList<Chunk>();
final World world = this.getWorld();
final int i = this.getLowerX() & 0xFFFFFFF0;
final int j = this.getUpperX() & 0xFFFFFFF0;
final int k = this.getLowerZ() & 0xFFFFFFF0;
final int m = this.getUpperZ() & 0xFFFFFFF0;
for (int n = i; n <= j; n += 16) {
for (int i2 = k; i2 <= m; i2 += 16) {
arrayList.add(world.getChunkAt(n >> 4, i2 >> 4));
}
}
return arrayList;
}
@Override
public Iterator<Block> iterator() {
return new CuboidIterator(this.getWorld(), this.x1, this.y1, this.z1, this.x2, this.y2, this.z2);
}
public Cuboid clone() {
return new Cuboid(this);
}
@Override
public String toString() {
return new String("Cuboid: " + this.worldName + "," + this.x1 + "," + this.y1 + "," + this.z1 + "=>" + this.x2 + "," + this.y2 + "," + this.z2);
}
public enum CuboidDirection
{
North("North", 0),
East("East", 1),
South("South", 2),
West("West", 3),
Up("Up", 4),
Down("Down", 5),
Horizontal("Horizontal", 6),
Vertical("Vertical", 7),
Both("Both", 8),
Unknown("Unknown", 9);
private CuboidDirection(final String s, final int n) {
}
public CuboidDirection opposite() {
switch (this) {
case Both: {
return CuboidDirection.South;
}
case Down: {
return CuboidDirection.West;
}
case East: {
return CuboidDirection.North;
}
case Horizontal: {
return CuboidDirection.East;
}
case Unknown: {
return CuboidDirection.Vertical;
}
case Up: {
return CuboidDirection.Horizontal;
}
case North: {
return CuboidDirection.Down;
}
case South: {
return CuboidDirection.Up;
}
case Vertical: {
return CuboidDirection.Both;
}
default: {
return CuboidDirection.Unknown;
}
}
}
}
public class CuboidIterator implements Iterator<Block>
{
private World w;
private int baseX;
private int baseY;
private int baseZ;
private int x;
private int y;
private int z;
private int sizeX;
private int sizeY;
private int sizeZ;
public CuboidIterator(final World paramWorld, final int paramInt1, final int paramInt2, final int paramInt3, final int paramInt4, final int paramInt5, final int paramInt6) {
this.w = paramWorld;
this.baseX = paramInt1;
this.baseY = paramInt2;
this.baseZ = paramInt3;
this.sizeX = Math.abs(paramInt4 - paramInt1) + 1;
this.sizeY = Math.abs(paramInt5 - paramInt2) + 1;
this.sizeZ = Math.abs(paramInt6 - paramInt3) + 1;
final boolean x = false;
this.z = (x ? 1 : 0);
this.y = (x ? 1 : 0);
this.x = (x ? 1 : 0);
}
@Override
public boolean hasNext() {
return this.x < this.sizeX && this.y < this.sizeY && this.z < this.sizeZ;
}
@Override
public Block next() {
final Block block = this.w.getBlockAt(this.baseX + this.x, this.baseY + this.y, this.baseZ + this.z);
if (++this.x >= this.sizeX) {
this.x = 0;
if (++this.y >= this.sizeY) {
this.y = 0;
++this.z;
}
}
return block;
}
@Override
public void remove() {
}
}
}

View File

@ -0,0 +1,26 @@
package com.igodlik3.conquest.utils;
import org.bukkit.*;
public class Utils
{
public static String color(final String stg) {
return ChatColor.translateAlternateColorCodes('&', stg);
}
public static String stringifyLocation(final Location location) {
return "[" + location.getWorld().getName() + "," + location.getX() + "," + location.getY() + "," + location.getZ() + "]";
}
public static Location destringifyLocation(final String string) {
final String[] split = string.substring(1, string.length() - 2).split(",");
final World world = Bukkit.getWorld(split[0]);
if (world == null) {
return null;
}
final double x = Double.parseDouble(split[1]);
final double y = Double.parseDouble(split[2]);
final double z = Double.parseDouble(split[3]);
return new Location(world, x, y, z);
}
}

View File

@ -0,0 +1,32 @@
package com.igodlik3.enchantfix;
import net.libhalt.bukkit.kaede.HCFactionPlugin;
import net.libhalt.bukkit.kaede.utils.ConfigurationWrapper;
import net.libhalt.bukkit.kaede.utils.Manager;
import org.bukkit.configuration.Configuration;
import org.bukkit.plugin.java.*;
import org.bukkit.event.*;
import org.bukkit.plugin.*;
public class EnchantFix extends Manager
{
private static EnchantFix instance;
private ConfigurationWrapper config;
public EnchantFix(HCFactionPlugin plugin) {
super(plugin);
}
public Configuration getConfig(){
return config.getConfig();
}
public void init() {
config = new ConfigurationWrapper("enchant-fix.yml", this.getPlugin());
EnchantFix.instance = this;
this.getPlugin().getServer().getPluginManager().registerEvents((Listener)new EnchantListener(),getPlugin());
}
public static EnchantFix getInstance() {
return EnchantFix.instance;
}
}

View File

@ -0,0 +1,164 @@
package com.igodlik3.enchantfix;
import org.bukkit.configuration.*;
import org.bukkit.enchantments.*;
import org.bukkit.inventory.*;
import org.bukkit.event.*;
import org.bukkit.event.enchantment.*;
import org.bukkit.event.inventory.*;
import org.bukkit.inventory.meta.*;
import org.bukkit.event.player.*;
import org.bukkit.event.entity.*;
import java.util.*;
import org.bukkit.entity.*;
import org.bukkit.*;
import net.md_5.bungee.api.chat.*;
public class EnchantListener implements Listener
{
private Configuration config;
public EnchantListener() {
this.config = (Configuration)EnchantFix.getInstance().getConfig();
}
@EventHandler
public void onPlayerInteract(final PlayerInteractEvent event) {
if (event.getItem() != null && event.getItem().getType() != Material.AIR) {
final ItemStack item = event.getItem();
if (item.getEnchantments() != null && !item.getEnchantments().isEmpty()) {
final Map<Enchantment, Integer> enchants = (Map<Enchantment, Integer>)item.getEnchantments();
try {
for (final String enchant : this.config.getStringList("Enchant-Limiter")) {
final String[] parse = enchant.split(":");
final Enchantment enchantment = Enchantment.getByName(parse[0]);
final int level = Integer.parseInt(parse[1]);
if (enchants.containsKey(enchantment) && enchants.get(enchantment) > level) {
event.getPlayer().setItemInHand((ItemStack)null);
this.notifyAdmins(event.getPlayer());
}
}
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
@EventHandler
public void onEnchantItem(final EnchantItemEvent e) {
final Map<Enchantment, Integer> enchants = (Map<Enchantment, Integer>)e.getEnchantsToAdd();
try {
for (final String enchant : this.config.getStringList("Enchant-Limiter")) {
final String[] parse = enchant.split(":");
final Enchantment enchantment = Enchantment.getByName(parse[0]);
final int level = Integer.parseInt(parse[1]);
if (enchants.containsKey(enchantment) && enchants.get(enchantment) > level) {
enchants.remove(enchantment);
if (level <= 0) {
continue;
}
enchants.put(enchantment, level);
}
}
}
catch (Exception ex) {
ex.printStackTrace();
}
}
@EventHandler
public void onInventoryClick(final InventoryClickEvent e) {
if (e.getInventory().getType() == InventoryType.ANVIL && e.getSlotType() == InventoryType.SlotType.RESULT) {
final ItemStack item = e.getCurrentItem();
try {
for (final String blockedEnchantments : this.config.getStringList("Enchant-Limiter")) {
final String[] parse = blockedEnchantments.split(":");
final Enchantment selectedEnchantment = Enchantment.getByName(parse[0]);
final int level = Integer.parseInt(parse[1]);
if (item.getType() == Material.ENCHANTED_BOOK) {
final EnchantmentStorageMeta bookMeta = (EnchantmentStorageMeta)item.getItemMeta();
if (bookMeta.getStoredEnchants().containsKey(selectedEnchantment) && bookMeta.getStoredEnchants().get(selectedEnchantment) > level) {
e.setCancelled(true);
return;
}
}
if (item.getEnchantments().containsKey(selectedEnchantment) && item.getEnchantments().get(selectedEnchantment) > level) {
e.setCancelled(true);
}
}
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}
@EventHandler
public void onPlayerFish(final PlayerFishEvent event) {
final Entity entity = event.getCaught();
if (entity != null && entity instanceof ItemStack) {
final ItemStack item = (ItemStack)entity;
if (item.getEnchantments() != null && !item.getEnchantments().isEmpty()) {
final Map<Enchantment, Integer> enchants = (Map<Enchantment, Integer>)item.getEnchantments();
try {
for (final String enchant : this.config.getStringList("Enchant-Limiter")) {
final String[] parse = enchant.split(":");
final Enchantment enchantment = Enchantment.getByName(parse[0]);
final int level = Integer.parseInt(parse[1]);
if (enchants.containsKey(enchantment) && enchants.get(enchantment) > level) {
item.removeEnchantment(enchantment);
if (level <= 0) {
continue;
}
item.addEnchantment(enchantment, level);
}
}
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
@EventHandler
public void onEntityDeath(final EntityDeathEvent event) {
final List<ItemStack> items = (List<ItemStack>)event.getDrops();
if (items != null) {
for (final ItemStack item : items) {
if (item != null && item.getType() != Material.AIR && item.getEnchantments() != null && !item.getEnchantments().isEmpty()) {
final Map<Enchantment, Integer> enchants = (Map<Enchantment, Integer>)item.getEnchantments();
try {
for (final String enchant : this.config.getStringList("Enchant-Limiter")) {
final String[] parse = enchant.split(":");
final Enchantment enchantment = Enchantment.getByName(parse[0]);
final int level = Integer.parseInt(parse[1]);
if (enchants.containsKey(enchantment) && enchants.get(enchantment) > level) {
item.removeEnchantment(enchantment);
if (level <= 0) {
continue;
}
item.addEnchantment(enchantment, level);
}
}
}
catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
}
private void notifyAdmins(final Player player) {
final TextComponent text = new TextComponent(ChatColor.translateAlternateColorCodes('&', "&8[&cALERT&8] &c" + player.getName() + " &ehas an illegal item! &6(&cClick here to TP&6)"));
text.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tp " + player.getName()));
for (Player pls : Bukkit.getOnlinePlayers()){
if (pls.hasPermission("illegal.notify")) {
pls.spigot().sendMessage((BaseComponent)text);
}
}
}
}

View File

@ -0,0 +1,70 @@
package com.igodlik3.modmode;
import com.google.common.collect.Sets;
import net.libhalt.bukkit.kaede.HCFactionPlugin;
import net.libhalt.bukkit.kaede.utils.ConfigurationWrapper;
import net.libhalt.bukkit.kaede.utils.Manager;
import org.bukkit.configuration.Configuration;
import org.bukkit.plugin.java.*;
import com.igodlik3.modmode.manager.*;
import java.util.*;
import org.bukkit.command.*;
import com.igodlik3.modmode.commands.*;
import org.bukkit.event.*;
import com.igodlik3.modmode.listener.*;
import org.bukkit.plugin.*;
public class ModMode extends Manager
{
public static ModMode instance;
private Set<UUID> modToggled = Sets.newHashSet();
private FreezeManager freezeManager;
private ConfigurationWrapper config;
public Configuration getConfig(){
return config.getConfig();
}
public ModMode(HCFactionPlugin plugin) {
super(plugin);
}
public void init() {
config = new ConfigurationWrapper("modmode.yml", this.getPlugin());
config.saveDefault();
(ModMode.instance = this).registerManagers();
this.registerListeners();
this.registerCommands();
}
private void registerCommands() {
this.getPlugin().getCommand("mod").setExecutor((CommandExecutor)new CmdModMode());
this.getPlugin().getCommand("freeze").setExecutor((CommandExecutor)new CmdFreeze());
this.getPlugin().getCommand("staffchat").setExecutor((CommandExecutor)new CmdStaffChat());
}
private void registerListeners() {
final PluginManager pm = this.getPlugin().getServer().getPluginManager();
pm.registerEvents((Listener)new ItemListener(this.getPlugin()), this.getPlugin());
pm.registerEvents((Listener)new ModListener(), this.getPlugin());
pm.registerEvents((Listener)new VanishListener(), this.getPlugin());
pm.registerEvents((Listener)new ScoreboardListener(), this.getPlugin());
}
private void registerManagers() {
(this.freezeManager = new FreezeManager()).runTaskTimer(this.getPlugin(), 20L, (long)(20 * this.getConfig().getInt("Mod-Mode.Freeze.message-delay")));
}
public static ModMode getInstance() {
return ModMode.instance;
}
public Set<UUID> getModToggled() {
return this.modToggled;
}
public FreezeManager getFreezeManager() {
return this.freezeManager;
}
}

View File

@ -0,0 +1,34 @@
package com.igodlik3.modmode.commands;
import com.igodlik3.modmode.manager.*;
import com.igodlik3.modmode.*;
import org.bukkit.command.*;
import com.igodlik3.modmode.utils.*;
import org.bukkit.*;
import org.bukkit.entity.*;
public class CmdFreeze implements CommandExecutor
{
private FreezeManager manager;
public CmdFreeze() {
this.manager = ModMode.getInstance().getFreezeManager();
}
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
if (sender.hasPermission("ModMode")) {
if (args.length == 0) {
sender.sendMessage(Utils.color("&c/ss <player>"));
}
else {
final Player target = Bukkit.getPlayer(args[0]);
if (target == null) {
sender.sendMessage(Utils.color("&cThis player is not online or doesn't exist !"));
return true;
}
sender.sendMessage(this.manager.freezePlayer(target));
}
}
return false;
}
}

View File

@ -0,0 +1,59 @@
package com.igodlik3.modmode.commands;
import com.igodlik3.ItemBuilder;
import org.bukkit.configuration.*;
import java.util.*;
import com.igodlik3.modmode.*;
import org.bukkit.command.*;
import org.bukkit.entity.*;
import org.bukkit.inventory.*;
import org.bukkit.*;
import com.igodlik3.modmode.utils.*;
public class CmdModMode implements CommandExecutor
{
private Configuration config;
private Set<UUID> modToggled;
public CmdModMode() {
this.config = (Configuration)ModMode.getInstance().getConfig();
this.modToggled = ModMode.getInstance().getModToggled();
}
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
if (!(sender instanceof Player)) {
return true;
}
final Player player = (Player)sender;
final String e = this.config.getString("Messages.STATUT.enabled");
final String d = this.config.getString("Messages.STATUT.disabled");
if (player.hasPermission("ModMode")) {
if (this.modToggled.contains(player.getUniqueId())) {
this.modToggled.remove(player.getUniqueId());
player.sendMessage(Utils.color(this.config.getString("Messages.MOD-MODE").replaceAll("%STATUT%", d)));
player.getInventory().clear();
}
else {
this.modToggled.add(player.getUniqueId());
player.sendMessage(Utils.color(this.config.getString("Messages.MOD-MODE").replaceAll("%STATUT%", e)));
this.getModItems(player);
}
}
return false;
}
private void getModItems(final Player player) {
player.setAllowFlight(true);
player.setFlying(true);
player.setFlySpeed(0.5f);
player.getInventory().clear();
player.getInventory().setArmorContents((ItemStack[])null);
player.getInventory().setItem(0, new ItemBuilder(Material.COMPASS).displayname(this.config.getString("Messages.MOD-ITEMS.COMPASS")).build());
player.getInventory().setItem(1, new ItemBuilder(Material.WOOD_AXE).displayname(this.config.getString("Messages.MOD-ITEMS.AXE")).build());
player.getInventory().setItem(2, new ItemBuilder(Material.EYE_OF_ENDER).displayname(this.config.getString("Messages.MOD-ITEMS.RANDOM-TP")).build());
player.getInventory().setItem(5, new ItemBuilder(Material.CHEST).displayname(this.config.getString("Messages.MOD-ITEMS.CHEST")).build());
player.getInventory().setItem(6, new ItemBuilder(Material.INK_SACK).durability((short)1).displayname(this.config.getString("Messages.MOD-ITEMS.VANISH").replaceAll("%STATUT%", "&cOFF")).build());
player.getInventory().setItem(7, new ItemBuilder(Material.BLAZE_ROD).displayname(this.config.getString("Messages.MOD-ITEMS.FREEZE.ITEMS")).build());
player.getInventory().setItem(8, new ItemBuilder(Material.BOOK).displayname(this.config.getString("Messages.MOD-ITEMS.INSPECTION")).build());
}
}

View File

@ -0,0 +1,41 @@
package com.igodlik3.modmode.commands;
import org.bukkit.configuration.*;
import com.igodlik3.modmode.*;
import org.bukkit.command.*;
import org.bukkit.entity.*;
import com.igodlik3.modmode.utils.*;
import org.bukkit.*;
public class CmdStaffChat implements CommandExecutor
{
private Configuration config;
public CmdStaffChat() {
this.config = (Configuration)ModMode.getInstance().getConfig();
}
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
if (!(sender instanceof Player)) {
return true;
}
final Player player = (Player)sender;
if (player.hasPermission("ModMode.StaffChat")) {
if (args.length == 0) {
player.sendMessage(Utils.color("&c/sc <message>"));
}
else {
final StringBuilder message = new StringBuilder();
for (int i = 0; i < args.length; ++i) {
message.append(String.valueOf(args[i]) + " ");
}
for (Player pls : Bukkit.getOnlinePlayers()){
if (pls.hasPermission("ModMode.StaffChat")) {
pls.sendMessage(Utils.color(this.config.getString("Mod-Mode.Staff-Chat.format").replaceAll("%PLAYER%", player.getName()).replaceAll("%MESSAGE%", message.toString())));
}
}
}
}
return true;
}
}

View File

@ -0,0 +1,74 @@
package com.igodlik3.modmode.event;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.event.*;
import org.bukkit.entity.*;
import java.util.*;
import org.bukkit.*;
public class VanishEvent extends Event
{
private static final HandlerList handlers;
public static Set<Player> vanished;
private Player p;
static {
handlers = new HandlerList();
VanishEvent.vanished = new HashSet<Player>();
}
public VanishEvent(final Player player, final boolean on) {
this.p = player;
if (on) {
this.setVanish();
}
else {
this.unVanish();
}
}
public void setVanish() {
VanishEvent.vanished.add(this.p);
/*
Player[] onlinePlayers;
for (int length = (onlinePlayers = Bukkit.getOnlinePlayers().toArray(new Player[0])).length, i = 0; i < length; ++i) {
final Player player = onlinePlayers[i];
if (!player.hasPermission("ModMode.Vanish")) {
player.hidePlayer(this.p);
}
}*/
((CraftPlayer)p).setHidden(true);
}
public void unVanish() {
VanishEvent.vanished.remove(this.p);
/*
Player[] onlinePlayers;
for (int length = (onlinePlayers = Bukkit.getOnlinePlayers().toArray(new Player[0])).length, i = 0; i < length; ++i) {
final Player player = onlinePlayers[i];
player.showPlayer(this.p);
}
*/
((CraftPlayer)p).setHidden(false);
}
public boolean isVanish() {
return VanishEvent.vanished.contains(this.p);
}
public String getVanishedPlayers() {
return VanishEvent.vanished.toString();
}
public Player getPlayer() {
return this.p;
}
public HandlerList getHandlers() {
return VanishEvent.handlers;
}
public static HandlerList getHandlerList() {
return VanishEvent.handlers;
}
}

View File

@ -0,0 +1,207 @@
package com.igodlik3.modmode.listener;
import com.igodlik3.ItemBuilder;
import com.igodlik3.subclaims.FactionsUtils;
import net.libhalt.bukkit.kaede.HCFactionPlugin;
import net.syuu.common.utils.PlayerUtils;
import net.syuu.popura.faction.FactionType;
import org.bukkit.configuration.*;
import com.igodlik3.modmode.manager.*;
import com.igodlik3.modmode.*;
import org.bukkit.event.player.*;
import org.bukkit.event.block.*;
import java.util.*;
import org.bukkit.entity.*;
import com.igodlik3.modmode.event.*;
import org.bukkit.event.*;
import com.igodlik3.modmode.utils.*;
import org.bukkit.inventory.meta.*;
import org.bukkit.inventory.*;
import org.bukkit.event.inventory.*;
import org.bukkit.*;
public class ItemListener implements Listener
{
private Configuration config;
private FreezeManager manager;
private HCFactionPlugin plugin;
public ItemListener(HCFactionPlugin instance) {
this.config = (Configuration)ModMode.getInstance().getConfig();
this.manager = ModMode.getInstance().getFreezeManager();
this.plugin = instance;
}
@EventHandler
public void onEntityInteract(final PlayerInteractEntityEvent event) {
if (event.getRightClicked() instanceof Player) {
final Player target = (Player)event.getRightClicked();
final Player player = event.getPlayer();
if (player.getItemInHand() != null && player.getItemInHand().getType() != Material.AIR) {
final ItemStack item = player.getItemInHand();
if (item.getType() == Material.BOOK && item.hasItemMeta() && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equalsIgnoreCase(Utils.color(this.config.getString("Messages.MOD-ITEMS.INSPECTION")))) {
if (this.isMod(player)) {
player.performCommand("invsee " + target.getName());
player.sendMessage(Utils.color(this.config.getString("Messages.MOD-ITEMS.OPENING-INVENTORY").replaceAll("%TARGET%", target.getName())));
}
else {
player.setItemInHand(null);
PlayerUtils.updateInventory(player);
//player.sendMessage(Utils.color(this.config.getString("Messages.MOD-ITEMS.MODE-NOT-TOGGLED")));
}
}
else if (item.getType() == Material.BLAZE_ROD && item.hasItemMeta() && item.getItemMeta().hasDisplayName() && item.getItemMeta().getDisplayName().equalsIgnoreCase(Utils.color(this.config.getString("Messages.MOD-ITEMS.FREEZE.ITEMS")))) {
if (this.isMod(player)) {
player.sendMessage(this.manager.freezePlayer(target));
}
else {
player.setItemInHand(null);
PlayerUtils.updateInventory(player);
//player.sendMessage(Utils.color(this.config.getString("Messages.MOD-ITEMS.MODE-NOT-TOGGLED")));
}
}
}
}
}
public Player getCorrectPlayer(Player moderator){
for(Player p : Bukkit.getOnlinePlayers()){
if(!p.equals(moderator)) {
if(FactionsUtils.getFactionAt(p.getLocation()) == null){
return p;
}
String name = FactionsUtils.getFactionAt(p.getLocation()).getName();
if(!name.equals("Spawn")){
return p;
}
}
}
return null;
}
public Player getRandomPlayer(Player moderator) {
final Random r = new Random();
final Player[] pls = Bukkit.getOnlinePlayers().toArray(new Player[0]);
Player target = pls[r.nextInt(pls.length)];
while(target.equals(moderator)){
target = pls[r.nextInt(pls.length)];
}
if(FactionsUtils.getFactionAt(target.getLocation()) != null){
if(FactionsUtils.getFactionAt(target.getLocation()).getName().equals("Spawn")){
target = getCorrectPlayer(moderator);
}
}
return target;
}
@EventHandler
public void onInteract(final PlayerInteractEvent event) {
final Player player = event.getPlayer();
if ((event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) && event.getItem() != null && event.getItem().getType() != Material.AIR) {
final ItemStack item = event.getItem();
if (item.hasItemMeta() && item.getItemMeta().hasDisplayName()) {
switch (item.getType()) {
case EYE_OF_ENDER: {
event.setCancelled(true);
if(this.isMod(player)) {
if(Bukkit.getOnlinePlayers().size() <= 1){
player.sendMessage(plugin.configdata.getConfigMessage("only-one-online").replaceAll("&", "§"));
return;
}
if(getCorrectPlayer(player) == null) {
player.sendMessage(plugin.configdata.getConfigMessage("all-players-in-spawn").replaceAll("&", "§"));
return;
}
final Player target = getRandomPlayer(player);
if (target != player) {
player.teleport((Entity) target);
player.sendMessage(Utils.color(this.config.getString("Messages.MOD-ITEMS.RANDOM-TELEPORTATION").replaceAll("%PLAYER%", target.getName())));
break;
}
}else{
player.setItemInHand(null);
PlayerUtils.updateInventory(player);
}
break;
}
case INK_SACK: {
event.setCancelled(true);
if(this.isMod(player)) {
if (VanishEvent.vanished.contains(player)) {
Bukkit.getPluginManager().callEvent((Event) new VanishEvent(player, false));
player.setItemInHand(new ItemBuilder(Material.INK_SACK).durability((short) 1).displayname(this.config.getString("Messages.MOD-ITEMS.VANISH").replaceAll("%STATUT%", "&cOFF")).build());
break;
}
Bukkit.getPluginManager().callEvent((Event) new VanishEvent(player, true));
player.setItemInHand(new ItemBuilder(Material.INK_SACK).durability((short) 10).displayname(this.config.getString("Messages.MOD-ITEMS.VANISH").replaceAll("%STATUT%", "&aON")).build());
}else{
player.setItemInHand(null);
PlayerUtils.updateInventory(player);
}
break;
}
case CHEST: {
event.setCancelled(true);
if(this.isMod(player)) {
final Inventory inv = Bukkit.createInventory((InventoryHolder) null, 54, Utils.color("&bPlayers under level 16"));
Player[] onlinePlayers;
for (Player p : Bukkit.getOnlinePlayers()) {
if (p.getLocation().getY() <= 16.0) {
final ItemStack is = new ItemBuilder(Material.SKULL_ITEM).durability((short) 3).displayname("&b" + p.getName()).lore("", "&c<><63> &eClick to teleport !").build();
final SkullMeta meta = (SkullMeta) is.getItemMeta();
meta.setOwner(p.getName());
is.setItemMeta((ItemMeta) meta);
inv.addItem(new ItemStack[]{is});
}
}
player.openInventory(inv);
}else{
player.setItemInHand(null);
PlayerUtils.updateInventory(player);
}
break;
}
}
}
}
}
@EventHandler
public void onInventoryClick(final InventoryClickEvent event) {
final Inventory inv = event.getInventory();
final Player player = (Player)event.getWhoClicked();
if (inv != null && inv.getName() != null && inv.getName().contains("level 16")) {
event.setCancelled(true);
if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) {
final ItemStack item = event.getCurrentItem();
if (event.getClickedInventory() == player.getOpenInventory().getTopInventory() && item.getType() == Material.SKULL_ITEM) {
player.closeInventory();
final Player pls = Bukkit.getPlayer(ChatColor.stripColor(item.getItemMeta().getDisplayName()));
if (pls == null) {
player.sendMessage(Utils.color(this.config.getString("Messages.MOD-ITEMS.GUI.NOT-ONLINE")));
return;
}
player.teleport((Entity)pls);
player.sendMessage(Utils.color(this.config.getString("Messages.MOD-ITEMS.GUI.TELEPORTATION").replaceAll("%PLAYER%", pls.getName())));
}
}
}
}
private boolean isMod(final Player player) {
return player.hasPermission("ModMode") && ModMode.getInstance().getModToggled().contains(player.getUniqueId());
}
}

View File

@ -0,0 +1,156 @@
package com.igodlik3.modmode.listener;
import org.bukkit.configuration.*;
import com.igodlik3.modmode.manager.*;
import com.igodlik3.modmode.*;
import com.igodlik3.modmode.utils.*;
import org.bukkit.command.*;
import java.util.*;
import org.bukkit.event.*;
import org.bukkit.event.inventory.*;
import org.bukkit.event.block.*;
import org.bukkit.event.player.*;
import org.bukkit.*;
import org.bukkit.event.entity.*;
import org.bukkit.entity.*;
import org.bukkit.projectiles.*;
import org.bukkit.scheduler.BukkitTask;
public class ModListener implements Listener
{
private Configuration config;
private FreezeManager manager;
public ModListener() {
this.config = (Configuration)ModMode.getInstance().getConfig();
this.manager = ModMode.getInstance().getFreezeManager();
}
@EventHandler
public void onPlayerJoin(final PlayerJoinEvent event) {
final Player player = event.getPlayer();
if (this.config.getBoolean("Mod-Mode.Staff-LeaveJoin-Message") && player.hasPermission("ModMode")) {
for(Player pls : Bukkit.getOnlinePlayers()){
if (pls.hasPermission("ModMode")) {
pls.sendMessage(Utils.color(this.config.getString("Messages.STAFF-JOIN").replaceAll("%PLAYER%", player.getName())));
}
}
}
if (this.config.getBoolean("Mod-Mode.Toggle-ModMode-OnJoin")) {
player.performCommand("mod");
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerQuit(final PlayerQuitEvent event) {
final Player player = event.getPlayer();
if (this.config.getBoolean("Mod-Mode.Staff-LeaveJoin-Message") && player.hasPermission("Xeor.ModMode")) {
for(Player pls : Bukkit.getOnlinePlayers()){
if (pls.hasPermission("Xeor.ModMode")) {
pls.sendMessage(Utils.color(this.config.getString("Messages.STAFF-LEAVE").replaceAll("%PLAYER%", player.getName())));
}
}
}
if (this.manager.isFrozen(player) && this.config.getBoolean("Mod-Mode.Freeze.execute-cmd-on-disconnect")) {
for (final String stg : this.config.getStringList("Mod-Mode.Freeze.cmds")) {
Bukkit.dispatchCommand((CommandSender)Bukkit.getConsoleSender(), stg.replaceAll("%PLAYER%", player.getName()));
}
}
}
@EventHandler
public void onInventoryClick(final InventoryClickEvent event) {
final Player player = (Player)event.getWhoClicked();
if (this.isMod(player) && event.getClickedInventory() != null) {
if (event.getClickedInventory().equals(player.getOpenInventory().getBottomInventory())) {
event.setCancelled(true);
}
else if (this.config.getBoolean("Mod-Mode.Block-InventoryMove.Others-Inventory")) {
event.setCancelled(true);
}
}
}
@EventHandler
public void onBlockPlace(final FoodLevelChangeEvent event) {
final Player player = (Player) event.getEntity();
if (this.isMod(player)) {
event.setFoodLevel(20);
}
}
@EventHandler
public void onBlockPlace(final BlockPlaceEvent event) {
final Player player = event.getPlayer();
if (this.isMod(player) && !event.isCancelled() && this.config.getBoolean("Mod-Mode.Block-Place")) {
event.setCancelled(true);
}
}
@EventHandler
public void onBlockBreak(final BlockBreakEvent event) {
final Player player = event.getPlayer();
if (this.isMod(player) && !event.isCancelled() && this.config.getBoolean("Mod-Mode.Block-Break")) {
event.setCancelled(true);
}
}
@EventHandler
public void onItemDrop(final PlayerDropItemEvent event) {
final Player player = event.getPlayer();
if (this.isMod(player) && this.config.getBoolean("Mod-Mode.Block-ItemDrop")) {
event.setCancelled(true);
}
}
@EventHandler
public void onItemDrop(final PlayerPickupItemEvent event) {
final Player player = event.getPlayer();
if (this.isMod(player) && this.config.getBoolean("Mod-Mode.Block-PickUp")) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerMove(final PlayerMoveEvent event) {
final Player player = event.getPlayer();
final Location to = event.getTo();
final Location from = event.getFrom();
if (this.manager.isFrozen(player) && (to.getBlockX() != from.getBlockX() || to.getBlockZ() != from.getBlockZ())) {
event.setTo(from);
}
}
@EventHandler
public void onEntityDamage(final EntityDamageByEntityEvent event) {
if (event.isCancelled() || !(event.getEntity() instanceof Player)) {
return;
}
final Player damaged = (Player)event.getEntity();
Entity eDamager = event.getDamager();
if (eDamager instanceof Projectile) {
final ProjectileSource projectileSource = (ProjectileSource)((Projectile)eDamager).getShooter();
if (projectileSource instanceof Player) {
eDamager = (Entity)projectileSource;
}
}
if (!(eDamager instanceof Player)) {
return;
}
final Player damager = (Player)eDamager;
if (damager == damaged) {
return;
}
if (this.manager.isFrozen(damager)) {
event.setCancelled(true);
damager.sendMessage(Utils.color("&cYou can't pvp whilst you're frozen !"));
return;
}
if (this.manager.isFrozen(damaged)) {
event.setCancelled(true);
damager.sendMessage(Utils.color("&cThis player is frozen !"));
}
}
private boolean isMod(final Player player) {
return player.hasPermission("ModMode") && ModMode.getInstance().getModToggled().contains(player.getUniqueId());
}
}

View File

@ -0,0 +1,48 @@
package com.igodlik3.modmode.listener;
import net.libhalt.bukkit.kaede.event.*;
import com.igodlik3.modmode.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
import com.igodlik3.modmode.event.*;
import org.bukkit.*;
public class ScoreboardListener implements Listener
{
private String[] placeholders;
public ScoreboardListener() {
this.placeholders = new String[] { "%VANISH%", "%GAMEMODE%", "%ONLINE%" };
}
@EventHandler
public void onScoreboardUpdate(final ScoreboardTextAboutToUpdateEvent event) {
final Player player = event.getPlayer();
String[] placeholders;
for (int length = (placeholders = this.placeholders).length, i = 0; i < length; ++i) {
final String placeholder = placeholders[i];
if (event.getText() != null && event.getText().contains(placeholder)) {
if (ModMode.getInstance().getModToggled().contains(player.getUniqueId())) {
event.setText(this.convertPlaceholder(event.getText(), player));
}
else {
event.setText((String)null);
}
}
}
}
@SuppressWarnings("deprecation")
private String convertPlaceholder(String text, final Player player) {
if (text.contains("%VANISH%")) {
text = text.replaceAll("%VANISH%", VanishEvent.vanished.contains(player) ? "&aON" : "&cOFF");
}
if (text.contains("GAMEMODE%")) {
text = text.replaceAll("%GAMEMODE%", (player.getGameMode() == GameMode.CREATIVE) ? "&aCreative" : "&cSurvival");
}
if (text.contains("%ONLINE%")) {
text = text.replaceAll("%ONLINE%", "&a" + Bukkit.getOnlinePlayers().size() + "&7/&a" + Bukkit.getMaxPlayers());
}
return text;
}
}

View File

@ -0,0 +1,57 @@
package com.igodlik3.modmode.listener;
import org.bukkit.configuration.*;
import com.igodlik3.modmode.*;
import com.igodlik3.modmode.event.*;
import com.igodlik3.modmode.utils.*;
import org.bukkit.potion.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
import org.bukkit.*;
import org.bukkit.event.player.*;
public class VanishListener implements Listener
{
private Configuration config;
public VanishListener() {
this.config = (Configuration)ModMode.getInstance().getConfig();
}
@EventHandler
public void onVanishEvent(final VanishEvent event) {
final Player player = event.getPlayer();
final String e = this.config.getString("Messages.STATUT.enabled");
final String d = this.config.getString("Messages.STATUT.disabled");
if (event.isVanish()) {
player.sendMessage(Utils.color(this.config.getString("Messages.VANISH").replaceAll("%STATUT%", e)));
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 3));
}
else {
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
player.sendMessage(Utils.color(this.config.getString("Messages.VANISH").replaceAll("%STATUT%", d)));
}
}
@EventHandler
public void onPlayerJoin(final PlayerJoinEvent event) {
/*
final Player player = event.getPlayer();
Player[] onlinePlayers;
for (int length = (onlinePlayers = Bukkit.getOnlinePlayers().toArray(new Player[0])).length, i = 0; i < length; ++i) {
final Player pls = onlinePlayers[i];
if (VanishEvent.vanished.contains(pls) && !player.hasPermission("ModMode.Vanish")) {
player.hidePlayer(pls);
}
}
*/
}
@EventHandler
public void onPickUp(final PlayerPickupItemEvent event) {
final Player player = event.getPlayer();
if (VanishEvent.vanished.contains(player)) {
event.setCancelled(true);
}
}
}

View File

@ -0,0 +1,60 @@
package com.igodlik3.modmode.manager;
import org.bukkit.scheduler.*;
import org.bukkit.configuration.*;
import com.igodlik3.modmode.*;
import org.bukkit.entity.*;
import com.igodlik3.modmode.utils.*;
import org.bukkit.*;
import java.util.*;
public class FreezeManager extends BukkitRunnable
{
private Set<UUID> frozenPlayers;
private Configuration config;
public FreezeManager() {
this.frozenPlayers = new HashSet<UUID>();
this.config = (Configuration)ModMode.getInstance().getConfig();
}
public boolean isFrozen(final Player player) {
return this.frozenPlayers.contains(player.getUniqueId());
}
public String freezePlayer(final Player player) {
if (this.isFrozen(player)) {
this.getFrozenPlayers().remove(player.getUniqueId());
return Utils.color(this.config.getString("Messages.UN-FROZEN").replaceAll("%PLAYER%", player.getName()));
}
this.getFrozenPlayers().add(player.getUniqueId());
return Utils.color(this.config.getString("Messages.FROZEN").replaceAll("%PLAYER%", player.getName()));
}
public void run() {
for (final UUID uuid : this.frozenPlayers) {
final Player player = Bukkit.getPlayer(uuid);
if (player != null) {
final String Line1 = Utils.color(this.config.getString("Messages.MOD-ITEMS.FREEZE.MESSAGE.1"));
final String Line2 = Utils.color(this.config.getString("Messages.MOD-ITEMS.FREEZE.MESSAGE.2"));
final String Line3 = Utils.color(this.config.getString("Messages.MOD-ITEMS.FREEZE.MESSAGE.3"));
final String Line4 = Utils.color(this.config.getString("Messages.MOD-ITEMS.FREEZE.MESSAGE.4"));
final String Line5 = Utils.color(this.config.getString("Messages.MOD-ITEMS.FREEZE.MESSAGE.5"));
player.sendMessage(ChatColor.WHITE + "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 " + Line1);
player.sendMessage(ChatColor.WHITE + "\u2588\u2588\u2588\u2588" + ChatColor.RED + "\u2588" + ChatColor.WHITE + "\u2588\u2588\u2588\u2588");
player.sendMessage(ChatColor.WHITE + "\u2588\u2588\u2588" + ChatColor.RED + "\u2588" + ChatColor.GOLD + ChatColor.BLACK + "\u2588" + ChatColor.GOLD + ChatColor.RED + "\u2588" + ChatColor.WHITE + "\u2588\u2588\u2588 " + Line2);
player.sendMessage(ChatColor.WHITE + "\u2588\u2588" + ChatColor.RED + "\u2588" + ChatColor.GOLD + "\u2588" + ChatColor.BLACK + "\u2588" + ChatColor.GOLD + "\u2588" + ChatColor.RED + "\u2588" + ChatColor.WHITE + "\u2588\u2588 " + Line3);
player.sendMessage(ChatColor.WHITE + "\u2588\u2588" + ChatColor.RED + "\u2588" + ChatColor.GOLD + "\u2588" + ChatColor.BLACK + "\u2588" + ChatColor.GOLD + "\u2588" + ChatColor.RED + "\u2588" + ChatColor.WHITE + "\u2588\u2588 " + Line4);
player.sendMessage(ChatColor.WHITE + "\u2588\u2588" + ChatColor.RED + "\u2588" + ChatColor.GOLD + "\u2588" + ChatColor.BLACK + "\u2588" + ChatColor.GOLD + "\u2588" + ChatColor.RED + "\u2588" + ChatColor.WHITE + "\u2588\u2588 " + Line5);
player.sendMessage(ChatColor.WHITE + "\u2588" + ChatColor.RED + "\u2588" + ChatColor.GOLD + "\u2588\u2588\u2588" + ChatColor.BLACK + ChatColor.GOLD + "\u2588\u2588" + ChatColor.RED + "\u2588" + ChatColor.WHITE + "\u2588 ");
player.sendMessage(ChatColor.RED + "\u2588" + ChatColor.GOLD + "\u2588\u2588\u2588" + ChatColor.BLACK + "\u2588" + ChatColor.GOLD + "\u2588\u2588\u2588" + ChatColor.RED + "\u2588" + ChatColor.WHITE);
player.sendMessage(ChatColor.RED + "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588");
player.sendMessage(ChatColor.WHITE + "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588");
}
}
}
public Set<UUID> getFrozenPlayers() {
return this.frozenPlayers;
}
}

View File

@ -0,0 +1,26 @@
package com.igodlik3.modmode.utils;
import org.bukkit.*;
public class Utils
{
public static String color(final String stg) {
return ChatColor.translateAlternateColorCodes('&', stg);
}
public static String stringifyLocation(final Location location) {
return "[" + location.getWorld().getName() + "," + location.getX() + "," + location.getY() + "," + location.getZ() + "]";
}
public static Location destringifyLocation(final String string) {
final String[] split = string.substring(1, string.length() - 2).split(",");
final World world = Bukkit.getWorld(split[0]);
if (world == null) {
return null;
}
final double x = Double.parseDouble(split[1]);
final double y = Double.parseDouble(split[2]);
final double z = Double.parseDouble(split[3]);
return new Location(world, x, y, z);
}
}

View File

@ -0,0 +1,16 @@
package com.igodlik3.stats;
import org.bukkit.event.inventory.*;
import org.bukkit.inventory.*;
import org.bukkit.event.*;
public class GUIListener implements Listener
{
@EventHandler
public void onInventoryClick(final InventoryClickEvent event) {
final Inventory inv = event.getInventory();
if (inv != null && inv.getName() != null && inv.getName().contains("Stats")) {
event.setCancelled(true);
}
}
}

View File

@ -0,0 +1,40 @@
package com.igodlik3.stats;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandExecutor;
import org.bukkit.event.Listener;
import org.bukkit.plugin.RegisteredServiceProvider;
import net.libhalt.bukkit.kaede.HCFactionPlugin;
import net.libhalt.bukkit.kaede.utils.Manager;
import net.milkbowl.vault.permission.Permission;
public class Stats extends Manager
{
private Permission perms;
private static Stats instance;
public Stats(HCFactionPlugin plugin) {
super(plugin);
}
public void init() {
(Stats.instance = this).setUpPermissions();
this.getPlugin().getCommand("stats").setExecutor((CommandExecutor)new StatsCmd());
Bukkit.getPluginManager().registerEvents((Listener)new GUIListener(), this.getPlugin());
}
private boolean setUpPermissions() {
final RegisteredServiceProvider<Permission> rsp = this.getPlugin().getServer().getServicesManager().getRegistration(Permission.class);
this.perms = (Permission)rsp.getProvider();
return this.perms != null;
}
public Permission getPerms() {
return this.perms;
}
public static Stats getInstance() {
return Stats.instance;
}
}

View File

@ -0,0 +1,74 @@
package com.igodlik3.stats;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Statistic;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import com.igodlik3.ItemBuilder;
import net.syuu.popura.PopuraPlugin;
import net.syuu.popura.faction.bean.FactionPlayer;
public class StatsCmd implements CommandExecutor
{
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("Only players !");
return true;
}
final Player player = (Player)sender;
if (args.length == 0) {
this.openStatsInv(player, player);
}
else {
final Player target = Bukkit.getPlayer(args[0]);
if (target == null) {
player.sendMessage(this.color("&cPlayer not found !"));
}
else {
this.openStatsInv(target, player);
}
}
return true;
}
private double getKDR(final Player player, final int kill, final int mort) {
if (mort == 0 && kill == 0) {
return 0.0;
}
if (mort == 0) {
return kill;
}
return Math.round(kill / mort);
}
private void openStatsInv(final Player player, final Player to) {
final Inventory inv = Bukkit.createInventory((InventoryHolder)null, 45, this.color("&6Stats of &c" + player.getName()));
final FactionPlayer fp = PopuraPlugin.getInstance().getPopura().getFactionDataManager().getPlayer(player);
inv.setItem(0, new ItemBuilder(Material.DIAMOND_SWORD).unsafeStackSize(true).amount((fp.getKill()== 0) ? 1 : fp.getKill()).displayname("&6Kills&8: &c" +fp.getKill()).build());
inv.setItem(1, new ItemBuilder(Material.SKULL_ITEM).unsafeStackSize(true).amount((player.getStatistic(Statistic.DEATHS) == 0) ? 1 : player.getStatistic(Statistic.DEATHS)).displayname("&6Deaths&8: &c" + player.getStatistic(Statistic.DEATHS)).build());
inv.setItem(2, new ItemBuilder(Material.ANVIL).displayname("&6Ratio&8: &c" + this.getKDR(player, player.getStatistic(Statistic.PLAYER_KILLS), player.getStatistic(Statistic.DEATHS))).build());
inv.setItem(9, new ItemBuilder(Material.BLAZE_POWDER).displayname("&4Faction&8: &c" + (fp.getFaction() != null ? fp.getFaction().getName() : "&cNone")).build());
inv.setItem(18, new ItemBuilder(Material.DIAMOND_ORE).unsafeStackSize(true).amount(player.getStatistic(Statistic.MINE_BLOCK, Material.DIAMOND_ORE)).displayname("&6Ores&8: &b" + player.getStatistic(Statistic.MINE_BLOCK, Material.DIAMOND_ORE) + " diamonds(s)").build());
inv.setItem(19, new ItemBuilder(Material.EMERALD_ORE).unsafeStackSize(true).amount(player.getStatistic(Statistic.MINE_BLOCK, Material.EMERALD_ORE)).displayname("&6Ores&8: &a" + player.getStatistic(Statistic.MINE_BLOCK, Material.EMERALD_ORE) + " emerald(s)").build());
inv.setItem(20, new ItemBuilder(Material.GOLD_ORE).unsafeStackSize(true).amount(player.getStatistic(Statistic.MINE_BLOCK, Material.GOLD_ORE)).displayname("&6Ores&8: &e" + player.getStatistic(Statistic.MINE_BLOCK, Material.GOLD_ORE) + " gold(s)").build());
inv.setItem(21, new ItemBuilder(Material.IRON_ORE).unsafeStackSize(true).amount(player.getStatistic(Statistic.MINE_BLOCK, Material.IRON_ORE)).displayname("&6Ores&8: &f" + player.getStatistic(Statistic.MINE_BLOCK, Material.IRON_ORE) + " iron(s)").build());
inv.setItem(22, new ItemBuilder(Material.REDSTONE_ORE).unsafeStackSize(true).amount(player.getStatistic(Statistic.MINE_BLOCK, Material.REDSTONE_ORE)).displayname("&6Ores&8: &f" + player.getStatistic(Statistic.MINE_BLOCK, Material.REDSTONE_ORE) + " redstone(s)").build());
inv.setItem(23, new ItemBuilder(Material.COAL_ORE).unsafeStackSize(true).amount(player.getStatistic(Statistic.MINE_BLOCK, Material.COAL_ORE)).displayname("&6Ores&8: &f" + player.getStatistic(Statistic.MINE_BLOCK, Material.COAL_ORE) + " coal(s)").build());
inv.setItem(24, new ItemBuilder(Material.STONE).unsafeStackSize(true).amount(player.getStatistic(Statistic.MINE_BLOCK, Material.STONE)).displayname("&6Ores&8: &7" + player.getStatistic(Statistic.MINE_BLOCK, Material.STONE) + " stone(s)").build());
inv.setItem(27, new ItemBuilder(Material.EMPTY_MAP).displayname("&6Money&8: &c" + fp.getMoney()).build());
inv.setItem(28, new ItemBuilder(Material.DIAMOND).displayname("&6Rank&8: &f" + Stats.getInstance().getPerms().getPrimaryGroup(player)).build());
to.openInventory(inv);
}
private String color(final String stg) {
return ChatColor.translateAlternateColorCodes('&', stg);
}
}

View File

@ -0,0 +1,37 @@
package com.igodlik3.subclaims;
import net.syuu.popura.PopuraPlugin;
import net.syuu.popura.claim.Position2D;
import net.syuu.popura.faction.bean.ClaimedRegion;
import net.syuu.popura.faction.bean.Faction;
import net.syuu.popura.faction.bean.FactionPlayer;
import org.bukkit.entity.*;
import org.bukkit.*;
import org.bukkit.event.*;
import java.util.*;
public class FactionsUtils
{
public static boolean isInOwnTerritory(final Player player) {
final Location loc = player.getLocation();
return hasFaction(player) && getFactionAt(loc) != null && getFactionAt(loc) == getFaction(player);
}
public static boolean hasFaction(final Player player) {
final FactionPlayer factionPlayer = PopuraPlugin.getInstance().getPopura().getFactionDataManager().getPlayer(player);
return factionPlayer.getFaction() != null;
}
public static Faction getFactionAt(final Location location) {
ClaimedRegion flocation = PopuraPlugin.getInstance().getPopura().getFactionDataManager().getClaimedRegionAt(new Position2D(location.getWorld().getName() , location.getBlockX() , location.getBlockZ()));
return flocation == null ? null : flocation.getOwner();
}
public static Faction getFaction(final Player player) {
final FactionPlayer factionPlayer = PopuraPlugin.getInstance().getPopura().getFactionDataManager().getPlayer(player);
return factionPlayer.getFaction();
}
}

View File

@ -0,0 +1,38 @@
package com.igodlik3.subclaims;
import org.bukkit.configuration.*;
import org.bukkit.command.*;
import org.bukkit.entity.*;
import java.util.*;
import org.bukkit.*;
public class SubclaimCmd implements CommandExecutor
{
private Configuration lang;
public SubclaimCmd() {
this.lang = Subclaims.getInstance().getConfig();
}
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
if (!(sender instanceof Player)) {
return true;
}
final Player player = (Player)sender;
if (args.length == 0) {
for (final String stg : this.lang.getStringList("Messages.Subclaim.INFO")) {
player.sendMessage(this.color(stg));
}
}
else if (args[0].equalsIgnoreCase("credits")) {
sender.sendMessage(this.color("&9Developed by &eiGoDLiK3"));
sender.sendMessage(this.color("&9Founded by &6Salvific"));
sender.sendMessage(this.color("&aWebsite&7: &cMC-Outlet.com"));
}
return true;
}
private String color(final String stg) {
return ChatColor.translateAlternateColorCodes('&', stg);
}
}

View File

@ -0,0 +1,433 @@
package com.igodlik3.subclaims;
import net.syuu.popura.PopuraPlugin;
import net.syuu.popura.faction.FactionRole;
import net.syuu.popura.faction.bean.FactionPlayer;
import org.bukkit.block.Chest;
import org.bukkit.block.Sign;
import org.bukkit.configuration.*;
import org.bukkit.entity.*;
import java.util.*;
import org.bukkit.event.*;
import org.bukkit.event.player.*;
import org.bukkit.event.block.*;
import org.bukkit.block.*;
import org.bukkit.event.inventory.*;
import org.bukkit.inventory.*;
import org.bukkit.material.*;
import org.bukkit.*;
import javax.management.relation.Role;
public class SubclaimListener implements Listener
{
private BlockFace[] FACES;
private Configuration lang;
private String title;
public SubclaimListener() {
this.FACES = new BlockFace[] { BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST, BlockFace.UP };
this.lang = Subclaims.getInstance().getConfig();
this.title = this.color(this.lang.getString("Title"));
}
@EventHandler
public void onSignChange(final SignChangeEvent event) {
final Player player = event.getPlayer();
final Block block = this.getAttachedBlock(event.getBlock());
if (this.isBlockSubclaimable(block)) {
for (final String stg : this.lang.getStringList("Messages.Subclaim.KEY-WORDS")) {
if (event.getLine(0).equalsIgnoreCase(stg)) {
if (FactionsUtils.getFactionAt(block.getLocation()) == null || !FactionsUtils.isInOwnTerritory(player)) {
event.setCancelled(true);
this.removeSubclaim(event.getBlock(), "NO-TERRITORY", player);
}
else if (this.isSubclaim(block)) {
event.setCancelled(true);
this.removeSubclaim(event.getBlock(), "ALREADY-SUBCLAIM", player);
}
else {
final FactionPlayer fplayer = PopuraPlugin.getInstance().getPopura().getFactionDataManager().getPlayer(player);
if (event.isCancelled()) {
continue;
}
if (event.getLine(1).equalsIgnoreCase("Admin") || event.getLine(1).equalsIgnoreCase("Leader")) {
if (!this.isAllowed(fplayer)) {
event.setCancelled(true);
this.removeSubclaim(event.getBlock(), "LEADER", player);
}
else {
player.sendMessage(this.color(this.lang.getString("Messages.Subclaim.CREATED-SUBCLAIM.LEADER")));
event.setLine(0, this.title);
event.setLine(1, "Leader");
}
}
else if (event.getLine(1).equalsIgnoreCase("Officer") || event.getLine(1).equalsIgnoreCase("Mod")) {
if (fplayer.getRole() != FactionRole.OFFICER && fplayer.getRole() != FactionRole.LEADER && fplayer.getRole() != FactionRole.COLEADER) {
event.setCancelled(true);
this.removeSubclaim(event.getBlock(), "OFFICIER", player);
}
else {
player.sendMessage(this.color(this.lang.getString("Messages.Subclaim.CREATED-SUBCLAIM.OFFICIER")));
event.setLine(0, this.title);
event.setLine(1, "Officer");
}
}
else {
player.sendMessage(this.color(this.lang.getString("Messages.Subclaim.CREATED-SUBCLAIM.OWN")));
event.setLine(0, this.title);
boolean anyNames = false;
for (int i = 1; i < event.getLines().length; ++i) {
final String s = event.getLines()[i];
if (s != null && !s.isEmpty()) {
event.setLine(i, s);
if (!anyNames) {
anyNames = true;
}
}
}
if (anyNames) {
continue;
}
event.setLine(1, player.getName());
}
}
}
}
}
}
@EventHandler
public void onBlockBreak(final BlockPlaceEvent event) {
if(event.getBlock().getType() == Material.HOPPER) {
for (BlockFace blockFace : BlockFace.values()) {
Block block = event.getBlock().getRelative(blockFace);
if ( isSubclaim(block)) {
event.getPlayer().sendMessage(ChatColor.RED + "Can not place hoppers here");
return;
}
}
}
}
@EventHandler
public void onBlockBreak(final BlockBreakEvent event) {
final Player player = event.getPlayer();
final Block block = event.getBlock();
final FactionPlayer fplayer = PopuraPlugin.getInstance().getPopura().getFactionDataManager().getPlayer(player);
if (player.hasPermission("SubclaimBypass")) {
return;
}
if (this.isBlockSubclaimable(block)) {
if (this.isSubclaim(block)) {
if (FactionsUtils.getFactionAt(block.getLocation()).isRaidable()) {
event.setCancelled(false);
}
else if (FactionsUtils.getFactionAt(block.getLocation()) != FactionsUtils.getFaction(player)) {
event.setCancelled(true);
}
else if (this.getSign(block).getLine(1).equalsIgnoreCase("Leader")) {
if (fplayer.getRole() != FactionRole.LEADER && fplayer.getRole() != FactionRole.LEADER && fplayer.getRole() != FactionRole.COLEADER && !this.isAllowed(fplayer)) {
player.sendMessage(this.color(this.lang.getString("Messages.Subclaim.DESTROY")));
event.setCancelled(true);
}
else {
event.setCancelled(false);
}
}
else if (this.getSign(block).getLine(1).equalsIgnoreCase("Officer")) {
if (fplayer.getRole() != FactionRole.OFFICER && fplayer.getRole() != FactionRole.LEADER && fplayer.getRole() != FactionRole.COLEADER && !this.isAllowed(fplayer)) {
player.sendMessage(this.color(this.lang.getString("Messages.Subclaim.DESTROY")));
event.setCancelled(true);
}
else {
event.setCancelled(false);
}
}
else if (!this.getSign(block).getLine(1).equalsIgnoreCase(player.getName()) && fplayer.getRole() != FactionRole.LEADER && fplayer.getRole() != FactionRole.COLEADER) {
player.sendMessage(this.color(this.lang.getString("Messages.Subclaim.DESTROY")));
event.setCancelled(true);
}
else {
event.setCancelled(false);
}
}
else if (this.isDoubleChestSubclaim(block) != null) {
final Block doublechest = this.isDoubleChestSubclaim(block);
if (FactionsUtils.getFactionAt(doublechest.getLocation()).isRaidable()) {
event.setCancelled(false);
}
else if (FactionsUtils.getFactionAt(doublechest.getLocation()) != FactionsUtils.getFaction(player)) {
event.setCancelled(true);
}
else if (this.getSign(doublechest).getLine(1).equalsIgnoreCase("Leader")) {
if (fplayer.getRole() != FactionRole.LEADER && fplayer.getRole() != FactionRole.COLEADER && !this.isAllowed(fplayer)) {
player.sendMessage(this.color(this.lang.getString("Messages.Subclaim.DESTROY")));
event.setCancelled(true);
}
else {
event.setCancelled(false);
}
}
else if (this.getSign(doublechest).getLine(1).equalsIgnoreCase("Officer")) {
if (fplayer.getRole() != FactionRole.LEADER && fplayer.getRole() != FactionRole.OFFICER && fplayer.getRole() != FactionRole.COLEADER && !this.isAllowed(fplayer)) {
player.sendMessage(this.color(this.lang.getString("Messages.Subclaim.DESTROY")));
event.setCancelled(true);
}
else {
event.setCancelled(false);
}
}
else {
boolean owner = false;
for (int i = 1; i < this.getSign(doublechest).getLines().length; ++i) {
final String name = this.getSign(doublechest).getLines()[i];
if (name.equalsIgnoreCase(player.getName()) && !owner) {
owner = true;
}
}
if (!owner && !this.isAllowed(fplayer)) {
player.sendMessage(this.color(this.lang.getString("Messages.Subclaim.DESTROY")));
event.setCancelled(true);
}
}
}
}
}
@EventHandler
public void onSignBreakEvent(final BlockBreakEvent event) {
final Player player = event.getPlayer();
final Block block = event.getBlock();
final FactionPlayer fplayer = PopuraPlugin.getInstance().getPopura().getFactionDataManager().getPlayer(player);
if (player.hasPermission("SubclaimBypass")) {
return;
}
if (block.getType() == Material.SIGN || (block.getType() == Material.WALL_SIGN && block.getState() instanceof Sign)) {
final Sign sign = (Sign)block.getState();
if (sign.getLine(0).equalsIgnoreCase(this.color(this.title))) {
if (FactionsUtils.getFactionAt(sign.getLocation()).isRaidable()) {
event.setCancelled(false);
}
else if (!FactionsUtils.getFaction(player).equals(FactionsUtils.getFactionAt(sign.getLocation()))) {
event.setCancelled(true);
}
else if (sign.getLine(1).equalsIgnoreCase("Leader")) {
if (fplayer.getRole() != FactionRole.LEADER && fplayer.getRole() != FactionRole.COLEADER && !this.isAllowed(fplayer)) {
player.sendMessage(this.color(this.lang.getString("Messages.Subclaim.DESTROY")));
event.setCancelled(true);
}
else {
event.setCancelled(false);
}
}
else if (sign.getLine(1).equalsIgnoreCase("Officer")) {
if (fplayer.getRole() != FactionRole.OFFICER && fplayer.getRole() != FactionRole.LEADER && fplayer.getRole() != FactionRole.COLEADER && this.isAllowed(fplayer)) {
player.sendMessage(this.color(this.lang.getString("Messages.Subclaim.DESTROY")));
event.setCancelled(true);
}
else {
event.setCancelled(false);
}
}
else {
boolean owner = false;
for (int i = 1; i < sign.getLines().length; ++i) {
final String name = sign.getLines()[i];
if (name.equalsIgnoreCase(player.getName()) && !owner) {
owner = true;
}
}
if (!owner && !this.isAllowed(fplayer)) {
player.sendMessage(this.color(this.lang.getString("Messages.Subclaim.DESTROY")));
event.setCancelled(true);
}
}
}
}
}
@EventHandler
public void onInteract(final PlayerInteractEvent event) {
final Player player = event.getPlayer();
final Block block = event.getClickedBlock();
final FactionPlayer fplayer = PopuraPlugin.getInstance().getPopura().getFactionDataManager().getPlayer(player);
if (player.hasPermission("SubclaimBypass")) {
return;
}
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && this.isBlockSubclaimable(block)) {
if (this.isSubclaim(block) && getSign(block) != null) {
if (FactionsUtils.getFactionAt(block.getLocation()) == null) {
this.getSign(block).getBlock().breakNaturally();
}
else if (FactionsUtils.getFactionAt(block.getLocation()).isRaidable()) {
event.setCancelled(false);
}
else if (FactionsUtils.getFactionAt(block.getLocation()) != FactionsUtils.getFaction(player)) {
event.setCancelled(true);
}
else if (this.getSign(block).getLine(1).equalsIgnoreCase("Leader")) {
if (fplayer.getRole() != FactionRole.LEADER && fplayer.getRole() != FactionRole.COLEADER&& !this.isAllowed(fplayer)) {
event.setCancelled(true);
player.sendMessage(this.color(this.lang.getString("Messages.Subclaim.OPEN")));
}
else {
event.setCancelled(false);
}
}
else if (this.getSign(block).getLine(1).equalsIgnoreCase("Officer")) {
if (fplayer.getRole() != FactionRole.OFFICER && fplayer.getRole() != FactionRole.LEADER && fplayer.getRole() != FactionRole.COLEADER && !this.isAllowed(fplayer)) {
event.setCancelled(true);
player.sendMessage(this.color(this.lang.getString("Messages.Subclaim.OPEN")));
}
else {
event.setCancelled(false);
}
}
else {
boolean owner = false;
for (int i = 1; i < this.getSign(block).getLines().length; ++i) {
final String name = this.getSign(block).getLines()[i];
if (name.equalsIgnoreCase(player.getName()) && !owner) {
owner = true;
}
}
if (!owner && !this.isAllowed(fplayer)) {
player.sendMessage(this.color(this.lang.getString("Messages.Subclaim.OPEN")));
event.setCancelled(true);
}
}
}
else if (this.isDoubleChestSubclaim(block) != null && getSign(block) != null) {
final Block doublechest = this.isDoubleChestSubclaim(block);
if (FactionsUtils.getFactionAt(doublechest.getLocation()) == null) {
this.getSign(doublechest).getBlock().breakNaturally();
}
else if (FactionsUtils.getFactionAt(doublechest.getLocation()).isRaidable()) {
event.setCancelled(false);
}
else if (FactionsUtils.getFactionAt(doublechest.getLocation()) != FactionsUtils.getFaction(player)) {
event.setCancelled(true);
}
else if (this.getSign(doublechest).getLine(1).equalsIgnoreCase("Leader")) {
if (fplayer.getRole() != FactionRole.COLEADER && fplayer.getRole() != FactionRole.LEADER && !this.isAllowed(fplayer)) {
event.setCancelled(true);
player.sendMessage(this.color(this.lang.getString("Messages.Subclaim.OPEN")));
}
else {
event.setCancelled(false);
}
}
else if (this.getSign(doublechest).getLine(1).equalsIgnoreCase("Officer")) {
if (fplayer.getRole() != FactionRole.OFFICER && fplayer.getRole() != FactionRole.LEADER && fplayer.getRole() != FactionRole.COLEADER && !this.isAllowed(fplayer)) {
event.setCancelled(true);
player.sendMessage(this.color(this.lang.getString("Messages.Subclaim.OPEN")));
}
else {
event.setCancelled(false);
}
}
else {
boolean owner2 = false;
for (int j = 1; j < this.getSign(doublechest).getLines().length; ++j) {
final String name2 = this.getSign(doublechest).getLines()[j];
if (name2.equalsIgnoreCase(player.getName()) && !owner2) {
owner2 = true;
}
}
if (!owner2 && !this.isAllowed(fplayer)) {
player.sendMessage(this.color(this.lang.getString("Messages.Subclaim.OPEN")));
event.setCancelled(true);
}
}
}
}
}
private boolean isAllowed(final FactionPlayer fplayer) {
return (this.lang.getBoolean("FLeader-Bypass") && fplayer.getRole() == FactionRole.LEADER) || (this.lang.getBoolean("FLeader-Bypass") && fplayer.getRole() == FactionRole.COLEADER) || (this.lang.getBoolean("FMod-Bypass") && fplayer.getRole() == FactionRole.OFFICER);
}
private boolean isSubclaim(final Block block) {
for (int i = 0; i < this.FACES.length; ++i) {
final BlockFace blockFaces = this.FACES[i];
if (block.getRelative(blockFaces).getType() == Material.WALL_SIGN && block.getRelative(blockFaces).getState() instanceof Sign) {
final Sign sign = (Sign)block.getRelative(blockFaces).getState();
if (sign.getLine(0).equalsIgnoreCase(this.title)) {
return true;
}
}
}
return false;
}
private Block isDoubleChestSubclaim(final Block block) {
if (this.isBlockSubclaimable(block)) {
for (int i = 0; i < this.FACES.length; ++i) {
final BlockFace blockFaces = this.FACES[i];
if (this.isBlockSubclaimable(block.getRelative(blockFaces))) {
final Block block2 = block.getRelative(blockFaces);
if (this.isSubclaim(block2)) {
return block2;
}
}
}
}
return null;
}
private Sign getSign(final Block block) {
if(block.getState() instanceof Chest){
Chest chest = (Chest) block.getState();
InventoryHolder ih = chest.getInventory().getHolder();
if (ih instanceof DoubleChest){
DoubleChest doubleChest = (DoubleChest) ih;
Chest left = (Chest) doubleChest.getLeftSide();
Chest right = (Chest) doubleChest.getRightSide();
Sign sign = getSign0(left.getBlock());
if(sign == null){
sign = getSign0(right.getBlock());;
}
return sign;
}else{
return getSign0(block);
}
}else{
return getSign0(block);
}
}
private Sign getSign0(final Block block) {
for (int i = 0; i < this.FACES.length; ++i) {
final BlockFace blockFaces = this.FACES[i];
if (block.getRelative(blockFaces).getType() == Material.WALL_SIGN && block.getRelative(blockFaces).getState() instanceof Sign) {
final Sign sign = (Sign)block.getRelative(blockFaces).getState();
if(sign.getBlock().getRelative(((org.bukkit.material.Sign)sign.getData()).getAttachedFace()).equals(block)) {
return sign;
}
}
}
return null;
}
private void removeSubclaim(final Block block, final String path, final Player player) {
player.sendMessage(this.color(this.lang.getString("Messages.Subclaim.INVALID-SUBCLAIM." + path)));
block.breakNaturally();
}
private boolean isBlockSubclaimable(final Block block) {
return block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST;
}
private Block getAttachedBlock(final Block block) {
final MaterialData matData = block.getState().getData();
BlockFace face = BlockFace.DOWN;
if (matData instanceof Attachable) {
face = ((Attachable)matData).getAttachedFace();
}
return block.getRelative(face);
}
private String color(final String stg) {
return ChatColor.translateAlternateColorCodes('&', stg);
}
}

View File

@ -0,0 +1,36 @@
package com.igodlik3.subclaims;
import net.libhalt.bukkit.kaede.HCFactionPlugin;
import net.libhalt.bukkit.kaede.utils.ConfigurationWrapper;
import net.libhalt.bukkit.kaede.utils.Manager;
import org.bukkit.configuration.Configuration;
import org.bukkit.plugin.java.*;
import org.bukkit.*;
import org.bukkit.event.*;
import org.bukkit.plugin.*;
import org.bukkit.command.*;
public class Subclaims extends Manager
{
private static Subclaims instance;
public Subclaims(HCFactionPlugin plugin) {
super(plugin);
}
private ConfigurationWrapper config;
public Configuration getConfig(){
return config.getConfig();
}
public void init() {
config = new ConfigurationWrapper("subclaim.yml", this.getPlugin());
config.saveDefault();
Subclaims.instance = this;
Bukkit.getPluginManager().registerEvents((Listener)new SubclaimListener(), this.getPlugin());
registerCommand("subclaim" , new SubclaimCmd());
}
public static Subclaims getInstance() {
return Subclaims.instance;
}
}

View File

@ -0,0 +1,58 @@
package com.igodlik3.viperfix;
import net.libhalt.bukkit.kaede.HCFactionPlugin;
import net.libhalt.bukkit.kaede.utils.Manager;
import net.syuu.popura.PopuraPlugin;
import net.syuu.popura.claim.Position2D;
import net.syuu.popura.faction.bean.ClaimedRegion;
import net.syuu.popura.faction.bean.Faction;
import net.syuu.popura.faction.bean.FactionPlayer;
import org.bukkit.plugin.java.*;
import org.bukkit.plugin.*;
import org.bukkit.event.entity.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
import org.bukkit.event.player.*;
import org.bukkit.event.block.*;
import org.bukkit.*;
public class ViperFix extends Manager implements Listener
{
public ViperFix(HCFactionPlugin plugin) {
super(plugin);
}
public void init() {
this.getPlugin().getServer().getPluginManager().registerEvents((Listener) this, getPlugin());
}
@EventHandler
public void onEntityDamageEvent(final EntityDamageEvent event) {
final Entity entity = event.getEntity();
if (event.getCause() == EntityDamageEvent.DamageCause.SUFFOCATION && entity instanceof Player) {
final Player player = (Player)entity;
final Location loc = player.getLocation();
player.teleport(loc);
}
}
@EventHandler
public void onVehiclePlace(final PlayerInteractEvent event) {
final Player player = event.getPlayer();
final FactionPlayer factionPlayer = PopuraPlugin.getInstance().getPopura().getFactionDataManager().getPlayer(player);
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && player.getItemInHand() != null && player.getItemInHand().getType() == Material.MINECART) {
final Location loc = event.getClickedBlock().getLocation();
final ClaimedRegion flo = PopuraPlugin.getInstance().getPopura().getFactionDataManager().getClaimedRegionAt(new Position2D(loc.getWorld().getName() , loc.getBlockX() , loc.getBlockZ()));
if (flo != null) {
final Faction faction = flo.getOwner();
if (factionPlayer.getFaction() == null || factionPlayer.getFaction() != faction) {
player.sendMessage(ChatColor.RED + "You can only place minecart on your territory !");
}
}
else {
event.setCancelled(true);
player.sendMessage(ChatColor.RED + "You can only place minecart on your territory !");
}
}
}
}

View File

@ -0,0 +1,53 @@
package com.igodlik3.vipermisc;
import com.igodlik3.vipermisc.listeners.ScoreboardListener;
import com.igodlik3.vipermisc.sotw.SOTWCmd;
import com.igodlik3.vipermisc.sotw.SOTWListener;
import com.igodlik3.vipermisc.sotw.SOTWManager;
import net.libhalt.bukkit.kaede.HCFactionPlugin;
import net.libhalt.bukkit.kaede.utils.ConfigurationWrapper;
import net.libhalt.bukkit.kaede.utils.Manager;
import org.bukkit.configuration.Configuration;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
/**
* Created by libhalt on 2016/12/06.
*/
public class Misc extends Manager{
public static Misc INSTANCE;
private HCFactionPlugin hcfStuff;
public static Misc getInstance(){
return INSTANCE;
}
public Misc(HCFactionPlugin plugin) {
super(plugin);
INSTANCE = this;
}
private ConfigurationWrapper config;
private SOTWManager sotwManager;
public Configuration getConfig(){
return config.getConfig();
}
public void init() {
hcfStuff = HCFactionPlugin.getInstance();
config = new ConfigurationWrapper("viper-misc.yml", this.getPlugin());
config.saveDefault();
sotwManager = new SOTWManager();
getPlugin().getCommand("sotw").setExecutor(new SOTWCmd());
getPlugin().getServer().getPluginManager().registerEvents((Listener) new ScoreboardListener(), getPlugin());
getPlugin().getServer().getPluginManager().registerEvents((Listener)new SOTWListener(), getPlugin());
}
public SOTWManager getSotwManager() {
return sotwManager;
}
public HCFactionPlugin getHcfStuff() {
return hcfStuff;
}
}

View File

@ -0,0 +1,14 @@
package com.igodlik3.vipermisc;
public interface Timer
{
boolean isActive();
long getLeftTime();
long getTimerEnd();
void setTimerEnd(final long p0);
String toString();
}

View File

@ -0,0 +1,51 @@
package com.igodlik3.vipermisc.listeners;
import com.igodlik3.vipermisc.*;
import com.igodlik3.vipermisc.sotw.*;
import net.libhalt.bukkit.kaede.event.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
import net.libhalt.bukkit.kaede.manager.*;
import net.libhalt.bukkit.kaede.*;
public class ScoreboardListener implements Listener
{
private Misc misc;
private final String DECO_LINE;
private SOTWManager sotwManager;
public ScoreboardListener() {
this.misc = Misc.getInstance();
this.DECO_LINE = Misc.getInstance().getConfig().getString("scoreboard.deco-line");
this.sotwManager = Misc.getInstance().getSotwManager();
}
@EventHandler
public void onScoreboardUpdate(final ScoreboardTextAboutToUpdateEvent event) {
final Player player = event.getPlayer();
if (event.getText() != null) {
if (event.getText().contains("%deco_line%")) {
if (this.shouldDisplayLine(player)) {
event.setText(this.DECO_LINE);
}
else {
event.setText((String)null);
}
}
else if (event.getText().contains("%sotw%")) {
if (this.sotwManager.isSOTWActive()) {
String text2 = event.getText();
text2 = text2.replace("%sotw%", this.sotwManager.getTimer().toString());
event.setText(text2);
}
else {
event.setText((String)null);
}
}
}
}
private boolean shouldDisplayLine(final Player player) {
return true;
}
}

View File

@ -0,0 +1,51 @@
package com.igodlik3.vipermisc.sotw;
import com.igodlik3.vipermisc.*;
import net.libhalt.bukkit.kaede.HCFactionPlugin;
import org.bukkit.command.*;
import com.igodlik3.modmode.utils.*;
import org.bukkit.*;
public class SOTWCmd implements CommandExecutor
{
private SOTWManager sotwManager;
public SOTWCmd() {
this.sotwManager = Misc.getInstance().getSotwManager();
}
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
if (!sender.hasPermission("Viper.SOTW")) {
return true;
}
if (args.length == 0) {
sender.sendMessage(Utils.color("&e/sotw start &7- &6Start the SOTW"));
sender.sendMessage(Utils.color("&e/sotw stop &7- &6Stop the SOTW"));
}
else if (args[0].equalsIgnoreCase("start")) {
if (this.sotwManager.isSOTWActive()) {
String active = HCFactionPlugin.getInstance().messages.getString("sotw-active").replaceAll("&", "§");
sender.sendMessage(active);
return true;
}
if(args.length >= 2) {
this.sotwManager.activeSOTW(Integer.valueOf(args[1]));
}else{
this.sotwManager.activeSOTW();
}
}
else if (args[0].equalsIgnoreCase("stop")) {
if (!this.sotwManager.isSOTWActive()) {
String inactive = HCFactionPlugin.getInstance().messages.getString("sotw-inactive").replaceAll("&", "§");
sender.sendMessage(inactive);
return true;
}
String stopped = HCFactionPlugin.getInstance().messages.getString("sotw-stopped").replaceAll("&", "§");
this.sotwManager.getTimer().setTimerEnd(0L);
Bukkit.broadcastMessage(stopped);
}
return true;
}
}

View File

@ -0,0 +1,55 @@
package com.igodlik3.vipermisc.sotw;
import com.igodlik3.vipermisc.*;
import org.bukkit.entity.*;
import net.libhalt.bukkit.kaede.*;
import org.bukkit.event.*;
import org.bukkit.event.player.*;
import org.bukkit.event.entity.*;
import org.bukkit.scheduler.BukkitRunnable;
public class SOTWListener implements Listener
{
private Misc misc;
private SOTWManager sotwManager;
public SOTWListener() {
this.misc = Misc.getInstance();
this.sotwManager = this.misc.getSotwManager();
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerJoin(final PlayerJoinEvent event) {
if (!this.sotwManager.isSOTWActive()) {
return;
}
final Player player = event.getPlayer();
final PlayerData data = misc.getHcfStuff().getPlayerDataManager().getPlayerData(player);
if (data != null && data.getPvpTime() > 0) {
data.setPvpTime(0);
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerRespawn(final PlayerRespawnEvent event) {
if (!this.sotwManager.isSOTWActive()) {
return;
}
final Player player = event.getPlayer();
final PlayerData data = this.misc.getHcfStuff().getPlayerDataManager().getPlayerData(player);
if (data.getPvpTime() > 0) {
data.setPvpTime(0);
}
}
@EventHandler
public void onEntityDamage(final EntityDamageEvent event) {
if (event.isCancelled() || !(event.getEntity() instanceof Player) || !this.sotwManager.isSOTWActive()) {
return;
}
if (event.getCause() != EntityDamageEvent.DamageCause.VOID) {
event.setCancelled(true);
}
}
}

View File

@ -0,0 +1,42 @@
package com.igodlik3.vipermisc.sotw;
import org.bukkit.*;
import com.igodlik3.vipermisc.*;
import com.igodlik3.vipermisc.utils.*;
import org.bukkit.entity.*;
import net.libhalt.bukkit.kaede.*;
public class SOTWManager
{
private SOTWTimer timer;
private HCFactionPlugin core;
public SOTWManager() {
this.timer = new SOTWTimer();
this.core = HCFactionPlugin.getInstance();
}
public boolean isSOTWActive() {
return this.timer.isActive();
}
public void activeSOTW() {
activeSOTW(Misc.getInstance().getConfig().getInt("sotw-defaultTime"));
}
public void activeSOTW(int value) {
for (Player player : Bukkit.getOnlinePlayers()){
final PlayerData data = this.core.getPlayerDataManager().getPlayerData(player);
if (data.getPvpTime() > 0) {
data.setPvpTime(0);
}
}
this.timer.setTimerEnd(System.currentTimeMillis() + 1000 * value);
String started = HCFactionPlugin.getInstance().messages.getString("sotw-started").replaceAll("&", "§");
Bukkit.broadcastMessage(started);
}
public SOTWTimer getTimer() {
return this.timer;
}
}

View File

@ -0,0 +1,38 @@
package com.igodlik3.vipermisc.sotw;
import com.igodlik3.vipermisc.*;
public class SOTWTimer implements Timer
{
private long timerEnd;
@Override
public boolean isActive() {
return this.getTimerEnd() > System.currentTimeMillis();
}
@Override
public long getLeftTime() {
return this.getTimerEnd() - System.currentTimeMillis();
}
@Override
public long getTimerEnd() {
return this.timerEnd;
}
@Override
public void setTimerEnd(final long timerEnd) {
this.timerEnd = timerEnd;
}
@Override
public String toString() {
final long left = this.getLeftTime();
final long totalSecs = left / 1000L;
if (totalSecs >= 3600L) {
return String.format("%02d:%02d:%02d", totalSecs / 3600L, totalSecs % 3600L / 60L, totalSecs % 60L);
}
return String.format("%02d:%02d", totalSecs / 60L, totalSecs % 60L);
}
}

View File

@ -0,0 +1,10 @@
package com.igodlik3.vipermisc.utils;
import org.bukkit.*;
public class Utils
{
public static String color(final String message) {
return ChatColor.translateAlternateColorCodes('&', message);
}
}

View File

@ -0,0 +1,31 @@
package com.igodlik3.viperutils;
import org.bukkit.configuration.*;
import org.bukkit.event.entity.*;
import org.bukkit.entity.*;
import org.bukkit.*;
import org.bukkit.enchantments.*;
import org.bukkit.inventory.*;
import org.bukkit.event.*;
public class BoostXPListener implements Listener
{
private Configuration config;
public BoostXPListener() {
this.config = (Configuration)ViperUtils.getInstance().getConfig();
}
@EventHandler
public void onEntityDeath(final EntityDeathEvent event) {
if (event.getEntity().getKiller() != null && event.getEntity().getKiller() instanceof Player) {
final Player player = event.getEntity().getKiller();
if (player.getItemInHand() != null && player.getItemInHand().getType() != Material.AIR) {
final ItemStack item = player.getItemInHand();
if (item.containsEnchantment(Enchantment.LOOT_BONUS_MOBS)) {
event.setDroppedExp(event.getDroppedExp() * (item.getEnchantmentLevel(Enchantment.LOOT_BONUS_MOBS) + this.config.getInt("XPBonus-Multiplier")));
}
}
}
}
}

View File

@ -0,0 +1,20 @@
package com.igodlik3.viperutils;
import org.bukkit.command.*;
import org.bukkit.*;
public class CmdCredits implements CommandExecutor
{
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
if (args.length > 0 && args[0].equalsIgnoreCase("credits")) {
sender.sendMessage(this.color("&9Developed by &eiGoDLiK3"));
sender.sendMessage(this.color("&9Founded by &6Salvific"));
sender.sendMessage(this.color("&aWebsite&7: &cMC-Outlet.com"));
}
return true;
}
private String color(final String stg) {
return ChatColor.translateAlternateColorCodes('&', stg);
}
}

View File

@ -0,0 +1,46 @@
package com.igodlik3.viperutils;
import net.syuu.common.command.*;
import net.syuu.common.command.condition.PermissionCondition;
import net.syuu.popura.PopuraPlugin;
import net.syuu.popura.faction.FactionDataManager;
import net.syuu.popura.faction.bean.Faction;
import org.bukkit.configuration.*;
import org.bukkit.entity.*;
import org.bukkit.command.*;
import org.bukkit.*;
public class CmdMuteFaction extends net.syuu.common.command.Command
{
private Configuration config;
public CmdMuteFaction() {
super("mute");
this.config = (Configuration)ViperUtils.getInstance().getConfig();
addCondition(new PermissionCondition("factions.mute"));
}
public void proccess(final Player player, final String[] args) {
final FactionDataManager factionDataManager = ((PopuraPlugin)PopuraPlugin.getPlugin(PopuraPlugin.class)).getPopura().getFactionDataManager();
Faction faction = factionDataManager.getPlayer(player).getFaction();
if(args.length > 0){
faction = factionDataManager.getFaction(args[0]);
}
if (faction == null) {
return;
}
final String time = args[1];
final String reason = args[2];
for (final Player bukkitPlayer : faction.getOnlineMembers()) {
Bukkit.dispatchCommand((CommandSender)Bukkit.getConsoleSender(), this.config.getString("mute-cmd").replaceAll("%TIME%", time).replaceAll("%PLAYER%", bukkitPlayer.getName()).replaceAll("%REASON%", reason));
}
if (this.config.getBoolean("Broadcast.enabled")) {
Bukkit.broadcastMessage(this.color(this.config.getString("Broadcast.message").replaceAll("%FACTION%", faction.getName()).replaceAll("%REASON%", reason)).replaceAll("%PLAYER%", player.getName()));
}
}
private String color(final String stg) {
return ChatColor.translateAlternateColorCodes('&', stg);
}
}

View File

@ -0,0 +1,38 @@
package com.igodlik3.viperutils;
import net.libhalt.bukkit.kaede.HCFactionPlugin;
import net.libhalt.bukkit.kaede.utils.ConfigurationWrapper;
import net.libhalt.bukkit.kaede.utils.Manager;
import net.syuu.popura.command.faction.FactionCommand;
import org.bukkit.configuration.Configuration;
import org.bukkit.plugin.java.*;
import org.bukkit.*;
import org.bukkit.event.*;
import org.bukkit.plugin.*;
import org.bukkit.command.*;
public class ViperUtils extends Manager
{
private static ViperUtils instance;
private ConfigurationWrapper config;
public ViperUtils(HCFactionPlugin plugin) {
super(plugin);
}
public Configuration getConfig(){
return config.getConfig();
}
public void init() {
config = new ConfigurationWrapper("viper-utils.yml", this.getPlugin());
config.saveDefault();
ViperUtils.instance = this;
FactionCommand.INSTANCE.addSubCommand(new CmdMuteFaction());
Bukkit.getPluginManager().registerEvents((Listener)new BoostXPListener(), getPlugin());
this.getPlugin().getCommand("utils").setExecutor((CommandExecutor)new CmdCredits());
}
public static ViperUtils getInstance() {
return ViperUtils.instance;
}
}

View File

@ -0,0 +1,51 @@
package config;
import net.libhalt.bukkit.kaede.HCFactionPlugin;
/**
* Created by Brennan on 6/15/2017.
*/
public class ConfigData
{
HCFactionPlugin plugin;
public ConfigData(HCFactionPlugin instance){
this.plugin = instance;
}
public void setupDefaultMessages()
{
if(!isSetup())
{
plugin.messages.set("nether-portal-in-spawn", "&7(&aViper&7) You cannot enter the portal from spawn.");
plugin.messages.set("all-players-in-spawn", "&7(&aViper&7) All players are currently in spawn.");
plugin.messages.set("only-one-online", "&7(&aViper&7) You are the only person online.");
plugin.messages.set("xp-bottle-created", "&7(&aViper&7) You have bottled the xp.");
plugin.messages.set("xp-bottle-received", "&7(&aViper&7) You have un-bottled the xp. ");
plugin.messages.set("xp-bottle-inventory", "&7(&aViper&7) You must have one available inventory space.");
plugin.messages.set("xp-bottle-insufficient", "&7(&aViper&7) You must have a minimum of 30 XP to bottle.");
plugin.messages.set("xp-bottle-name", "&a&lLevel 30 XP Bottle");
plugin.messages.set("pearl-stuck-message", "&7(&aViper&7) Plugin prevented you from becoming stuck.");
plugin.messages.set("pearl-suffocate-message", "&7(&aViper&7) Plugin prevented you from suffocating.");
plugin.messages.set("sotw-started", "&7(&aViper&7) The SOTW has been started.");
plugin.messages.set("sotw-stopped", "&7(&aViper&7) The SOTW has been stopped.");
plugin.messages.set("sotw-active", "&7(&aViper&7) The SOTW is already active.");
plugin.messages.set("sotw-inactive", "&7(&aViper&7) The SOTW is not active.");
plugin.messages.saveConfig();
}
}
public boolean isSetup()
{
if(!plugin.messages.contains("nether-portal-in-spawn"))
{
return false;
}
return true;
}
public String getConfigMessage(String message) {
return plugin.messages.getString(message);
}
}

View File

@ -0,0 +1,104 @@
package config;
import java.io.File;
import java.io.InputStream;
import java.util.List;
import java.util.Set;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
public class MyConfig
{
private int comments;
private MyConfigManager manager;
private File file;
private FileConfiguration config;
@SuppressWarnings("deprecation")
public MyConfig(InputStream configStream, File configFile, int comments, JavaPlugin plugin)
{
this.comments = comments;
this.manager = new MyConfigManager(plugin);
this.file = configFile;
this.config = YamlConfiguration.loadConfiguration(configStream);
}
public Object get(String path) {return this.config.get(path);}
public Object get(String path, Object def) {return this.config.get(path, def);}
public String getString(String path) {return this.config.getString(path);}
public String getString(String path, String def) {return this.config.getString(path, def);}
public int getInt(String path) {return this.config.getInt(path);}
public int getInt(String path, int def) {return this.config.getInt(path, def);}
public boolean getBoolean(String path) {return this.config.getBoolean(path);}
public boolean getBoolean(String path, boolean def) {return this.config.getBoolean(path, def);}
public void createSection(String path) {this.config.createSection(path);}
public ConfigurationSection getConfigurationSection(String path) {return this.config.getConfigurationSection(path);}
public double getDouble(String path) {return this.config.getDouble(path);}
public double getDouble(String path, double def) {return this.config.getDouble(path, def);}
public List<?> getList(String path) {return this.config.getList(path);}
public List<?> getList(String path, List<?> def) {return this.config.getList(path, def);}
public boolean contains(String path) {return this.config.contains(path);}
public void removeKey(String path) {this.config.set(path, null);}
public void set(String path, Object value) {this.config.set(path, value);}
public void set(String path, Object value, String comment)
{
if(!this.config.contains(path))
{
this.config.set(manager.getPluginName() + "_COMMENT_" + comments, " " + comment);
comments++;
}
this.config.set(path, value);
}
public void set(String path, Object value, String[] comment)
{
for(String comm : comment)
{
if(!this.config.contains(path))
{
this.config.set(manager.getPluginName() + "_COMMENT_" + comments, " " + comm);
comments++;
}
}
this.config.set(path, value);
}
public void setHeader(String[] header)
{
manager.setHeader(this.file, header);
this.comments = header.length + 2;
this.reloadConfig();
}
@SuppressWarnings("deprecation")
public void reloadConfig() {this.config = YamlConfiguration.loadConfiguration(manager.getConfigContent(file));}
public void saveConfig()
{
String config = this.config.saveToString();
manager.saveConfig(config, this.file);
}
public Set<String> getKeys() {return this.config.getKeys(false);}
}

View File

@ -0,0 +1,288 @@
package config;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.Charset;
import org.bukkit.plugin.java.JavaPlugin;
public class MyConfigManager
{
private JavaPlugin plugin;
public MyConfigManager(JavaPlugin plugin)
{
this.plugin = plugin;
}
public MyConfig getNewConfig(String fileName, String[] header)
{
File file = this.getConfigFile(fileName);
if(!file.exists())
{
this.prepareFile(fileName);
if(header != null && header.length != 0)
this.setHeader(file, header);
}
MyConfig config = new MyConfig(this.getConfigContent(fileName), file, this.getCommentsNum(file), plugin);
return config;
}
public MyConfig getNewConfig(String fileName)
{
return this.getNewConfig(fileName, null);
}
private File getConfigFile(String file)
{
if(file.isEmpty() || file == null)
return null;
File configFile;
if(file.contains("/"))
{
if(file.startsWith("/"))
configFile = new File(plugin.getDataFolder() + file.replace("/", File.separator));
else configFile = new File(plugin.getDataFolder() + File.separator + file.replace("/", File.separator));
}
else configFile = new File(plugin.getDataFolder(), file);
return configFile;
}
public void prepareFile(String filePath, String resource)
{
File file = this.getConfigFile(filePath);
if(file.exists())
return;
try
{
file.getParentFile().mkdirs();
file.createNewFile();
if(resource != null)
if(!resource.isEmpty())
this.copyResource(plugin.getResource(resource), file);
}
catch (IOException e){e.printStackTrace();}
}
public void prepareFile(String filePath)
{
this.prepareFile(filePath, null);
}
public void setHeader(File file, String[] header)
{
if(!file.exists())
return;
try
{
String currentLine;
StringBuilder config = new StringBuilder("");
BufferedReader reader = new BufferedReader(new FileReader(file));
while((currentLine = reader.readLine()) != null)
config.append(currentLine + "\n");
reader.close();
config.append("# +----------------------------------------------------+ #\n");
for(String line : header)
{
if(line.length() > 50)
continue;
int lenght = (50 - line.length()) / 2;
StringBuilder finalLine = new StringBuilder(line);
for(int i = 0; i < lenght; i++)
{
finalLine.append(" ");
finalLine.reverse();
finalLine.append(" ");
finalLine.reverse();
}
if(line.length() % 2 != 0)
finalLine.append(" ");
config.append("# < " + finalLine.toString() + " > #\n");
}
config.append("# +----------------------------------------------------+ #");
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
writer.write(this.prepareConfigString(config.toString()));
writer.flush();
writer.close();
}
catch (IOException e){e.printStackTrace();}
}
public InputStream getConfigContent(File file)
{
if(!file.exists())
return null;
try
{
int commentNum = 0;
String addLine;
String currentLine;
String pluginName = this.getPluginName();
StringBuilder whole = new StringBuilder("");
BufferedReader reader = new BufferedReader(new FileReader(file));
while((currentLine = reader.readLine()) != null)
{
if(currentLine.startsWith("#"))
{
addLine = currentLine.replaceFirst("#", pluginName + "_COMMENT_" + commentNum + ":");
whole.append(addLine + "\n");
commentNum++;
}
else whole.append(currentLine + "\n");
}
String config = whole.toString();
InputStream configStream = new ByteArrayInputStream(config.getBytes(Charset.forName("UTF-8")));
reader.close();
return configStream;
}
catch (IOException e){e.printStackTrace();return null;}
}
private int getCommentsNum(File file)
{
if(!file.exists())
return 0;
try
{
int comments = 0;
String currentLine;
BufferedReader reader = new BufferedReader(new FileReader(file));
while((currentLine = reader.readLine()) != null)
if(currentLine.startsWith("#"))
comments++;
reader.close();
return comments;
}
catch (IOException e){e.printStackTrace();return 0;}
}
public InputStream getConfigContent(String filePath)
{
return this.getConfigContent(this.getConfigFile(filePath));
}
private String prepareConfigString(String configString)
{
int lastLine = 0;
int headerLine = 0;
String[] lines = configString.split("\n");
StringBuilder config = new StringBuilder("");
for(String line : lines)
{
if(line.startsWith(this.getPluginName() + "_COMMENT"))
{
String comment = "#" + line.trim().substring(line.indexOf(":") + 1);
if(comment.startsWith("# +-"))
{
if(headerLine == 0)
{
config.append(comment + "\n");
lastLine = 0;
headerLine = 1;
}
else if(headerLine == 1)
{
config.append(comment + "\n\n");
lastLine = 0;
headerLine = 0;
}
}
else
{
String normalComment;
if(comment.startsWith("# ' "))
normalComment = comment.substring(0, comment.length() - 1).replaceFirst("# ' ", "# ");
else normalComment = comment;
if(lastLine == 0)
config.append(normalComment + "\n");
else if(lastLine == 1)
config.append("\n" + normalComment + "\n");
lastLine = 0;
}
}
else
{
config.append(line + "\n");
lastLine = 1;
}
}
return config.toString();
}
public void saveConfig(String configString, File file)
{
String configuration = this.prepareConfigString(configString);
try
{
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
writer.write(configuration);
writer.flush();
writer.close();
}
catch (IOException e){e.printStackTrace();}
}
public String getPluginName()
{
return plugin.getDescription().getName();
}
private void copyResource(InputStream resource, File file)
{
try
{
OutputStream out = new FileOutputStream(file);
int length;
byte[] buf = new byte[1024];
while((length = resource.read(buf)) > 0)
out.write(buf, 0, length);
out.close();
resource.close();
}
catch (Exception e) {e.printStackTrace();}
}
}

View File

@ -0,0 +1,95 @@
package me.dreamzy.report;
import net.libhalt.bukkit.kaede.HCFactionPlugin;
import net.libhalt.bukkit.kaede.utils.ConfigurationWrapper;
import net.libhalt.bukkit.kaede.utils.Manager;
import net.syuu.popura.command.faction.FactionCommand;
import org.bukkit.configuration.Configuration;
import org.bukkit.plugin.java.*;
import org.bukkit.*;
import org.bukkit.event.*;
import org.bukkit.plugin.*;
import me.dreamzy.report.stats.*;
import me.dreamzy.report.reports.*;
import org.bukkit.command.*;
public class ViperReport extends Manager
{
private static ViperReport instance;
private String prefix;
private String prefixReportGui;
private String prefixReportChatGui;
private String prefixReportCheatGui;
private StatsManager statsManager;
private ReportManager reportManager;
{
this.prefix = "&8[&9Delta&aReport&8]";
this.prefixReportGui = "&e\u2022 &9Report &6";
this.prefixReportChatGui = "&2Cheat &e";
this.prefixReportCheatGui = "&6Chat &e";
}
public ViperReport(HCFactionPlugin plugin) {
super(plugin);
}
private ConfigurationWrapper config;
public Configuration getConfig(){
return config.getConfig();
}
public void init() {
config = new ConfigurationWrapper("report.yml", this.getPlugin());
config.saveDefault();
(ViperReport.instance = this).loadManagers();
this.loadListeners();
this.loadCommands();
}
public void onDisable() {
this.statsManager.saveData();
}
private void loadManagers() {
(this.statsManager = new StatsManager()).reloadData();
this.reportManager = new ReportManager();
}
public void loadListeners() {
final PluginManager pm = Bukkit.getPluginManager();
pm.registerEvents((Listener)new StatsListener(), this.getPlugin());
//pm.registerEvents((Listener)new ReportListener(), this.getPlugin());
}
public void loadCommands() {
FactionCommand.INSTANCE.addSubCommand(new CmdStats());
//this.getPlugin().getCommand("report").setExecutor((CommandExecutor)new CmdReport());
}
public static ViperReport getInstance() {
return ViperReport.instance;
}
public String getPrefix() {
return this.prefix;
}
public String getPrefixReportGui() {
return this.prefixReportGui;
}
public String getPrefixReportChatGui() {
return this.prefixReportChatGui;
}
public String getPrefixReportCheatGui() {
return this.prefixReportCheatGui;
}
public StatsManager getStatsManager() {
return this.statsManager;
}
public ReportManager getReportManager() {
return this.reportManager;
}
}

View File

@ -0,0 +1,72 @@
package me.dreamzy.report.reports;
import me.dreamzy.report.*;
import net.syuu.popura.PopuraPlugin;
import net.syuu.popura.faction.bean.FactionPlayer;
import org.bukkit.configuration.*;
import org.bukkit.command.*;
import org.bukkit.entity.*;
import me.dreamzy.report.utils.*;
import org.bukkit.*;
public class CmdReport implements CommandExecutor
{
private ViperReport plugin;
private Configuration config;
private ReportManager reportManager;
public CmdReport() {
this.plugin = ViperReport.getInstance();
this.config = (Configuration)ViperReport.getInstance().getConfig();
this.reportManager = this.plugin.getReportManager();
}
public boolean onCommand(final CommandSender sender, final Command cmd, final String label, final String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(Utils.color(this.config.getString("Messages.NO-PERM")));
return true;
}
final Player player = (Player)sender;
if (args.length == 0) {
this.sendHelp(player);
}
else {
if (CooldownUtils.isOnCooldown("Report", player)) {
sender.sendMessage(Utils.color(this.config.getString("Messages.REPORT-COOLDOWN")).replace("%TIME%", String.valueOf(CooldownUtils.getCooldownForPlayerInt("Report", player))));
return true;
}
final Player cheater = Bukkit.getPlayer(args[0]);
if (cheater != null) {
final FactionPlayer factionPlayer = PopuraPlugin.getInstance().getPopura().getFactionDataManager().getPlayer(player);
if (player == cheater) {
player.sendMessage(Utils.color(this.config.getString("Messages.SELF-REPORT")));
return true;
}
if (factionPlayer.getFaction() != null) {
final ReportData data = this.reportManager.getReportData(factionPlayer.getFaction());
if (!data.reportPlayer(cheater.getName())) {
player.sendMessage(Utils.color(this.config.getString("Messages.MAX-REPORT-FACTION")).replace("%REPORT_COUNT%", String.valueOf(data.getMAX_REPORT_PER_FACTION())));
return true;
}
}
if (this.reportManager.getReport(player) != null) {
this.reportManager.getReports().remove(this.reportManager.getReport(player));
}
final Report report = new Report(player, args[0]);
this.reportManager.getReports().add(report);
this.reportManager.openReportInventory(player);
}
else {
player.sendMessage(Utils.color(this.config.getString("Messages.REPORT-USAGE")));
}
}
return false;
}
public void sendHelp(final Player player) {
for (final String msg : this.config.getStringList("Messages.HELP-CMD")) {
player.sendMessage(Utils.color(msg));
}
}
}

View File

@ -0,0 +1,165 @@
package me.dreamzy.report.reports;
import org.bukkit.entity.*;
import javax.annotation.*;
import org.bukkit.configuration.*;
import me.dreamzy.report.*;
import net.md_5.bungee.api.chat.*;
import me.dreamzy.report.utils.*;
import org.bukkit.*;
public class Report
{
private Player sender;
private String reported;
@Nullable
private String reason;
private Configuration config;
public Report(final Player sender, final String reported) {
this.config = (Configuration)ViperReport.getInstance().getConfig();
this.sender = sender;
this.reported = reported;
this.reason = null;
}
public void send() {
for (Player staff : Bukkit.getOnlinePlayers()){
if (staff.hasPermission("viper.report")) {
String msg = Utils.color(this.config.getString("Messages.REPORT-SEND-STAFF"));
msg = msg.replace("%PLAYER%", this.reported);
msg = msg.replace("%REASON%", this.reason);
final TextComponent text = new TextComponent(msg);
text.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tp " + this.reported));
final Location loc = staff.getLocation();
staff.spigot().sendMessage((BaseComponent)text);
staff.playSound(loc, Sound.WOLF_GROWL, 0.5f, 0.5f);
staff.playSound(loc, Sound.ENDERDRAGON_GROWL, 100.0f, 1.0f);
}
}
this.sender.sendMessage(Utils.color(this.config.getString("Messages.REPORT-SEND")));
CooldownUtils.addCooldown("Report", this.sender, 60);
ViperReport.getInstance().getReportManager().getReports().remove(this);
}
public Player getSender() {
return this.sender;
}
public String getReported() {
return this.reported;
}
@Nullable
public String getReason() {
return this.reason;
}
public Configuration getConfig() {
return this.config;
}
public void setSender(final Player sender) {
this.sender = sender;
}
public void setReported(final String reported) {
this.reported = reported;
}
public void setReason(@Nullable final String reason) {
this.reason = reason;
}
public void setConfig(final Configuration config) {
this.config = config;
}
@Override
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof Report)) {
return false;
}
final Report other = (Report)o;
if (!other.canEqual(this)) {
return false;
}
final Object this$sender = this.getSender();
final Object other$sender = other.getSender();
Label_0065: {
if (this$sender == null) {
if (other$sender == null) {
break Label_0065;
}
}
else if (this$sender.equals(other$sender)) {
break Label_0065;
}
return false;
}
final Object this$reported = this.getReported();
final Object other$reported = other.getReported();
Label_0102: {
if (this$reported == null) {
if (other$reported == null) {
break Label_0102;
}
}
else if (this$reported.equals(other$reported)) {
break Label_0102;
}
return false;
}
final Object this$reason = this.getReason();
final Object other$reason = other.getReason();
Label_0139: {
if (this$reason == null) {
if (other$reason == null) {
break Label_0139;
}
}
else if (this$reason.equals(other$reason)) {
break Label_0139;
}
return false;
}
final Object this$config = this.getConfig();
final Object other$config = other.getConfig();
if (this$config == null) {
if (other$config == null) {
return true;
}
}
else if (this$config.equals(other$config)) {
return true;
}
return false;
}
protected boolean canEqual(final Object other) {
return other instanceof Report;
}
@Override
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $sender = this.getSender();
result = result * 59 + (($sender == null) ? 43 : $sender.hashCode());
final Object $reported = this.getReported();
result = result * 59 + (($reported == null) ? 43 : $reported.hashCode());
final Object $reason = this.getReason();
result = result * 59 + (($reason == null) ? 43 : $reason.hashCode());
final Object $config = this.getConfig();
result = result * 59 + (($config == null) ? 43 : $config.hashCode());
return result;
}
@Override
public String toString() {
return "Report(sender=" + this.getSender() + ", reported=" + this.getReported() + ", reason=" + this.getReason() + ", config=" + this.getConfig() + ")";
}
}

View File

@ -0,0 +1,107 @@
package me.dreamzy.report.reports;
import me.dreamzy.report.*;
import net.syuu.popura.faction.bean.Faction;
import java.util.*;
public class ReportData
{
private Faction faction;
private Map<String, Integer> reportedPlayers;
private final int MAX_REPORT_PER_FACTION;
public ReportData(final Faction faction) {
this.MAX_REPORT_PER_FACTION = ViperReport.getInstance().getConfig().getInt("MAX-REPORT-PER-FACTION");
this.faction = faction;
this.reportedPlayers = new HashMap<String, Integer>();
}
public boolean reportPlayer(final String name) {
if (this.reportedPlayers.containsKey(name)) {
final int reportTime = this.reportedPlayers.put(name, this.reportedPlayers.get(name) + 1);
return reportTime < this.MAX_REPORT_PER_FACTION;
}
this.reportedPlayers.put(name, 1);
return true;
}
public Faction getFaction() {
return this.faction;
}
public Map<String, Integer> getReportedPlayers() {
return this.reportedPlayers;
}
public int getMAX_REPORT_PER_FACTION() {
return this.MAX_REPORT_PER_FACTION;
}
public void setFaction(final Faction faction) {
this.faction = faction;
}
public void setReportedPlayers(final Map<String, Integer> reportedPlayers) {
this.reportedPlayers = reportedPlayers;
}
@Override
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof ReportData)) {
return false;
}
final ReportData other = (ReportData)o;
if (!other.canEqual(this)) {
return false;
}
final Object this$faction = this.getFaction();
final Object other$faction = other.getFaction();
Label_0065: {
if (this$faction == null) {
if (other$faction == null) {
break Label_0065;
}
}
else if (this$faction.equals(other$faction)) {
break Label_0065;
}
return false;
}
final Object this$reportedPlayers = this.getReportedPlayers();
final Object other$reportedPlayers = other.getReportedPlayers();
if (this$reportedPlayers == null) {
if (other$reportedPlayers == null) {
return this.getMAX_REPORT_PER_FACTION() == other.getMAX_REPORT_PER_FACTION();
}
}
else if (this$reportedPlayers.equals(other$reportedPlayers)) {
return this.getMAX_REPORT_PER_FACTION() == other.getMAX_REPORT_PER_FACTION();
}
return false;
}
protected boolean canEqual(final Object other) {
return other instanceof ReportData;
}
@Override
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $faction = this.getFaction();
result = result * 59 + (($faction == null) ? 43 : $faction.hashCode());
final Object $reportedPlayers = this.getReportedPlayers();
result = result * 59 + (($reportedPlayers == null) ? 43 : $reportedPlayers.hashCode());
result = result * 59 + this.getMAX_REPORT_PER_FACTION();
return result;
}
@Override
public String toString() {
return "ReportData(faction=" + this.getFaction() + ", reportedPlayers=" + this.getReportedPlayers() + ", MAX_REPORT_PER_FACTION=" + this.getMAX_REPORT_PER_FACTION() + ")";
}
}

View File

@ -0,0 +1,70 @@
package me.dreamzy.report.reports;
import com.igodlik3.ItemBuilder;
import me.dreamzy.report.*;
import org.bukkit.event.inventory.*;
import org.bukkit.entity.*;
import org.bukkit.event.*;
import org.bukkit.*;
import org.bukkit.inventory.*;
import me.dreamzy.report.utils.*;
public class ReportListener implements Listener
{
private ViperReport plugin;
private ReportManager reportManager;
public ReportListener() {
this.plugin = ViperReport.getInstance();
this.reportManager = this.plugin.getReportManager();
}
@EventHandler
public void onInventoryClick(final InventoryClickEvent event) {
final Player player = (Player)event.getWhoClicked();
final Inventory inv = event.getInventory();
if (inv != null && inv.getName() != null && player.getOpenInventory().getTopInventory() == inv && event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) {
final ItemStack item = event.getCurrentItem();
if (inv.getName().equalsIgnoreCase(Utils.color(this.plugin.getPrefixReportGui()))) {
event.setCancelled(true);
if (item.getType() == Material.DIAMOND_SWORD) {
this.openCheatInventory(player);
}
else {
this.openChatInventory(player);
}
}
else if (inv.getName().contains(Utils.color(this.plugin.getPrefixReportChatGui())) || inv.getName().contains(Utils.color(this.plugin.getPrefixReportCheatGui()))) {
event.setCancelled(true);
final Report report = this.reportManager.getReport(player);
if (report == null) {
player.closeInventory();
return;
}
report.setReason(item.getItemMeta().getDisplayName());
report.send();
player.closeInventory();
}
}
}
public void openChatInventory(final Player player) {
final Inventory inv = Bukkit.createInventory((InventoryHolder)player, 27, Utils.color(this.plugin.getPrefixReportChatGui()));
inv.setItem(10, new ItemBuilder(Material.DIAMOND_SWORD).displayname(Utils.color("&6Spamming Chat")).build());
inv.setItem(12, new ItemBuilder(Material.GOLD_SWORD).displayname(Utils.color("&5Spamming Msg")).build());
inv.setItem(14, new ItemBuilder(Material.POTION).displayname(Utils.color("&3Spamming Faction Title")).build());
inv.setItem(16, new ItemBuilder(Material.FEATHER).displayname(Utils.color("&cCAPS")).build());
inv.setItem(22, new ItemBuilder(Material.BOW).displayname(Utils.color("&dOthers")).build());
player.openInventory(inv);
}
public void openCheatInventory(final Player player) {
final Inventory inv = Bukkit.createInventory((InventoryHolder)player, 27, Utils.color(this.plugin.getPrefixReportCheatGui()));
inv.setItem(10, new ItemBuilder(Material.DIAMOND_SWORD).displayname(Utils.color("&6ForceField")).build());
inv.setItem(12, new ItemBuilder(Material.GOLD_SWORD).displayname(Utils.color("&5KillAura")).build());
inv.setItem(14, new ItemBuilder(Material.POTION).displayname(Utils.color("&3SpeedHack")).build());
inv.setItem(16, new ItemBuilder(Material.FEATHER).displayname(Utils.color("&eFly")).build());
inv.setItem(22, new ItemBuilder(Material.BOW).displayname(Utils.color("&dOthers")).build());
player.openInventory(inv);
}
}

View File

@ -0,0 +1,60 @@
package me.dreamzy.report.reports;
import com.igodlik3.ItemBuilder;
import me.dreamzy.report.*;
import com.google.common.collect.*;
import net.syuu.popura.faction.bean.Faction;
import org.bukkit.entity.*;
import java.util.*;
import org.bukkit.*;
import me.dreamzy.report.utils.*;
import org.bukkit.inventory.*;
public class ReportManager
{
private List<Report> reports;
private List<ReportData> reportsData;
private ViperReport plugin;
public ReportManager() {
this.reports = Lists.newArrayList();
this.reportsData = Lists.newArrayList();
this.plugin = ViperReport.getInstance();
}
public Report getReport(final Player player) {
for (final Report report : this.reports) {
if (report.getSender().getUniqueId().equals(player.getUniqueId())) {
return report;
}
}
return null;
}
public ReportData getReportData(final Faction faction) {
for (final ReportData data : this.reportsData) {
if (data.getFaction().equals(faction)) {
return data;
}
}
this.reportsData.add(new ReportData(faction));
return this.getReportData(faction);
}
public void openReportInventory(final Player player) {
final Inventory inv = Bukkit.createInventory((InventoryHolder)player, 27, Utils.color(this.plugin.getPrefixReportGui()));
final ItemStack cheatCategory = new ItemBuilder(Material.DIAMOND_SWORD).displayname(Utils.color("&a&lCheat")).durability((short)0).lore("&8- &eForceField", "&8- &eKillAura", "&8- &eSpeedHack", "&8- &eFly", "&8- &eOthers").build();
inv.setItem(11, cheatCategory);
final ItemStack chatCategory = new ItemBuilder(Material.PAPER).displayname(Utils.color("&a&lChat")).durability((short)0).lore("&8- &eSpamming Chat", "&8- &eSpamming Msg", "&8- &eSpamming Faction Title", "&8- &eCAPS", "&8- &eOthers").build();
inv.setItem(15, chatCategory);
player.openInventory(inv);
}
public List<Report> getReports() {
return this.reports;
}
public List<ReportData> getReportsData() {
return this.reportsData;
}
}

View File

@ -0,0 +1,86 @@
package me.dreamzy.report.stats;
import net.syuu.common.command.Command;
import net.syuu.popura.PopuraPlugin;
import net.syuu.popura.command.condition.MustBeInFaction;
import net.syuu.popura.faction.FactionDataManager;
import net.syuu.popura.faction.FactionType;
import net.syuu.popura.faction.bean.Faction;
import net.syuu.popura.faction.bean.FactionPlayer;
import org.bukkit.configuration.*;
import me.dreamzy.report.*;
import me.dreamzy.report.utils.*;
import org.bukkit.*;
import org.bukkit.entity.*;
public class CmdStats extends Command
{
private StatsManager statsManager;
private Configuration config;
public CmdStats() {
super("stat");
this.statsManager = ViperReport.getInstance().getStatsManager();
this.config = (Configuration)ViperReport.getInstance().getConfig();
addAllias("stats");
addCondition(new MustBeInFaction());
}
public void proccess(final Player player, final String[] args) {
final FactionDataManager factionDataManager = ((PopuraPlugin)PopuraPlugin.getPlugin(PopuraPlugin.class)).getPopura().getFactionDataManager();
Faction faction = factionDataManager.getPlayer(player).getFaction();
if(args.length > 0){
faction = factionDataManager.getFaction(args[0]);
}
if (faction == null) {
return;
}
if (faction.getFactionType() != FactionType.NORMAL) {
player.sendMessage(Utils.color("&cInvalid faction."));
return;
}
int totalDiamond = 0;
int totalIron = 0;
int totalGold = 0;
int totalEmerald = 0;
int totalCoal = 0;
int totalKills = 0;
int totalDeaths = 0;
for (final FactionPlayer fp : faction.getPlayers()) {
totalKills += fp.getKill();
totalDeaths = fp.getDeath();
Player bukkitPlayer = Bukkit.getPlayer(fp.getName());
if (bukkitPlayer != null) {
totalDiamond = bukkitPlayer.getStatistic(Statistic.MINE_BLOCK, Material.DIAMOND_ORE);
totalIron = bukkitPlayer.getStatistic(Statistic.MINE_BLOCK, Material.IRON_ORE);
totalGold = bukkitPlayer.getStatistic(Statistic.MINE_BLOCK, Material.GOLD_ORE);
totalEmerald = bukkitPlayer.getStatistic(Statistic.MINE_BLOCK, Material.EMERALD_ORE);
totalCoal = bukkitPlayer.getStatistic(Statistic.MINE_BLOCK, Material.COAL_ORE);
}
else {
final StatsData data = this.statsManager.getUser(fp.getUuid().toString());
if (data == null) {
continue;
}
totalDiamond = data.getTotalDiamond();
totalIron = data.getTotalIron();
totalGold = data.getTotalGold();
totalEmerald = data.getTotalEmerald();
totalCoal = data.getTotalCoal();
}
}
for (String msg : this.config.getStringList("Messages.STATS-CMD")) {
msg = msg.replace("%FACTION%", faction.getName());
msg = msg.replace("%KILLS%", String.valueOf(totalKills));
msg = msg.replace("%DEATHS%", String.valueOf(totalDeaths));
msg = msg.replace("%DIAMOND%", String.valueOf(totalDiamond));
msg = msg.replace("%IRON%", String.valueOf(totalIron));
msg = msg.replace("%GOLD%", String.valueOf(totalGold));
msg = msg.replace("%EMERALD%", String.valueOf(totalEmerald));
msg = msg.replace("%COAL%", String.valueOf(totalCoal));
player.sendMessage(Utils.color(msg));
}
}
}

View File

@ -0,0 +1,106 @@
package me.dreamzy.report.stats;
import org.bukkit.entity.*;
import org.bukkit.*;
public class StatsData
{
private int totalDiamond;
private int totalIron;
private int totalGold;
private int totalEmerald;
private int totalCoal;
public StatsData(final Player player) {
this.saveStats(player);
}
public StatsData(final int d, final int i, final int g, final int e, final int c) {
this.totalDiamond = d;
this.totalIron = i;
this.totalGold = g;
this.totalEmerald = e;
this.totalCoal = c;
}
public void saveStats(final Player player) {
this.totalDiamond = player.getStatistic(Statistic.MINE_BLOCK, Material.DIAMOND_ORE);
this.totalIron = player.getStatistic(Statistic.MINE_BLOCK, Material.IRON_ORE);
this.totalGold = player.getStatistic(Statistic.MINE_BLOCK, Material.GOLD_ORE);
this.totalEmerald = player.getStatistic(Statistic.MINE_BLOCK, Material.EMERALD_ORE);
this.totalCoal = player.getStatistic(Statistic.MINE_BLOCK, Material.COAL_ORE);
}
public int getTotalDiamond() {
return this.totalDiamond;
}
public int getTotalIron() {
return this.totalIron;
}
public int getTotalGold() {
return this.totalGold;
}
public int getTotalEmerald() {
return this.totalEmerald;
}
public int getTotalCoal() {
return this.totalCoal;
}
public void setTotalDiamond(final int totalDiamond) {
this.totalDiamond = totalDiamond;
}
public void setTotalIron(final int totalIron) {
this.totalIron = totalIron;
}
public void setTotalGold(final int totalGold) {
this.totalGold = totalGold;
}
public void setTotalEmerald(final int totalEmerald) {
this.totalEmerald = totalEmerald;
}
public void setTotalCoal(final int totalCoal) {
this.totalCoal = totalCoal;
}
@Override
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof StatsData)) {
return false;
}
final StatsData other = (StatsData)o;
return other.canEqual(this) && this.getTotalDiamond() == other.getTotalDiamond() && this.getTotalIron() == other.getTotalIron() && this.getTotalGold() == other.getTotalGold() && this.getTotalEmerald() == other.getTotalEmerald() && this.getTotalCoal() == other.getTotalCoal();
}
protected boolean canEqual(final Object other) {
return other instanceof StatsData;
}
@Override
public int hashCode() {
final int PRIME = 59;
int result = 1;
result = result * 59 + this.getTotalDiamond();
result = result * 59 + this.getTotalIron();
result = result * 59 + this.getTotalGold();
result = result * 59 + this.getTotalEmerald();
result = result * 59 + this.getTotalCoal();
return result;
}
@Override
public String toString() {
return "StatsData(totalDiamond=" + this.getTotalDiamond() + ", totalIron=" + this.getTotalIron() + ", totalGold=" + this.getTotalGold() + ", totalEmerald=" + this.getTotalEmerald() + ", totalCoal=" + this.getTotalCoal() + ")";
}
}

View File

@ -0,0 +1,29 @@
package me.dreamzy.report.stats;
import me.dreamzy.report.*;
import org.bukkit.event.*;
import org.bukkit.event.player.*;
public class StatsListener implements Listener
{
private StatsManager manager;
public StatsListener() {
this.manager = ViperReport.getInstance().getStatsManager();
}
@EventHandler
public void onPlayerJoin(final PlayerJoinEvent event) {
this.manager.getUser(event.getPlayer());
}
@EventHandler
public void onPlayerQuit(final PlayerQuitEvent event) {
this.manager.getUser(event.getPlayer()).saveStats(event.getPlayer());
}
@EventHandler
public void onPlayerKick(final PlayerKickEvent event) {
this.manager.getUser(event.getPlayer()).saveStats(event.getPlayer());
}
}

View File

@ -0,0 +1,56 @@
package me.dreamzy.report.stats;
import me.dreamzy.report.utils.*;
import me.dreamzy.report.*;
import org.bukkit.plugin.java.*;
import org.bukkit.entity.*;
import org.bukkit.configuration.*;
import java.util.*;
public class StatsManager
{
private Map<String, StatsData> statsMap;
private ConfigCreator config;
public StatsManager() {
this.statsMap = new HashMap<String, StatsData>();
this.config = new ConfigCreator("data", ViperReport.getInstance().getPlugin());
}
public StatsData getUser(final Player player) {
final String id = player.getUniqueId().toString();
if (this.statsMap.containsKey(id)) {
return this.statsMap.get(id);
}
final StatsData data = new StatsData(player);
this.statsMap.put(id, data);
return data;
}
public StatsData getUser(final String id) {
return this.statsMap.get(id);
}
public void reloadData() {
final ConfigurationSection section = this.config.getConfigurationSection("data");
if (section != null) {
for (final String id : section.getKeys(false)) {
final String path = String.valueOf(id) + ".";
this.statsMap.put(id, new StatsData(section.getInt(String.valueOf(path) + "totalDiamond"), section.getInt(String.valueOf(path) + "totalIron"), section.getInt(String.valueOf(path) + "totalGold"), section.getInt(String.valueOf(path) + "totalEmerald"), section.getInt(String.valueOf(path) + "totalCoal")));
}
}
}
public void saveData() {
final ConfigurationSection section = this.config.createSection("data");
for (final String id : this.statsMap.keySet()) {
final StatsData data = this.statsMap.get(id);
section.set(String.valueOf(id) + ".totalDiamond", (Object)data.getTotalDiamond());
section.set(String.valueOf(id) + ".totalIron", (Object)data.getTotalIron());
section.set(String.valueOf(id) + ".totalGold", (Object)data.getTotalGold());
section.set(String.valueOf(id) + ".totalEmerald", (Object)data.getTotalEmerald());
section.set(String.valueOf(id) + ".totalCoal", (Object)data.getTotalCoal());
}
this.config.save();
}
}

View File

@ -0,0 +1,92 @@
package me.dreamzy.report.utils;
import org.bukkit.configuration.file.*;
import org.bukkit.plugin.java.*;
import java.io.*;
public class ConfigCreator extends YamlConfiguration
{
private final String fileName;
private final JavaPlugin plugin;
public ConfigCreator(final String fileName, final JavaPlugin plugin) {
this(fileName, ".yml", plugin);
}
public ConfigCreator(final String fileName, final String fileExtension, final JavaPlugin plugin) {
this.fileName = String.valueOf(fileName) + (fileName.endsWith(fileExtension) ? "" : fileExtension);
this.plugin = plugin;
this.createFile();
}
public String getFileName() {
return this.fileName;
}
public JavaPlugin getPlugin() {
return this.plugin;
}
private void createFile() {
final File folder = new File(this.plugin.getDataFolder() , "report-data");
try {
final File file = new File(folder, this.fileName);
if (!file.exists()) {
if (this.plugin.getResource(this.fileName) != null) {
this.plugin.saveResource(this.fileName, false);
}
else {
this.save(file);
}
}
else {
this.load(file);
this.save(file);
}
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public void save() {
final File folder = this.plugin.getDataFolder();
try {
this.save(new File(folder, this.fileName));
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!(o instanceof ConfigCreator)) {
return false;
}
final ConfigCreator config = (ConfigCreator)o;
Label_0054: {
if (this.fileName != null) {
if (this.fileName.equals(config.fileName)) {
break Label_0054;
}
}
else if (config.fileName == null) {
break Label_0054;
}
return false;
}
if (this.plugin != null) {
return this.plugin.equals((Object)config.plugin);
}
return config.plugin == null;
}
public int hashCode() {
int result = (this.fileName != null) ? this.fileName.hashCode() : 0;
result = 31 * result + ((this.plugin != null) ? this.plugin.hashCode() : 0);
return result;
}
}

View File

@ -0,0 +1,58 @@
package me.dreamzy.report.utils;
import java.util.*;
import org.bukkit.entity.*;
public class CooldownUtils
{
private static HashMap<String, HashMap<UUID, Long>> cooldown;
static {
CooldownUtils.cooldown = new HashMap<String, HashMap<UUID, Long>>();
}
public static void clearCooldowns() {
CooldownUtils.cooldown.clear();
}
public static void createCooldown(final String k) {
if (CooldownUtils.cooldown.containsKey(k)) {
throw new IllegalArgumentException("Ce cooldown existe d\u00e9j\u00e0");
}
CooldownUtils.cooldown.put(k, new HashMap<UUID, Long>());
}
public static HashMap<UUID, Long> getCooldownMap(final String k) {
if (CooldownUtils.cooldown.containsKey(k)) {
return CooldownUtils.cooldown.get(k);
}
return null;
}
public static void addCooldown(final String k, final Player p, final int seconds) {
if (!CooldownUtils.cooldown.containsKey(k)) {
createCooldown(k);
}
final long next = System.currentTimeMillis() + seconds * 1000L;
CooldownUtils.cooldown.get(k).put(p.getUniqueId(), next);
}
public static boolean isOnCooldown(final String k, final Player p) {
return CooldownUtils.cooldown.containsKey(k) && CooldownUtils.cooldown.get(k).containsKey(p.getUniqueId()) && System.currentTimeMillis() <= CooldownUtils.cooldown.get(k).get(p.getUniqueId());
}
public static int getCooldownForPlayerInt(final String k, final Player p) {
return (int)((CooldownUtils.cooldown.get(k).get(p.getUniqueId()) - System.currentTimeMillis()) / 1000L);
}
public static long getCooldownForPlayerLong(final String k, final Player p) {
return CooldownUtils.cooldown.get(k).get(p.getUniqueId()) - System.currentTimeMillis();
}
public static void removeCooldown(final String k, final Player p) {
if (!CooldownUtils.cooldown.containsKey(k)) {
throw new IllegalArgumentException(String.valueOf(String.valueOf(k)) + " n'existe pas");
}
CooldownUtils.cooldown.get(k).remove(p.getUniqueId());
}
}

View File

@ -0,0 +1,473 @@
package me.dreamzy.report.utils;
import org.bukkit.block.*;
import org.bukkit.configuration.serialization.*;
import java.util.logging.*;
import java.util.*;
import org.bukkit.*;
public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializable
{
protected final String worldName;
protected final int x1;
protected final int y1;
protected final int z1;
protected final int x2;
protected final int y2;
protected final int z2;
public Cuboid(final Location location1, final Location location2) {
if (!location1.getWorld().equals(location2.getWorld())) {
Logger.getLogger("Les locations doivent \u00eatre dans un m\u00eame monde.");
}
this.worldName = location1.getWorld().getName();
this.x1 = Math.min(location1.getBlockX(), location2.getBlockX());
this.y1 = Math.min(location1.getBlockY(), location2.getBlockY());
this.z1 = Math.min(location1.getBlockZ(), location2.getBlockZ());
this.x2 = Math.max(location1.getBlockX(), location2.getBlockX());
this.y2 = Math.max(location1.getBlockY(), location2.getBlockY());
this.z2 = Math.max(location1.getBlockZ(), location2.getBlockZ());
}
public Cuboid(final Location location) {
this(location, location);
}
public Cuboid(final Cuboid cuboid) {
this(cuboid.getWorld().getName(), cuboid.x1, cuboid.y1, cuboid.z1, cuboid.x2, cuboid.y2, cuboid.z2);
}
private Cuboid(final String string, final int n, final int n2, final int n3, final int n4, final int n5, final int n6) {
this.worldName = string;
this.x1 = Math.min(n, n4);
this.x2 = Math.max(n, n4);
this.y1 = Math.min(n2, n5);
this.y2 = Math.max(n2, n5);
this.z1 = Math.min(n3, n6);
this.z2 = Math.max(n3, n6);
}
public Cuboid(final Map<String, Object> map) {
this.worldName = (String) map.get("worldName");
this.x1 = (int) map.get("x1");
this.x2 = (int) map.get("x2");
this.y1 = (int) map.get("y1");
this.y2 = (int) map.get("y2");
this.z1 = (int) map.get("z1");
this.z2 = (int) map.get("z2");
}
public Map<String, Object> serialize() {
final HashMap<String, Object> hashMap = new HashMap<String, Object>();
hashMap.put("worldName", this.worldName);
hashMap.put("x1", this.x1);
hashMap.put("y1", this.y1);
hashMap.put("z1", this.z1);
hashMap.put("x2", this.x2);
hashMap.put("y2", this.y2);
hashMap.put("z2", this.z2);
return hashMap;
}
public Location getLowerNE() {
return new Location(this.getWorld(), (double)this.x1, (double)this.y1, (double)this.z1);
}
public Location getUpperSW() {
return new Location(this.getWorld(), (double)this.x2, (double)this.y2, (double)this.z2);
}
public List<Block> getBlocks() {
final Iterator<Block> iterator = this.iterator();
final ArrayList<Block> arrayList = new ArrayList<Block>();
while (iterator.hasNext()) {
arrayList.add(iterator.next());
}
return arrayList;
}
public Location getCenter() {
final int i = this.getUpperX() + 1;
final int j = this.getUpperY() + 1;
final int k = this.getUpperZ() + 1;
return new Location(this.getWorld(), this.getLowerX() + (i - this.getLowerX()) / 2.0, this.getLowerY() + (j - this.getLowerY()) / 2.0, this.getLowerZ() + (k - this.getLowerZ()) / 2.0);
}
public World getWorld() {
final World world = Bukkit.getWorld(this.worldName);
if (world == null) {
Logger.getLogger("Le monde " + this.worldName + "n'est pas charg\u00e9 !");
}
return world;
}
public int getSizeX() {
return this.x2 - this.x1 + 1;
}
public int getSizeY() {
return this.y2 - this.y1 + 1;
}
public int getSizeZ() {
return this.z2 - this.z1 + 1;
}
public int getLowerX() {
return this.x1;
}
public int getLowerY() {
return this.y1;
}
public int getLowerZ() {
return this.z1;
}
public int getUpperX() {
return this.x2;
}
public int getUpperY() {
return this.y2;
}
public int getUpperZ() {
return this.z2;
}
public Block[] corners() {
final Block[] arrayOfBlock = new Block[8];
final World localWorld = this.getWorld();
arrayOfBlock[0] = localWorld.getBlockAt(this.x1, this.y1, this.z1);
arrayOfBlock[1] = localWorld.getBlockAt(this.x1, this.y1, this.z2);
arrayOfBlock[2] = localWorld.getBlockAt(this.x1, this.y2, this.z1);
arrayOfBlock[3] = localWorld.getBlockAt(this.x1, this.y2, this.z2);
arrayOfBlock[4] = localWorld.getBlockAt(this.x2, this.y1, this.z1);
arrayOfBlock[5] = localWorld.getBlockAt(this.x2, this.y1, this.z2);
arrayOfBlock[6] = localWorld.getBlockAt(this.x2, this.y2, this.z1);
arrayOfBlock[7] = localWorld.getBlockAt(this.x2, this.y2, this.z2);
return arrayOfBlock;
}
public Cuboid expand(final CuboidDirection paramCuboidDirection, final int paramInt) {
switch (paramCuboidDirection) {
case Both: {
return new Cuboid(this.worldName, this.x1 - paramInt, this.y1, this.z1, this.x2, this.y2, this.z2);
}
case East: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2 + paramInt, this.y2, this.z2);
}
case Down: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z1 - paramInt, this.x2, this.y2, this.z2);
}
case Horizontal: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y2, this.z2 + paramInt);
}
case South: {
return new Cuboid(this.worldName, this.x1, this.y1 - paramInt, this.z1, this.x2, this.y2, this.z2);
}
case North: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y2 + paramInt, this.z2);
}
default: {
throw new IllegalArgumentException("Invalid direction " + paramCuboidDirection);
}
}
}
public Cuboid shift(final CuboidDirection paramCuboidDirection, final int paramInt) {
return this.expand(paramCuboidDirection, paramInt).expand(paramCuboidDirection.opposite(), -paramInt);
}
public Cuboid outset(final CuboidDirection paramCuboidDirection, final int paramInt) {
Cuboid localCuboid = null;
switch (paramCuboidDirection) {
case Unknown: {
localCuboid = this.expand(CuboidDirection.North, paramInt).expand(CuboidDirection.South, paramInt).expand(CuboidDirection.East, paramInt).expand(CuboidDirection.West, paramInt);
break;
}
case Up: {
localCuboid = this.expand(CuboidDirection.Down, paramInt).expand(CuboidDirection.Up, paramInt);
break;
}
case Vertical: {
localCuboid = this.outset(CuboidDirection.Horizontal, paramInt).outset(CuboidDirection.Vertical, paramInt);
break;
}
default: {
throw new IllegalArgumentException("Invalid direction " + paramCuboidDirection);
}
}
return localCuboid;
}
public Cuboid inset(final CuboidDirection cuboidDirection, final int n) {
return this.outset(cuboidDirection, -n);
}
public boolean contains(final int n, final int n2, final int n3) {
return n >= this.x1 && n <= this.x2 && n2 >= this.y1 && n2 <= this.y2 && n3 >= this.z1 && n3 <= this.z2;
}
public boolean contains(final Block block) {
return this.contains(block.getLocation());
}
public boolean contains(final Location location) {
return this.worldName.equals(location.getWorld().getName()) && this.contains(location.getBlockX(), location.getBlockY(), location.getBlockZ());
}
public int getVolume() {
return this.getSizeX() * this.getSizeY() * this.getSizeZ();
}
public byte getAverageLightLevel() {
long l = 0L;
int i = 0;
for (final Block localBlock : this) {
if (localBlock.isEmpty()) {
l += localBlock.getLightLevel();
++i;
}
}
return (byte)((i > 0) ? ((byte)(l / i)) : 0);
}
public Cuboid contract() {
return this.contract(CuboidDirection.Down).contract(CuboidDirection.South).contract(CuboidDirection.East).contract(CuboidDirection.Up).contract(CuboidDirection.North).contract(CuboidDirection.West);
}
public Cuboid contract(final CuboidDirection paramCuboidDirection) {
Cuboid localCuboid = this.getFace(paramCuboidDirection.opposite());
switch (paramCuboidDirection) {
case South: {
while (localCuboid.containsOnly(0) && localCuboid.getLowerY() > this.getLowerY()) {
localCuboid = localCuboid.shift(CuboidDirection.Down, 1);
}
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, localCuboid.getUpperY(), this.z2);
}
case North: {
while (localCuboid.containsOnly(0) && localCuboid.getUpperY() < this.getUpperY()) {
localCuboid = localCuboid.shift(CuboidDirection.Up, 1);
}
return new Cuboid(this.worldName, this.x1, localCuboid.getLowerY(), this.z1, this.x2, this.y2, this.z2);
}
case Both: {
while (localCuboid.containsOnly(0) && localCuboid.getLowerX() > this.getLowerX()) {
localCuboid = localCuboid.shift(CuboidDirection.North, 1);
}
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, localCuboid.getUpperX(), this.y2, this.z2);
}
case East: {
while (localCuboid.containsOnly(0) && localCuboid.getUpperX() < this.getUpperX()) {
localCuboid = localCuboid.shift(CuboidDirection.South, 1);
}
return new Cuboid(this.worldName, localCuboid.getLowerX(), this.y1, this.z1, this.x2, this.y2, this.z2);
}
case Down: {
while (localCuboid.containsOnly(0) && localCuboid.getLowerZ() > this.getLowerZ()) {
localCuboid = localCuboid.shift(CuboidDirection.East, 1);
}
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y2, localCuboid.getUpperZ());
}
case Horizontal: {
while (localCuboid.containsOnly(0) && localCuboid.getUpperZ() < this.getUpperZ()) {
localCuboid = localCuboid.shift(CuboidDirection.West, 1);
}
return new Cuboid(this.worldName, this.x1, this.y1, localCuboid.getLowerZ(), this.x2, this.y2, this.z2);
}
default: {
throw new IllegalArgumentException("Invalid direction " + paramCuboidDirection);
}
}
}
public Cuboid getFace(final CuboidDirection paramCuboidDirection) {
switch (paramCuboidDirection) {
case South: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y1, this.z2);
}
case North: {
return new Cuboid(this.worldName, this.x1, this.y2, this.z1, this.x2, this.y2, this.z2);
}
case Both: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x1, this.y2, this.z2);
}
case East: {
return new Cuboid(this.worldName, this.x2, this.y1, this.z1, this.x2, this.y2, this.z2);
}
case Down: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y2, this.z1);
}
case Horizontal: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z2, this.x2, this.y2, this.z2);
}
default: {
throw new IllegalArgumentException("Invalid direction " + paramCuboidDirection);
}
}
}
public boolean containsOnly(final int paramInt) {
for (final Block block : this) {
if (block.getTypeId() != paramInt) {
return false;
}
}
return true;
}
public Cuboid getBoundingCuboid(final Cuboid paramCuboid) {
if (paramCuboid == null) {
return this;
}
final int i = Math.min(this.getLowerX(), paramCuboid.getLowerX());
final int j = Math.min(this.getLowerY(), paramCuboid.getLowerY());
final int k = Math.min(this.getLowerZ(), paramCuboid.getLowerZ());
final int m = Math.max(this.getUpperX(), paramCuboid.getUpperX());
final int n = Math.max(this.getUpperY(), paramCuboid.getUpperY());
final int i2 = Math.max(this.getUpperZ(), paramCuboid.getUpperZ());
return new Cuboid(this.worldName, i, j, k, m, n, i2);
}
public Block getRelativeBlock(final int n, final int n2, final int n3) {
return this.getWorld().getBlockAt(this.x1 + n, this.y1 + n2, this.z1 + n3);
}
public Block getRelativeBlock(final World world, final int n, final int n2, final int n3) {
return world.getBlockAt(this.x1 + n, this.y1 + n2, this.z1 + n3);
}
public List<Chunk> getChunks() {
final ArrayList<Chunk> arrayList = new ArrayList<Chunk>();
final World world = this.getWorld();
final int i = this.getLowerX() & 0xFFFFFFF0;
final int j = this.getUpperX() & 0xFFFFFFF0;
final int k = this.getLowerZ() & 0xFFFFFFF0;
final int m = this.getUpperZ() & 0xFFFFFFF0;
for (int n = i; n <= j; n += 16) {
for (int i2 = k; i2 <= m; i2 += 16) {
arrayList.add(world.getChunkAt(n >> 4, i2 >> 4));
}
}
return arrayList;
}
@Override
public Iterator<Block> iterator() {
return new CuboidIterator(this.getWorld(), this.x1, this.y1, this.z1, this.x2, this.y2, this.z2);
}
public Cuboid clone() {
return new Cuboid(this);
}
@Override
public String toString() {
return new String("Cuboid: " + this.worldName + "," + this.x1 + "," + this.y1 + "," + this.z1 + "=>" + this.x2 + "," + this.y2 + "," + this.z2);
}
public enum CuboidDirection
{
North("North", 0),
East("East", 1),
South("South", 2),
West("West", 3),
Up("Up", 4),
Down("Down", 5),
Horizontal("Horizontal", 6),
Vertical("Vertical", 7),
Both("Both", 8),
Unknown("Unknown", 9);
private CuboidDirection(final String s, final int n) {
}
public CuboidDirection opposite() {
switch (this) {
case Both: {
return CuboidDirection.South;
}
case Down: {
return CuboidDirection.West;
}
case East: {
return CuboidDirection.North;
}
case Horizontal: {
return CuboidDirection.East;
}
case Unknown: {
return CuboidDirection.Vertical;
}
case Up: {
return CuboidDirection.Horizontal;
}
case North: {
return CuboidDirection.Down;
}
case South: {
return CuboidDirection.Up;
}
case Vertical: {
return CuboidDirection.Both;
}
default: {
return CuboidDirection.Unknown;
}
}
}
}
public class CuboidIterator implements Iterator<Block>
{
private World w;
private int baseX;
private int baseY;
private int baseZ;
private int x;
private int y;
private int z;
private int sizeX;
private int sizeY;
private int sizeZ;
public CuboidIterator(final World paramWorld, final int paramInt1, final int paramInt2, final int paramInt3, final int paramInt4, final int paramInt5, final int paramInt6) {
this.w = paramWorld;
this.baseX = paramInt1;
this.baseY = paramInt2;
this.baseZ = paramInt3;
this.sizeX = Math.abs(paramInt4 - paramInt1) + 1;
this.sizeY = Math.abs(paramInt5 - paramInt2) + 1;
this.sizeZ = Math.abs(paramInt6 - paramInt3) + 1;
final boolean x = false;
this.z = (x ? 1 : 0);
this.y = (x ? 1 : 0);
this.x = (x ? 1 : 0);
}
@Override
public boolean hasNext() {
return this.x < this.sizeX && this.y < this.sizeY && this.z < this.sizeZ;
}
@Override
public Block next() {
final Block block = this.w.getBlockAt(this.baseX + this.x, this.baseY + this.y, this.baseZ + this.z);
if (++this.x >= this.sizeX) {
this.x = 0;
if (++this.y >= this.sizeY) {
this.y = 0;
++this.z;
}
}
return block;
}
@Override
public void remove() {
}
}
}

View File

@ -0,0 +1,50 @@
package me.dreamzy.report.utils;
import java.lang.reflect.*;
import org.bukkit.enchantments.*;
import org.bukkit.inventory.*;
public final class FakeEnchantment extends Enchantment
{
static {
try {
final Field field = Enchantment.class.getDeclaredField("acceptingNew");
field.setAccessible(true);
field.set(null, true);
}
catch (Exception e) {
throw new RuntimeException("Can't register enchantment", e);
}
if (Enchantment.getByName("CA_FAKE") == null) {
Enchantment.registerEnchantment((Enchantment)new FakeEnchantment());
}
}
public FakeEnchantment() {
super(100);
}
public String getName() {
return "CA_FAKE";
}
public int getMaxLevel() {
return 0;
}
public int getStartLevel() {
return 0;
}
public EnchantmentTarget getItemTarget() {
return null;
}
public boolean conflictsWith(final Enchantment enchantment) {
return false;
}
public boolean canEnchantItem(final ItemStack itemStack) {
return false;
}
}

Some files were not shown because too many files have changed in this diff Show More