-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPTorchPlayerListener.java
executable file
·85 lines (80 loc) · 2.15 KB
/
PTorchPlayerListener.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package com.gmail.fuzzelogicsoftware.PortableTorch;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerItemEvent;
import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerItemHeldEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.event.player.*;
class PTorchPlayerListener extends PlayerListener {
public PTorchPlayerListener () { }
@Override
public void onPlayerMove (PlayerMoveEvent event) {
Player player = event.getPlayer();
if(event.getTo().getBlock().getType() == Material.WATER)
{
if(PTorch.isLit(event.getPlayer()))
{
PTorch.extinguish(event.getPlayer());
}
return;
}
else
{
if ( PTorch.updatePlayerLoc(player) ) {
PTorch.lightArea(player, PTorch.intensity, PTorch.falloff); // values for a torch
}
}
}
@Override
public void onPlayerItem(PlayerItemEvent event)
{
if(event.getItem().getType() == Material.TORCH)
{
if(PTorch.isLit(event.getPlayer()) == false)
{
PlayerInventory inv = event.getPlayer().getInventory();
if ( inv.getItemInHand().getType() == Material.TORCH )
{
PTorch.lightTorch(event.getPlayer());
}
}
}
}
@Override
public void onPlayerToggleSneak(PlayerToggleSneakEvent event)
{
//if(PTorch.isLit(event.getPlayer()))
//{
// PTorch.extinguish(event.getPlayer());
// }
}
/*
@Override
public void onPlayerAnimation(PlayerAnimationEvent event)
{
if(event.getAnimationType() == PlayerAnimationType.ARM_SWING)
{
if ( PTorch.isLit(event.getPlayer()) ) {
// player already has lit torch
}
PlayerInventory inv = event.getPlayer().getInventory();
if ( inv.getItemInHand().getType() == Material.TORCH )
{
PTorch.lightTorch(event.getPlayer());
}
}
}
*/
@Override
public void onPlayerQuit (PlayerEvent event) {
if ( PTorch.isLit(event.getPlayer()) ) {
PTorch.extinguish(event.getPlayer());
}
}
}