Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
434 additions
and
1,558 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package net.danh.storage.Gui; | ||
|
||
import net.danh.storage.Manager.Data; | ||
import net.danh.storage.Storage; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.inventory.ClickType; | ||
import org.bukkit.event.player.AsyncPlayerChatEvent; | ||
import org.bukkit.scheduler.BukkitRunnable; | ||
|
||
import static net.danh.dcore.Random.Number.isInteger; | ||
|
||
public class Chat implements Listener { | ||
|
||
@EventHandler | ||
public void onChat(AsyncPlayerChatEvent e) { | ||
Player p = e.getPlayer(); | ||
String msg = ChatColor.stripColor(e.getMessage()); | ||
if (isInteger(msg)) { | ||
if (!Data.item.isEmpty() && Data.click.containsValue(ClickType.LEFT) && Data.click.containsKey(p) && Data.action.contains(p)) { | ||
new BukkitRunnable() { | ||
@Override | ||
public void run() { | ||
p.performCommand("storage take " + Data.item.get(p) + " " + Integer.parseInt(msg)); | ||
} | ||
}.runTask(Storage.get()); | ||
Data.item.remove(p); | ||
Data.click.remove(p); | ||
Data.action.remove(p); | ||
e.setCancelled(true); | ||
} | ||
if (!Data.item.isEmpty() && Data.click.containsValue(ClickType.RIGHT) && Data.click.containsKey(p) && Data.action.contains(p)) { | ||
new BukkitRunnable() { | ||
@Override | ||
public void run() { | ||
p.performCommand("storage add " + Data.item.get(p) + " " + Integer.parseInt(msg)); | ||
} | ||
}.runTask(Storage.get()); | ||
Data.item.remove(p); | ||
Data.click.remove(p); | ||
Data.action.remove(p); | ||
e.setCancelled(true); | ||
} | ||
if (!Data.item.isEmpty() && Data.click.containsValue(ClickType.DROP) && Data.click.containsKey(p) && Data.action.contains(p)) { | ||
new BukkitRunnable() { | ||
@Override | ||
public void run() { | ||
p.performCommand("storage sell " + Data.item.get(p) + " " + Integer.parseInt(msg)); | ||
} | ||
}.runTask(Storage.get()); | ||
Data.item.remove(p); | ||
Data.click.remove(p); | ||
Data.action.remove(p); | ||
e.setCancelled(true); | ||
} | ||
} | ||
} | ||
} |
244 changes: 0 additions & 244 deletions
244
src/main/java/net/danh/storage/Gui/GuiEventListener.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.