1
0
mirror of https://e.coding.net/circlecloud/GuiShopManager.git synced 2024-12-27 07:58:51 +00:00

update to Maven project...

Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
j502647092 2015-07-07 16:09:51 +08:00
commit 769fd577ec
12 changed files with 661 additions and 0 deletions

20
.classpath Normal file
View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/bin/
/target/
.settings

23
.project Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>GuiShopManager</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

59
changelog.txt Normal file
View File

@ -0,0 +1,59 @@
<<quote>>
You want virtual and easy-to-use shops? [[http://dev.bukkit.org/bukkit-plugins/bossshop|**BossShop**]] allows to create the most player friendly shops ever!
Tired of promoting your Players by hand? [[http://dev.bukkit.org/server-mods/commandrank-permissionsbukkit/|**CommandRank**]] promotes players for money/kills/passwords/exp etc.!
Unleash the Power of an unique economy system: [[http://dev.bukkit.org/bukkit-plugins/playerpoints/|**PlayerPoints**]] (You can run this beside an other economy plugin)
You want your VIPs to be able to become invincible but you are afraid of abusing players? Use [[http://dev.bukkit.org/bukkit-plugins/vip-god/|**VIP-God**]] :)
<</quote>>
v1.3.2:
*[FIX] Now you can set the Inventory Location of your items to "0"
*[NOTE] World Settings coming soon!
v1.3.1 **(REQUIRES BOSSSHOP v1.9.0 or newer. Sorry for that... Important parts of BossShop were rewritten and work way better now!)**:
*[UPDATE] Updated to BossShop v1.9.0
v1.3.0 **(REQUIRES BOSSSHOP v1.8.3)**:
*[ADD] Added a command (/gsm give <itemname> [player]) which allows to spawn GuiShopManager items
*[ADD] Now you can define the inventory locations of the items
*[UPDATE] Now working with the new BossShop API
v1.2.0:
*[IMPROVE] Improved the GuiShopManager API
*[FIX] Fixed a tiny bug
*[NOTE] With the next update you will be able to define the location of the items in the inventory
v1.1.3:
*[UPDATE] Updated to 1.7.2
v1.1.2:
*[FIX] Fixed an other tiny error
v1.1.1:
* [FIX] An error was caused when a player clicked in the space **around** his inventory
v1.1:
*[FIX] An error was caused when a player who joined had items without special display name in the inventory
v1.0:
*Release

BIN
lib/BossShop.jar Normal file

Binary file not shown.

53
pom.xml Normal file
View File

@ -0,0 +1,53 @@
<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>cn.citycraft</groupId>
<artifactId>GuiShopManager</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>GuiShopManager</name>
<build>
<finalName>${project.name}</finalName>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<type>jar</type>
<version>1.8.3-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.black_ixx.bossshop</groupId>
<artifactId>BossShop</artifactId>
<version>2.01</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/BossShop.jar</systemPath>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

View File

@ -0,0 +1,108 @@
package org.black_ixx.bossshop.addon.guishopmanager;
import org.black_ixx.bossshop.addon.guishopmanager.GuiShopManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
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;
public class Commander implements CommandExecutor {
private GuiShopManager plugin;
public Commander(GuiShopManager plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String arg, String[] args) {
if ((args.length == 1) || (args.length == 2) || (args.length == 3)) {
if (args[0].equalsIgnoreCase("reload")) {
if (!sender.hasPermission("GUIShopManager.reload")) {
sender.sendMessage(ChatColor.RED + "No Permissions!");
return false;
}
this.plugin.reload();
sender.sendMessage(ChatColor.RED + "Reloaded " + ChatColor.YELLOW
+ "GUIShopManager");
return true;
}
if (args[0].equalsIgnoreCase("items")) {
if (!sender.hasPermission("GUIShopManager.Items")) {
sender.sendMessage(ChatColor.RED + "No Permissions!");
return false;
}
sender.sendMessage(ChatColor.YELLOW + "" + ChatColor.BOLD + "GuiShopManager Items");
for (String name : this.plugin.getGSMItems().getItemNames().keySet()) {
sender.sendMessage(ChatColor.YELLOW + "- " + name);
}
return true;
}
if (args[0].equalsIgnoreCase("give")) {
if (!sender.hasPermission("GUIShopManager.give")) {
sender.sendMessage(ChatColor.RED + "No Permissions!");
return false;
}
if ((args.length != 2) && (args.length != 3)) {
sendInfo(sender);
return false;
}
String itemname = args[1];
String playername = sender.getName();
if (args.length == 3) {
playername = args[2];
} else if (!(sender instanceof Player)) {
sendInfo(sender);
return false;
}
ItemStack item = this.plugin.getGSMItems().getItemByName(itemname);
if (item == null) {
sender.sendMessage(ChatColor.RED + "GuiShopManager Item " + ChatColor.GOLD
+ itemname + ChatColor.RED + " not found!");
return false;
}
Player player = Bukkit.getPlayerExact(playername);
if (player == null) {
player = Bukkit.getPlayer(playername);
}
if (player == null) {
sender.sendMessage(ChatColor.RED + "Player " + ChatColor.GOLD + playername
+ ChatColor.RED + " not found!");
return false;
}
player.getInventory().addItem(new ItemStack[] { item });
sender.sendMessage(ChatColor.YELLOW + "Added GSM Item " + ChatColor.RED + itemname
+ ChatColor.YELLOW + " to " + ChatColor.RED + playername + "'s"
+ ChatColor.YELLOW + " Inventory.");
return true;
}
}
sendInfo(sender);
return false;
}
private void sendInfo(CommandSender s) {
s.sendMessage(ChatColor.YELLOW + "/GSM reload " + ChatColor.RED
+ "- Reloads GUIShopManager");
s.sendMessage(ChatColor.YELLOW + "/GSM items " + ChatColor.RED + "- Lists all GSM Items");
s.sendMessage(ChatColor.YELLOW + "/GSM give <itemname> [Player] " + ChatColor.RED
+ "- Gives [Player] the named item");
}
}

View File

@ -0,0 +1,169 @@
package org.black_ixx.bossshop.addon.guishopmanager;
import java.util.HashMap;
import java.util.List;
import org.black_ixx.bossshop.addon.guishopmanager.GuiShopManager;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
public class GSMItems implements Reloadable {
private HashMap<ItemStack, String> items = new HashMap<ItemStack, String>();
private HashMap<String, ItemStack> item_names = new HashMap<String, ItemStack>();
private HashMap<Integer, ItemStack> joinItems = new HashMap<Integer, ItemStack>();
private GuiShopManager plugin;
public GSMItems(GuiShopManager plugin) {
this.plugin = plugin;
loadItems(plugin);
}
public ItemStack getItemByName(String name) {
ItemStack i = this.item_names.get(name);
if (i != null)
return i;
for (String s : this.item_names.keySet()) {
if (s.equalsIgnoreCase(name))
return this.item_names.get(s);
}
for (String s : this.item_names.keySet()) {
if (s.toLowerCase().startsWith(name.toLowerCase()))
return this.item_names.get(s);
}
return null;
}
public HashMap<String, ItemStack> getItemNames() {
return this.item_names;
}
public void giveJoinItems(Player p) {
if (!this.joinItems.isEmpty()) {
for (Integer integer : this.joinItems.keySet()) {
int loc = integer.intValue();
ItemStack i = this.joinItems.get(Integer.valueOf(loc));
if ((!p.getInventory().contains(i.getType()))
|| (!hasItem(i, p))) {
loc--;
boolean b = false;
if ((loc >= p.getInventory().getSize()) || (loc < 0)) {
loc = 0;
b = true;
}
if ((!b) || (p.getInventory().getItem(loc) == null)) {
p.getInventory().setItem(loc, i.clone());
} else {
p.getInventory().addItem(new ItemStack[] { i.clone() });
}
}
}
}
}
private boolean hasItem(ItemStack i, Player p) {
for (ItemStack s : p.getInventory().getContents()) {
if ((s != null)
&& (s.hasItemMeta())
&& (s.getItemMeta().hasDisplayName())
&& (s.getItemMeta().getDisplayName().equalsIgnoreCase(i
.getItemMeta().getDisplayName())))
return true;
}
return false;
}
public boolean isShopItem(ItemStack s) {
if (s == null)
return false;
for (ItemStack i : this.items.keySet()) {
if (i != null) {
if (i.getType() == s.getType()) {
if (i.getItemMeta().getDisplayName()
.equalsIgnoreCase(s.getItemMeta().getDisplayName()))
return true;
}
}
}
return false;
}
private void loadItems(GuiShopManager plugin) {
ConfigurationSection c = plugin.getConfig().getConfigurationSection(
"Items");
if (c == null) {
Bukkit.getLogger()
.severe("[GuiShopManager] No Items were found in the config :/ Delete your config and restart the server to generate a new config file.");
return;
}
for (String path_name : c.getKeys(false)) {
ConfigurationSection sec = c.getConfigurationSection(path_name);
String open_shop = sec.getString("OpenShop");
if (open_shop != null) {
boolean give_on_join = sec.getBoolean("GiveOnJoin");
int inventoryloc = sec.getInt("InventoryLocation");
List<String> list = sec.getStringList("Look");
if (list != null) {
ItemStack item = plugin.getBossShop().getClassManager()
.getItemStackCreator().createItemStack(list);
this.items.put(item, open_shop);
this.item_names.put(path_name, item);
if (give_on_join) {
this.joinItems.put(Integer.valueOf(inventoryloc), item);
}
}
}
}
}
public void playerClicked(PlayerInteractEvent e) {
if (((e.getAction() == Action.RIGHT_CLICK_AIR) || (e.getAction() == Action.RIGHT_CLICK_BLOCK))
&& (e.getItem() != null)) {
for (ItemStack i : this.items.keySet()) {
if (i != null && i.hasItemMeta()
&& i.getItemMeta().hasDisplayName()) {
if (e.getItem() != null && e.getItem().hasItemMeta()
&& e.getItem().getItemMeta().hasDisplayName()) {
if (i.getItemMeta()
.getDisplayName()
.equalsIgnoreCase(
e.getItem().getItemMeta()
.getDisplayName())) {
String n = this.items.get(i);
this.plugin.getBossShop().getAPI()
.openShop(e.getPlayer(), n);
e.setCancelled(true);
}
}
}
}
}
}
@Override
public void reload(GuiShopManager plugin) {
this.items.clear();
this.item_names.clear();
this.joinItems.clear();
loadItems(plugin);
}
}

View File

@ -0,0 +1,98 @@
package org.black_ixx.bossshop.addon.guishopmanager;
import java.util.ArrayList;
import java.util.List;
import org.black_ixx.bossshop.addon.guishopmanager.Commander;
import org.black_ixx.bossshop.addon.guishopmanager.GSMItems;
import org.black_ixx.bossshop.addon.guishopmanager.PlayerListener;
import org.black_ixx.bossshop.api.BossShopAddon;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
public class GuiShopManager extends BossShopAddon {
private GSMItems items;
private PlayerListener listener;
private void addDefaultConfig() {
FileConfiguration c = getConfig();
c.set("Version", getDescription().getVersion());
c.set("Settings.AllowPlaceItems", Boolean.valueOf(false));
c.set("Settings.AllowMoveItems", Boolean.valueOf(false));
c.set("Settings.AllowDropItems", Boolean.valueOf(false));
c.set("Settings.DropItemsOnDeath", Boolean.valueOf(false));
c.set("Settings.GetItemsOnRespawn", Boolean.valueOf(true));
List<String> compass = new ArrayList<String>();
compass.add("name:&aQuick Warp &7(Right Click) &6[x]");
compass.add("type:COMPASS");
compass.add("amount:1");
List<String> book = new ArrayList<String>();
book.add("name:&6[o] &4&lBossShop &r&6Menu &6[o]");
book.add("lore:&7Right Click to open the Menu!");
book.add("type:BOOK");
book.add("amount:1");
c.set("Items.BossShopMenu.Look", book);
c.set("Items.BossShopMenu.GiveOnJoin", Boolean.valueOf(true));
c.set("Items.BossShopMenu.InventoryLocation", Integer.valueOf(1));
c.set("Items.BossShopMenu.OpenShop", "menu");
c.set("Items.Servers.Look", compass);
c.set("Items.Servers.GiveOnJoin", Boolean.valueOf(true));
c.set("Items.Servers.InventoryLocation", Integer.valueOf(9));
c.set("Items.Servers.OpenShop", "bungeecordservers");
saveConfig();
}
@Override
public void bossShopReloaded(CommandSender sender) {
reload();
sender.sendMessage(ChatColor.YELLOW + "Reloaded BossShop Addon " + ChatColor.GOLD
+ getAddonName());
}
@Override
public void disableAddon() {
}
@Override
public void enableAddon() {
if (getConfig().getString("Version") == null) {
addDefaultConfig();
}
this.items = new GSMItems(this);
this.listener = new PlayerListener(this);
getServer().getPluginManager().registerEvents(this.listener, this);
getCommand("gsm").setExecutor(new Commander(this));
}
@Override
public String getAddonName() {
return "GuiShopManager";
}
public GSMItems getGSMItems() {
return this.items;
}
@Override
public String getRequiredBossShopVersion() {
return "1.9.0";
}
public void reload() {
reloadConfig();
if (getConfig().getString("Version") == null) {
addDefaultConfig();
}
this.items.reload(this);
this.listener.reload(this);
}
}

View File

@ -0,0 +1,110 @@
package org.black_ixx.bossshop.addon.guishopmanager;
import java.util.ArrayList;
import java.util.List;
import org.black_ixx.bossshop.addon.guishopmanager.GuiShopManager;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.ItemStack;
public class PlayerListener implements Listener, Reloadable {
private GuiShopManager plugin;
private boolean drop;
private boolean move;
private boolean place;
private boolean death;
private boolean respawn;
public PlayerListener(GuiShopManager plugin) {
this.plugin = plugin;
loadSettings(plugin);
}
private void loadSettings(GuiShopManager plugin) {
ConfigurationSection s = plugin.getConfig().getConfigurationSection("Settings");
this.drop = s.getBoolean("AllowDropItems");
this.move = s.getBoolean("AllowMoveItems");
this.place = s.getBoolean("AllowPlaceItems");
this.death = s.getBoolean("DropItemsOnDeath");
this.respawn = s.getBoolean("GetItemsOnRespawn");
}
@EventHandler(ignoreCancelled = true)
public void onDeath(PlayerDeathEvent event) {
if (!this.death) {
List<ItemStack> toRemove = new ArrayList<ItemStack>();
for (ItemStack i : event.getDrops()) {
if (this.plugin.getGSMItems().isShopItem(i)) {
toRemove.add(i);
}
}
for (ItemStack i : toRemove) {
event.getDrops().remove(i);
}
toRemove.clear();
}
}
@EventHandler(ignoreCancelled = true)
public void onDrop(PlayerDropItemEvent event) {
if ((!this.drop)
&& (this.plugin.getGSMItems().isShopItem(event.getItemDrop().getItemStack()))) {
event.setCancelled(true);
}
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onInteract(PlayerInteractEvent event) {
this.plugin.getGSMItems().playerClicked(event);
}
@EventHandler(ignoreCancelled = true)
public void onJoin(PlayerJoinEvent event) {
this.plugin.getGSMItems().giveJoinItems(event.getPlayer());
}
@EventHandler(ignoreCancelled = true)
public void onMove(InventoryClickEvent event) {
if (event.getWhoClicked().isOp())
return;
if (!this.move) {
if (this.plugin.getGSMItems().isShopItem(event.getCurrentItem())
|| this.plugin.getGSMItems().isShopItem(event.getCursor())) {
event.setCancelled(true);
}
}
}
@EventHandler(ignoreCancelled = true)
public void onPlace(BlockPlaceEvent event) {
if ((!this.place) && (this.plugin.getGSMItems().isShopItem(event.getItemInHand()))) {
event.setCancelled(true);
}
}
@EventHandler
public void onRespawn(PlayerRespawnEvent event) {
if (this.respawn) {
this.plugin.getGSMItems().giveJoinItems(event.getPlayer());
}
}
@Override
public void reload(GuiShopManager plugin) {
loadSettings(plugin);
}
}

View File

@ -0,0 +1,8 @@
package org.black_ixx.bossshop.addon.guishopmanager;
import org.black_ixx.bossshop.addon.guishopmanager.GuiShopManager;
public abstract interface Reloadable
{
public abstract void reload(GuiShopManager paramGuiShopManager);
}

10
src/plugin.yml Normal file
View File

@ -0,0 +1,10 @@
name: GuiShopManager
version: 1.3.3
description: BossShop Addon managing the GUIs
author: Black_ixx
website: http://felix.neuby.de
main: org.black_ixx.bossshop.addon.guishopmanager.GuiShopManager
depend: [BossShop]
commands:
gsm:
description: GUIShopManager command