mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-03 06:57:39 +01:00
Revert to 1013
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1021 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
81c9b91561
commit
08041599ff
@ -628,6 +628,13 @@ is divided into following sections:
|
|||||||
<param name="call.target" value="jar"/>
|
<param name="call.target" value="jar"/>
|
||||||
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
|
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
|
||||||
</antcall>
|
</antcall>
|
||||||
|
<antcall target="-maybe-call-dep">
|
||||||
|
<param name="call.built.properties" value="${built-jar.properties}"/>
|
||||||
|
<param location="${project.EssentialsServerlist}" name="call.subproject"/>
|
||||||
|
<param location="${project.EssentialsServerlist}/build.xml" name="call.script"/>
|
||||||
|
<param name="call.target" value="jar"/>
|
||||||
|
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
|
||||||
|
</antcall>
|
||||||
<antcall target="-maybe-call-dep">
|
<antcall target="-maybe-call-dep">
|
||||||
<param name="call.built.properties" value="${built-jar.properties}"/>
|
<param name="call.built.properties" value="${built-jar.properties}"/>
|
||||||
<param location="${project.EssentialsSpawn}" name="call.subproject"/>
|
<param location="${project.EssentialsSpawn}" name="call.subproject"/>
|
||||||
@ -1106,6 +1113,13 @@ is divided into following sections:
|
|||||||
<param name="call.target" value="clean"/>
|
<param name="call.target" value="clean"/>
|
||||||
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
|
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
|
||||||
</antcall>
|
</antcall>
|
||||||
|
<antcall target="-maybe-call-dep">
|
||||||
|
<param name="call.built.properties" value="${built-clean.properties}"/>
|
||||||
|
<param location="${project.EssentialsServerlist}" name="call.subproject"/>
|
||||||
|
<param location="${project.EssentialsServerlist}/build.xml" name="call.script"/>
|
||||||
|
<param name="call.target" value="clean"/>
|
||||||
|
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
|
||||||
|
</antcall>
|
||||||
<antcall target="-maybe-call-dep">
|
<antcall target="-maybe-call-dep">
|
||||||
<param name="call.built.properties" value="${built-clean.properties}"/>
|
<param name="call.built.properties" value="${built-clean.properties}"/>
|
||||||
<param location="${project.EssentialsSpawn}" name="call.subproject"/>
|
<param location="${project.EssentialsSpawn}" name="call.subproject"/>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
build.xml.data.CRC32=60061751
|
build.xml.data.CRC32=36e85771
|
||||||
build.xml.script.CRC32=7a797370
|
build.xml.script.CRC32=7a797370
|
||||||
build.xml.stylesheet.CRC32=28e38971@1.42.1.45
|
build.xml.stylesheet.CRC32=28e38971@1.42.1.45
|
||||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||||
nbproject/build-impl.xml.data.CRC32=60061751
|
nbproject/build-impl.xml.data.CRC32=36e85771
|
||||||
nbproject/build-impl.xml.script.CRC32=5fce336c
|
nbproject/build-impl.xml.script.CRC32=eaedfa13
|
||||||
nbproject/build-impl.xml.stylesheet.CRC32=19debb58@1.42.1.45
|
nbproject/build-impl.xml.stylesheet.CRC32=19debb58@1.42.1.45
|
||||||
|
@ -34,6 +34,7 @@ javac.classpath=\
|
|||||||
${reference.EssentialsGroupBridge.jar}:\
|
${reference.EssentialsGroupBridge.jar}:\
|
||||||
${reference.EssentialsGroupManager.jar}:\
|
${reference.EssentialsGroupManager.jar}:\
|
||||||
${reference.EssentialsProtect.jar}:\
|
${reference.EssentialsProtect.jar}:\
|
||||||
|
${reference.EssentialsServerlist.jar}:\
|
||||||
${reference.EssentialsSpawn.jar}
|
${reference.EssentialsSpawn.jar}
|
||||||
# Space-separated list of extra javac options
|
# Space-separated list of extra javac options
|
||||||
javac.compilerargs=
|
javac.compilerargs=
|
||||||
@ -68,12 +69,14 @@ project.EssentialsChat=../EssentialsChat
|
|||||||
project.EssentialsGroupBridge=../EssentialsGroupBridge
|
project.EssentialsGroupBridge=../EssentialsGroupBridge
|
||||||
project.EssentialsGroupManager=../EssentialsGroupManager
|
project.EssentialsGroupManager=../EssentialsGroupManager
|
||||||
project.EssentialsProtect=../EssentialsProtect
|
project.EssentialsProtect=../EssentialsProtect
|
||||||
|
project.EssentialsServerlist=../EssentialsServerlist
|
||||||
project.EssentialsSpawn=../EssentialsSpawn
|
project.EssentialsSpawn=../EssentialsSpawn
|
||||||
reference.Essentials.jar=${project.Essentials}/dist/Essentials.jar
|
reference.Essentials.jar=${project.Essentials}/dist/Essentials.jar
|
||||||
reference.EssentialsChat.jar=${project.EssentialsChat}/dist/EssentialsChat.jar
|
reference.EssentialsChat.jar=${project.EssentialsChat}/dist/EssentialsChat.jar
|
||||||
reference.EssentialsGroupBridge.jar=${project.EssentialsGroupBridge}/dist/EssentialsGroupBridge.jar
|
reference.EssentialsGroupBridge.jar=${project.EssentialsGroupBridge}/dist/EssentialsGroupBridge.jar
|
||||||
reference.EssentialsGroupManager.jar=${project.EssentialsGroupManager}/dist/EssentialsGroupManager.jar
|
reference.EssentialsGroupManager.jar=${project.EssentialsGroupManager}/dist/EssentialsGroupManager.jar
|
||||||
reference.EssentialsProtect.jar=${project.EssentialsProtect}/dist/original-EssentialsProtect.jar
|
reference.EssentialsProtect.jar=${project.EssentialsProtect}/dist/original-EssentialsProtect.jar
|
||||||
|
reference.EssentialsServerlist.jar=${project.EssentialsServerlist}/dist/EssentialsServerlist.jar
|
||||||
reference.EssentialsSpawn.jar=${project.EssentialsSpawn}/dist/EssentialsSpawn.jar
|
reference.EssentialsSpawn.jar=${project.EssentialsSpawn}/dist/EssentialsSpawn.jar
|
||||||
run.classpath=\
|
run.classpath=\
|
||||||
${javac.classpath}:\
|
${javac.classpath}:\
|
||||||
|
@ -55,6 +55,14 @@
|
|||||||
<clean-target>clean</clean-target>
|
<clean-target>clean</clean-target>
|
||||||
<id>jar</id>
|
<id>jar</id>
|
||||||
</reference>
|
</reference>
|
||||||
|
<reference>
|
||||||
|
<foreign-project>EssentialsServerlist</foreign-project>
|
||||||
|
<artifact-type>jar</artifact-type>
|
||||||
|
<script>build.xml</script>
|
||||||
|
<target>jar</target>
|
||||||
|
<clean-target>clean</clean-target>
|
||||||
|
<id>jar</id>
|
||||||
|
</reference>
|
||||||
<reference>
|
<reference>
|
||||||
<foreign-project>EssentialsSpawn</foreign-project>
|
<foreign-project>EssentialsSpawn</foreign-project>
|
||||||
<artifact-type>jar</artifact-type>
|
<artifact-type>jar</artifact-type>
|
||||||
|
@ -38,6 +38,7 @@ public class Essentials extends JavaPlugin
|
|||||||
private EssentialsPlayerListener playerListener;
|
private EssentialsPlayerListener playerListener;
|
||||||
private EssentialsBlockListener blockListener;
|
private EssentialsBlockListener blockListener;
|
||||||
private EssentialsEntityListener entityListener;
|
private EssentialsEntityListener entityListener;
|
||||||
|
private JailPlayerListener jailPlayerListener;
|
||||||
private static Essentials staticThis = null;
|
private static Essentials staticThis = null;
|
||||||
public Spawn spawn;
|
public Spawn spawn;
|
||||||
private Jail jail;
|
private Jail jail;
|
||||||
@ -159,7 +160,7 @@ public class Essentials extends JavaPlugin
|
|||||||
pm.registerEvent(Type.PLAYER_MOVE, playerListener, Priority.High, this);
|
pm.registerEvent(Type.PLAYER_MOVE, playerListener, Priority.High, this);
|
||||||
pm.registerEvent(Type.PLAYER_LOGIN, playerListener, Priority.High, this);
|
pm.registerEvent(Type.PLAYER_LOGIN, playerListener, Priority.High, this);
|
||||||
pm.registerEvent(Type.PLAYER_TELEPORT, playerListener, Priority.High, this);
|
pm.registerEvent(Type.PLAYER_TELEPORT, playerListener, Priority.High, this);
|
||||||
pm.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.Monitor, this);
|
pm.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.High, this);
|
||||||
|
|
||||||
blockListener = new EssentialsBlockListener(this);
|
blockListener = new EssentialsBlockListener(this);
|
||||||
pm.registerEvent(Type.SIGN_CHANGE, blockListener, Priority.Monitor, this);
|
pm.registerEvent(Type.SIGN_CHANGE, blockListener, Priority.Monitor, this);
|
||||||
@ -172,11 +173,12 @@ public class Essentials extends JavaPlugin
|
|||||||
pm.registerEvent(Type.ENTITY_DEATH, entityListener, Priority.Lowest, this);
|
pm.registerEvent(Type.ENTITY_DEATH, entityListener, Priority.Lowest, this);
|
||||||
|
|
||||||
jail = new Jail(this.getDataFolder());
|
jail = new Jail(this.getDataFolder());
|
||||||
|
jailPlayerListener = new JailPlayerListener(this);
|
||||||
confList.add(jail);
|
confList.add(jail);
|
||||||
pm.registerEvent(Type.BLOCK_BREAK, jail, Priority.High, this);
|
pm.registerEvent(Type.BLOCK_BREAK, jail, Priority.High, this);
|
||||||
pm.registerEvent(Type.BLOCK_DAMAGE, jail, Priority.High, this);
|
pm.registerEvent(Type.BLOCK_DAMAGE, jail, Priority.High, this);
|
||||||
pm.registerEvent(Type.BLOCK_PLACE, jail, Priority.High, this);
|
pm.registerEvent(Type.BLOCK_PLACE, jail, Priority.High, this);
|
||||||
|
pm.registerEvent(Type.PLAYER_INTERACT, jailPlayerListener, Priority.High, this);
|
||||||
attachEcoListeners();
|
attachEcoListeners();
|
||||||
|
|
||||||
if (settings.isNetherEnabled() && getServer().getWorlds().size() < 2)
|
if (settings.isNetherEnabled() && getServer().getWorlds().size() < 2)
|
||||||
@ -662,9 +664,11 @@ public class Essentials extends JavaPlugin
|
|||||||
private void attachEcoListeners()
|
private void attachEcoListeners()
|
||||||
{
|
{
|
||||||
PluginManager pm = getServer().getPluginManager();
|
PluginManager pm = getServer().getPluginManager();
|
||||||
EssentialsEcoBlockListener blockListener = new EssentialsEcoBlockListener();
|
EssentialsEcoBlockListener ecoBlockListener = new EssentialsEcoBlockListener();
|
||||||
pm.registerEvent(Type.BLOCK_BREAK, blockListener, Priority.High, this);
|
EssentialsEcoPlayerListener ecoPlayerListener = new EssentialsEcoPlayerListener();
|
||||||
pm.registerEvent(Type.SIGN_CHANGE, blockListener, Priority.Monitor, this);
|
pm.registerEvent(Type.PLAYER_INTERACT, ecoPlayerListener, Priority.High, this);
|
||||||
|
pm.registerEvent(Type.BLOCK_BREAK, ecoBlockListener, Priority.High, this);
|
||||||
|
pm.registerEvent(Type.SIGN_CHANGE, ecoBlockListener, Priority.Monitor, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CraftScheduler getScheduler()
|
public CraftScheduler getScheduler()
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import net.minecraft.server.InventoryPlayer;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.block.*;
|
import org.bukkit.block.*;
|
||||||
import org.bukkit.craftbukkit.block.CraftSign;
|
import org.bukkit.craftbukkit.block.CraftSign;
|
||||||
|
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.block.*;
|
import org.bukkit.event.block.*;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
|
||||||
public class EssentialsBlockListener extends BlockListener
|
public class EssentialsBlockListener extends BlockListener
|
||||||
@ -47,7 +52,6 @@ public class EssentialsBlockListener extends BlockListener
|
|||||||
user.sendMessage("§cYou do not have permission to destroy that sign.");
|
user.sendMessage("§cYou do not have permission to destroy that sign.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSignChange(SignChangeEvent event)
|
public void onSignChange(SignChangeEvent event)
|
||||||
{
|
{
|
||||||
@ -137,7 +141,7 @@ public class EssentialsBlockListener extends BlockListener
|
|||||||
private static final int ALLOWED = 1;
|
private static final int ALLOWED = 1;
|
||||||
private static final int NOSIGN = 2;
|
private static final int NOSIGN = 2;
|
||||||
|
|
||||||
private static int checkProtectionSign(Block block, User user)
|
private int checkProtectionSign(Block block, User user)
|
||||||
{
|
{
|
||||||
if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)
|
if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)
|
||||||
{
|
{
|
||||||
@ -162,7 +166,7 @@ public class EssentialsBlockListener extends BlockListener
|
|||||||
return NOSIGN;
|
return NOSIGN;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Block[] getAdjacentBlocks(Block block)
|
private Block[] getAdjacentBlocks(Block block)
|
||||||
{
|
{
|
||||||
return new Block[]
|
return new Block[]
|
||||||
{
|
{
|
||||||
@ -175,7 +179,7 @@ public class EssentialsBlockListener extends BlockListener
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isBlockProtected(Block block, User user)
|
public boolean isBlockProtected(Block block, User user)
|
||||||
{
|
{
|
||||||
Block[] faces = getAdjacentBlocks(block);
|
Block[] faces = getAdjacentBlocks(block);
|
||||||
boolean protect = false;
|
boolean protect = false;
|
||||||
|
@ -81,7 +81,6 @@ public class EssentialsConf extends Configuration
|
|||||||
ostr.write(buffer, 0, length);
|
ostr.write(buffer, 0, length);
|
||||||
length = istr.read(buffer);
|
length = istr.read(buffer);
|
||||||
}
|
}
|
||||||
ostr.close();
|
|
||||||
istr.close();
|
istr.close();
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
@ -93,7 +92,9 @@ public class EssentialsConf extends Configuration
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ostr.close();
|
if (ostr != null) {
|
||||||
|
ostr.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (IOException ex)
|
catch (IOException ex)
|
||||||
{
|
{
|
||||||
|
@ -65,6 +65,7 @@ public class EssentialsEcoBlockListener extends BlockListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSignChange(SignChangeEvent event)
|
public void onSignChange(SignChangeEvent event)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import net.minecraft.server.InventoryPlayer;
|
import net.minecraft.server.InventoryPlayer;
|
||||||
@ -7,8 +8,8 @@ import org.bukkit.*;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Sign;
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.craftbukkit.block.CraftSign;
|
import org.bukkit.craftbukkit.block.CraftSign;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
|
||||||
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
|
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.player.*;
|
import org.bukkit.event.player.*;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -19,229 +20,14 @@ public class EssentialsPlayerListener extends PlayerListener
|
|||||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||||
private final Server server;
|
private final Server server;
|
||||||
private final Essentials parent;
|
private final Essentials parent;
|
||||||
|
private EssentialsBlockListener essBlockListener = null;
|
||||||
|
|
||||||
|
|
||||||
public EssentialsPlayerListener(Essentials parent)
|
public EssentialsPlayerListener(Essentials parent)
|
||||||
{
|
{
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.server = parent.getServer();
|
this.server = parent.getServer();
|
||||||
}
|
essBlockListener = new EssentialsBlockListener(parent);
|
||||||
|
|
||||||
private void onPlayerInteractEco(PlayerInteractEvent event)
|
|
||||||
{
|
|
||||||
if (Essentials.getSettings().areSignsDisabled()) return;
|
|
||||||
User user = User.get(event.getPlayer());
|
|
||||||
if (event.getClickedBlock().getType() != Material.WALL_SIGN && event.getClickedBlock().getType() != Material.SIGN_POST)
|
|
||||||
return;
|
|
||||||
Sign sign = new CraftSign(event.getClickedBlock());
|
|
||||||
|
|
||||||
if (sign.getLine(0).equals("§1[Buy]") && user.isAuthorized("essentials.signs.buy.use"))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
int amount = Integer.parseInt(sign.getLine(1));
|
|
||||||
ItemStack item = ItemDb.get(sign.getLine(2), amount);
|
|
||||||
int cost = Integer.parseInt(sign.getLine(3).substring(1));
|
|
||||||
if (user.getMoney() < cost) throw new Exception("You do not have sufficient funds.");
|
|
||||||
user.takeMoney(cost);
|
|
||||||
user.getInventory().addItem(item);
|
|
||||||
user.updateInventory();
|
|
||||||
}
|
|
||||||
catch (Throwable ex)
|
|
||||||
{
|
|
||||||
user.sendMessage("§cError: " + ex.getMessage());
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sign.getLine(0).equals("§1[Sell]") && user.isAuthorized("essentials.signs.sell.use"))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
int amount = Integer.parseInt(sign.getLine(1));
|
|
||||||
ItemStack item = ItemDb.get(sign.getLine(2), amount);
|
|
||||||
int cost = Integer.parseInt(sign.getLine(3).substring(1));
|
|
||||||
if (!InventoryWorkaround.containsItem((CraftInventory)user.getInventory(), true, item)) throw new Exception("You do not have enough items to sell.");
|
|
||||||
user.giveMoney(cost);
|
|
||||||
InventoryWorkaround.removeItem((CraftInventory)user.getInventory(), true, item);
|
|
||||||
user.updateInventory();
|
|
||||||
}
|
|
||||||
catch (Throwable ex)
|
|
||||||
{
|
|
||||||
user.sendMessage("§cError: " + ex.getMessage());
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sign.getLine(0).equals("§1[Trade]") && user.isAuthorized("essentials.signs.trade.use"))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
String[] l1 = sign.getLines()[1].split("[ :-]+");
|
|
||||||
String[] l2 = sign.getLines()[2].split("[ :-]+");
|
|
||||||
boolean m1 = l1[0].matches("\\$[0-9]+");
|
|
||||||
boolean m2 = l2[0].matches("\\$[0-9]+");
|
|
||||||
int q1 = Integer.parseInt(m1 ? l1[0].substring(1) : l1[0]);
|
|
||||||
int q2 = Integer.parseInt(m2 ? l2[0].substring(1) : l2[0]);
|
|
||||||
int r1 = Integer.parseInt(l1[m1 ? 1 : 2]);
|
|
||||||
int r2 = Integer.parseInt(l2[m2 ? 1 : 2]);
|
|
||||||
r1 = r1 - r1 % q1;
|
|
||||||
r2 = r2 - r2 % q2;
|
|
||||||
if (q1 < 1 || q2 < 1) throw new Exception("Quantities must be greater than 0.");
|
|
||||||
|
|
||||||
ItemStack i1 = m1 || r1 <= 0 ? null : ItemDb.get(l1[1], r1);
|
|
||||||
ItemStack qi1 = m1 ? null : ItemDb.get(l1[1], q1);
|
|
||||||
ItemStack qi2 = m2 ? null : ItemDb.get(l2[1], q2);
|
|
||||||
|
|
||||||
if (user.getName().equals(sign.getLines()[3].substring(2)))
|
|
||||||
{
|
|
||||||
if (m1)
|
|
||||||
{
|
|
||||||
user.giveMoney(r1);
|
|
||||||
}
|
|
||||||
else if (i1 != null)
|
|
||||||
{
|
|
||||||
user.getInventory().addItem(i1);
|
|
||||||
user.updateInventory();
|
|
||||||
}
|
|
||||||
r1 = 0;
|
|
||||||
sign.setLine(1, (m1 ? "$" + q1 : q1 + " " + l1[1]) + ":" + r1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (m1)
|
|
||||||
{
|
|
||||||
if (user.getMoney() < q1)
|
|
||||||
throw new Exception("You do not have sufficient funds.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!InventoryWorkaround.containsItem((CraftInventory)user.getInventory(), true, qi1))
|
|
||||||
throw new Exception("You do not have " + q1 + "x " + l1[1] + ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (r2 < q2) throw new Exception("The trade sign does not have enough supply left.");
|
|
||||||
|
|
||||||
if (m1)
|
|
||||||
user.takeMoney(q1);
|
|
||||||
else
|
|
||||||
InventoryWorkaround.removeItem((CraftInventory)user.getInventory(), true, qi1);
|
|
||||||
|
|
||||||
if (m2)
|
|
||||||
user.giveMoney(q2);
|
|
||||||
else
|
|
||||||
user.getInventory().addItem(qi2);
|
|
||||||
|
|
||||||
user.updateInventory();
|
|
||||||
|
|
||||||
r1 += q1;
|
|
||||||
r2 -= q2;
|
|
||||||
|
|
||||||
sign.setLine(0, "§1[Trade]");
|
|
||||||
sign.setLine(1, (m1 ? "$" + q1 : q1 + " " + l1[1]) + ":" + r1);
|
|
||||||
sign.setLine(2, (m2 ? "$" + q2 : q2 + " " + l2[1]) + ":" + r2);
|
|
||||||
|
|
||||||
user.sendMessage("§7Trade completed.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Throwable ex)
|
|
||||||
{
|
|
||||||
user.sendMessage("§cError: " + ex.getMessage());
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPlayerInteract(PlayerInteractEvent event)
|
|
||||||
{
|
|
||||||
if (event.isCancelled()) return;
|
|
||||||
User user = User.get(event.getPlayer());
|
|
||||||
if (user.isJailed())
|
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
onPlayerInteractEco(event);
|
|
||||||
onPlayerInteractSigns(event);
|
|
||||||
|
|
||||||
if (!Essentials.getSettings().areSignsDisabled() && EssentialsBlockListener.protectedBlocks.contains(event.getClickedBlock().getType()))
|
|
||||||
{
|
|
||||||
if (!user.isAuthorized("essentials.signs.protection.override"))
|
|
||||||
{
|
|
||||||
if (EssentialsBlockListener.isBlockProtected(event.getClickedBlock(), user))
|
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
|
||||||
user.sendMessage("§cYou do not have permission to access that chest.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Essentials.getSettings().getBedSetsHome() && event.getClickedBlock().getType() == Material.BED_BLOCK)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
user.setHome();
|
|
||||||
user.sendMessage("§7Your home is now set to this bed.");
|
|
||||||
}
|
|
||||||
catch (Throwable ex)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onPlayerInteractSigns(PlayerInteractEvent event)
|
|
||||||
{
|
|
||||||
User user = User.get(event.getPlayer());
|
|
||||||
if (user.isJailed()) return;
|
|
||||||
if (Essentials.getSettings().areSignsDisabled()) return;
|
|
||||||
if (event.getClickedBlock().getType() != Material.WALL_SIGN && event.getClickedBlock().getType() != Material.SIGN_POST)
|
|
||||||
return;
|
|
||||||
Sign sign = new CraftSign(event.getClickedBlock());
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (sign.getLine(0).equals("§1[Free]") && user.isAuthorized("essentials.signs.free.use"))
|
|
||||||
{
|
|
||||||
ItemStack item = ItemDb.get(sign.getLine(1));
|
|
||||||
CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(user.getHandle()));
|
|
||||||
inv.clear();
|
|
||||||
item.setAmount(9 * 4 * 64);
|
|
||||||
inv.addItem(item);
|
|
||||||
user.showInventory(inv);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (sign.getLine(0).equals("§1[Disposal]") && user.isAuthorized("essentials.signs.disposal.use"))
|
|
||||||
{
|
|
||||||
CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(user.getHandle()));
|
|
||||||
inv.clear();
|
|
||||||
user.showInventory(inv);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (sign.getLine(0).equals("§1[Heal]") && user.isAuthorized("essentials.signs.heal.use"))
|
|
||||||
{
|
|
||||||
user.setHealth(20);
|
|
||||||
user.sendMessage("§7You have been healed.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (sign.getLine(0).equals("§1[Mail]") && user.isAuthorized("essentials.signs.mail.use") && user.isAuthorized("essentials.mail"))
|
|
||||||
{
|
|
||||||
List<String> mail = Essentials.readMail(user);
|
|
||||||
if (mail.isEmpty())
|
|
||||||
{
|
|
||||||
user.sendMessage("§cYou do not have any mail!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (String s : mail) user.sendMessage(s);
|
|
||||||
user.sendMessage("§cTo mark your mail as read, type §c/mail clear");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Throwable ex)
|
|
||||||
{
|
|
||||||
user.sendMessage("§cError: " + ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -342,11 +128,12 @@ public class EssentialsPlayerListener extends PlayerListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerQuit(PlayerQuitEvent event)
|
public void onPlayerQuit(PlayerEvent event)
|
||||||
{
|
{
|
||||||
if (!Essentials.getSettings().getReclaimSetting())
|
if (!Essentials.getSettings().getReclaimSetting())
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
User.get(event.getPlayer()).dispose();
|
User.get(event.getPlayer()).dispose();
|
||||||
Thread thread = new Thread(new Runnable()
|
Thread thread = new Thread(new Runnable()
|
||||||
{
|
{
|
||||||
@ -375,7 +162,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
public void onPlayerJoin(PlayerEvent event)
|
||||||
{
|
{
|
||||||
Essentials.getStatic().backup.onPlayerJoin();
|
Essentials.getStatic().backup.onPlayerJoin();
|
||||||
User user = User.get(event.getPlayer());
|
User user = User.get(event.getPlayer());
|
||||||
@ -441,7 +228,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
public void onPlayerTeleport(PlayerMoveEvent event)
|
||||||
{
|
{
|
||||||
User user = User.get(event.getPlayer());
|
User user = User.get(event.getPlayer());
|
||||||
if (user.currentJail == null || user.currentJail.isEmpty())
|
if (user.currentJail == null || user.currentJail.isEmpty())
|
||||||
@ -449,4 +236,87 @@ public class EssentialsPlayerListener extends PlayerListener
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
user.sendMessage(ChatColor.RED + "You do the crime, you do the time.");
|
user.sendMessage(ChatColor.RED + "You do the crime, you do the time.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerInteract(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (event.isCancelled()) return;
|
||||||
|
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
||||||
|
User user = User.get(event.getPlayer());
|
||||||
|
if (user.isJailed()) return;
|
||||||
|
if (!Essentials.getSettings().areSignsDisabled() && EssentialsBlockListener.protectedBlocks.contains(event.getClickedBlock().getType()))
|
||||||
|
{
|
||||||
|
if (!user.isAuthorized("essentials.signs.protection.override"))
|
||||||
|
{
|
||||||
|
if (essBlockListener.isBlockProtected(event.getClickedBlock(), user))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
user.sendMessage("§cYou do not have permission to access that chest.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Essentials.getSettings().getBedSetsHome() && event.getClickedBlock().getType() == Material.BED_BLOCK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
user.setHome();
|
||||||
|
user.sendMessage("§7Your home is now set to this bed.");
|
||||||
|
}
|
||||||
|
catch (Throwable ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (Essentials.getSettings().areSignsDisabled()) return;
|
||||||
|
if (event.getClickedBlock().getType() != Material.WALL_SIGN && event.getClickedBlock().getType() != Material.SIGN_POST)
|
||||||
|
return;
|
||||||
|
Sign sign = new CraftSign(event.getClickedBlock());
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (sign.getLine(0).equals("§1[Free]") && user.isAuthorized("essentials.signs.free.use"))
|
||||||
|
{
|
||||||
|
ItemStack item = ItemDb.get(sign.getLine(1));
|
||||||
|
CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(user.getHandle()));
|
||||||
|
inv.clear();
|
||||||
|
item.setAmount(9 * 4 * 64);
|
||||||
|
inv.addItem(item);
|
||||||
|
user.showInventory(inv);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (sign.getLine(0).equals("§1[Disposal]") && user.isAuthorized("essentials.signs.disposal.use"))
|
||||||
|
{
|
||||||
|
CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(user.getHandle()));
|
||||||
|
inv.clear();
|
||||||
|
user.showInventory(inv);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (sign.getLine(0).equals("§1[Heal]") && user.isAuthorized("essentials.signs.heal.use"))
|
||||||
|
{
|
||||||
|
user.setHealth(20);
|
||||||
|
user.sendMessage("§7You have been healed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (sign.getLine(0).equals("§1[Mail]") && user.isAuthorized("essentials.signs.mail.use") && user.isAuthorized("essentials.mail"))
|
||||||
|
{
|
||||||
|
List<String> mail = Essentials.readMail(user);
|
||||||
|
if (mail.isEmpty())
|
||||||
|
{
|
||||||
|
user.sendMessage("§cYou do not have any mail!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (String s : mail) user.sendMessage(s);
|
||||||
|
user.sendMessage("§cTo mark your mail as read, type §c/mail clear");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Throwable ex)
|
||||||
|
{
|
||||||
|
user.sendMessage("§cError: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,25 +7,24 @@ import java.util.Map;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockDamageEvent;
|
import org.bukkit.event.block.BlockDamageEvent;
|
||||||
|
import org.bukkit.event.block.BlockInteractEvent;
|
||||||
import org.bukkit.event.block.BlockListener;
|
import org.bukkit.event.block.BlockListener;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.event.player.PlayerListener;
|
||||||
|
|
||||||
|
public class Jail extends BlockListener implements IConf {
|
||||||
public class Jail extends BlockListener implements IConf
|
|
||||||
{
|
|
||||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||||
private EssentialsConf config;
|
private EssentialsConf config;
|
||||||
|
|
||||||
public Jail(File dataFolder)
|
public Jail(File dataFolder) {
|
||||||
{
|
|
||||||
config = new EssentialsConf(new File(dataFolder, "jail.yml"));
|
config = new EssentialsConf(new File(dataFolder, "jail.yml"));
|
||||||
config.load();
|
config.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJail(Location loc, String jailName) throws Exception
|
public void setJail(Location loc, String jailName) throws Exception {
|
||||||
{
|
|
||||||
Map<String, Object> map = new HashMap<String, Object>();
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
map.put("world", loc.getWorld().getName());
|
map.put("world", loc.getWorld().getName());
|
||||||
map.put("x", loc.getX());
|
map.put("x", loc.getX());
|
||||||
@ -37,10 +36,8 @@ public class Jail extends BlockListener implements IConf
|
|||||||
config.save();
|
config.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getJail(String jailName) throws Exception
|
public Location getJail(String jailName) throws Exception {
|
||||||
{
|
if (config.getProperty(jailName.toLowerCase()) == null) {
|
||||||
if (config.getProperty(jailName.toLowerCase()) == null)
|
|
||||||
{
|
|
||||||
throw new Exception("That jail does not exist");
|
throw new Exception("That jail does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,12 +46,10 @@ public class Jail extends BlockListener implements IConf
|
|||||||
double x = config.getDouble(jailName + ".x", 0); // wh.spawnX
|
double x = config.getDouble(jailName + ".x", 0); // wh.spawnX
|
||||||
double y = config.getDouble(jailName + ".y", 0); // wh.spawnY
|
double y = config.getDouble(jailName + ".y", 0); // wh.spawnY
|
||||||
double z = config.getDouble(jailName + ".z", 0); // wh.spawnZ
|
double z = config.getDouble(jailName + ".z", 0); // wh.spawnZ
|
||||||
float yaw = (float)config.getDouble(jailName + ".yaw", 0);
|
float yaw = (float) config.getDouble(jailName + ".yaw", 0);
|
||||||
float pitch = (float)config.getDouble(jailName + ".pitch", 0);
|
float pitch = (float) config.getDouble(jailName + ".pitch", 0);
|
||||||
for (World w : Essentials.getStatic().getServer().getWorlds())
|
for (World w : Essentials.getStatic().getServer().getWorlds()) {
|
||||||
{
|
if (w.getName().equalsIgnoreCase(world)) {
|
||||||
if (w.getName().equalsIgnoreCase(world))
|
|
||||||
{
|
|
||||||
jWorld = w;
|
jWorld = w;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -63,34 +58,29 @@ public class Jail extends BlockListener implements IConf
|
|||||||
return new Location(jWorld, x, y, z, yaw, pitch);
|
return new Location(jWorld, x, y, z, yaw, pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendToJail(User user, String jail) throws Exception
|
public void sendToJail(User user, String jail) throws Exception {
|
||||||
{
|
user.teleportTo(getJail(jail));
|
||||||
user.teleport(getJail(jail));
|
|
||||||
user.currentJail = jail;
|
user.currentJail = jail;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delJail(String jail) throws Exception
|
public void delJail(String jail) throws Exception {
|
||||||
{
|
|
||||||
config.removeProperty(jail.toLowerCase());
|
config.removeProperty(jail.toLowerCase());
|
||||||
config.save();
|
config.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getJails() throws Exception
|
public List<String> getJails() throws Exception {
|
||||||
{
|
|
||||||
return config.getKeys(null);
|
return config.getKeys(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadConfig()
|
public void reloadConfig() {
|
||||||
{
|
|
||||||
config.load();
|
config.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockBreak(BlockBreakEvent event)
|
public void onBlockBreak(BlockBreakEvent event)
|
||||||
{
|
{
|
||||||
User user = User.get(event.getPlayer());
|
User user = User.get(event.getPlayer());
|
||||||
if (user.isJailed())
|
if (user.isJailed()) {
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,19 +89,18 @@ public class Jail extends BlockListener implements IConf
|
|||||||
public void onBlockPlace(BlockPlaceEvent event)
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
{
|
{
|
||||||
User user = User.get(event.getPlayer());
|
User user = User.get(event.getPlayer());
|
||||||
if (user.isJailed())
|
if (user.isJailed()) {
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockDamage(BlockDamageEvent event)
|
public void onBlockDamage(BlockDamageEvent event) {
|
||||||
{
|
|
||||||
User user = User.get(event.getPlayer());
|
User user = User.get(event.getPlayer());
|
||||||
if (user.isJailed())
|
if (user.isJailed()) {
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -283,69 +283,4 @@ public class OfflinePlayer implements Player
|
|||||||
public void sendRawMessage(String string) {
|
public void sendRawMessage(String string) {
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getCompassTarget()
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaximumNoDamageTicks()
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMaximumNoDamageTicks(int i)
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLastDamage()
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastDamage(int i)
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getNoDamageTicks()
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNoDamageTicks(int i)
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean teleport(Location lctn)
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean teleport(Entity entity)
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public Entity getPassenger()
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean setPassenger(Entity entity)
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEmpty()
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean eject()
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -154,15 +154,15 @@ public class PlayerWrapper implements Player
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean teleport(Location lctn)
|
public void teleportTo(Location lctn)
|
||||||
{
|
{
|
||||||
return base.teleport(lctn);
|
base.teleportTo(lctn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean teleport(Entity entity)
|
public void teleportTo(Entity entity)
|
||||||
{
|
{
|
||||||
return base.teleport(entity);
|
base.teleportTo(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -329,88 +329,7 @@ public class PlayerWrapper implements Player
|
|||||||
return base.getEyeLocation();
|
return base.getEyeLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendRawMessage(String string) {
|
public void sendRawMessage(String string) {
|
||||||
base.sendRawMessage(string);
|
base.sendRawMessage(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Location getCompassTarget()
|
|
||||||
{
|
|
||||||
return base.getCompassTarget();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMaximumNoDamageTicks()
|
|
||||||
{
|
|
||||||
return base.getMaximumNoDamageTicks();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setMaximumNoDamageTicks(int i)
|
|
||||||
{
|
|
||||||
base.setMaximumNoDamageTicks(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLastDamage()
|
|
||||||
{
|
|
||||||
return base.getLastDamage();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setLastDamage(int i)
|
|
||||||
{
|
|
||||||
base.setLastDamage(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getNoDamageTicks()
|
|
||||||
{
|
|
||||||
return base.getNoDamageTicks();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setNoDamageTicks(int i)
|
|
||||||
{
|
|
||||||
base.setNoDamageTicks(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Entity getPassenger()
|
|
||||||
{
|
|
||||||
return base.getPassenger();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setPassenger(Entity entity)
|
|
||||||
{
|
|
||||||
return base.setPassenger(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isEmpty()
|
|
||||||
{
|
|
||||||
return base.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean eject()
|
|
||||||
{
|
|
||||||
return base.eject();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public void teleportTo(Location lctn)
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public void teleportTo(Entity entity)
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ public class User extends PlayerExtension implements Comparable<User>
|
|||||||
|
|
||||||
public void respawn(Spawn spawn, final String chargeFor) throws Exception
|
public void respawn(Spawn spawn, final String chargeFor) throws Exception
|
||||||
{
|
{
|
||||||
teleport(getSafeDestination(spawn.getSpawn(getGroup())), chargeFor);
|
teleportTo(getSafeDestination(spawn.getSpawn(getGroup())), chargeFor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private User update(Player base)
|
private User update(Player base)
|
||||||
@ -383,7 +383,7 @@ public class User extends PlayerExtension implements Comparable<User>
|
|||||||
cancelTeleport(false);
|
cancelTeleport(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean teleport(final Location loc, final String chargeFor)
|
public void teleportTo(final Location loc, final String chargeFor)
|
||||||
{
|
{
|
||||||
final long delay = Essentials.getSettings().getTeleportDelay();
|
final long delay = Essentials.getSettings().getTeleportDelay();
|
||||||
|
|
||||||
@ -393,13 +393,13 @@ public class User extends PlayerExtension implements Comparable<User>
|
|||||||
{
|
{
|
||||||
if (chargeFor != null) charge(chargeFor);
|
if (chargeFor != null) charge(chargeFor);
|
||||||
teleportCooldown(false);
|
teleportCooldown(false);
|
||||||
return teleportToNow(loc);
|
teleportToNow(loc);
|
||||||
}
|
}
|
||||||
catch (Throwable ex)
|
catch (Throwable ex)
|
||||||
{
|
{
|
||||||
sendMessage("§cError: " + ex.getMessage());
|
sendMessage("§cError: " + ex.getMessage());
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelTeleport();
|
cancelTeleport();
|
||||||
@ -424,16 +424,15 @@ public class User extends PlayerExtension implements Comparable<User>
|
|||||||
cancelTeleport();
|
cancelTeleport();
|
||||||
}
|
}
|
||||||
}, 10, 10);
|
}, 10, 10);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean teleport(final Location loc)
|
public void teleportTo(final Location loc)
|
||||||
{
|
{
|
||||||
return teleport(loc, null);
|
teleportTo(loc, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean teleport(final Entity entity, final String chargeFor)
|
public void teleportTo(final Entity entity, final String chargeFor)
|
||||||
{
|
{
|
||||||
final long delay = Essentials.getSettings().getTeleportDelay();
|
final long delay = Essentials.getSettings().getTeleportDelay();
|
||||||
|
|
||||||
@ -443,13 +442,13 @@ public class User extends PlayerExtension implements Comparable<User>
|
|||||||
{
|
{
|
||||||
if (chargeFor != null) charge(chargeFor);
|
if (chargeFor != null) charge(chargeFor);
|
||||||
teleportCooldown(false);
|
teleportCooldown(false);
|
||||||
return teleportToNow(entity);
|
teleportToNow(entity);
|
||||||
}
|
}
|
||||||
catch (Throwable ex)
|
catch (Throwable ex)
|
||||||
{
|
{
|
||||||
sendMessage("§cError: " + ex.getMessage());
|
sendMessage("§cError: " + ex.getMessage());
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cancelTeleport();
|
cancelTeleport();
|
||||||
@ -474,13 +473,12 @@ public class User extends PlayerExtension implements Comparable<User>
|
|||||||
cancelTeleport();
|
cancelTeleport();
|
||||||
}
|
}
|
||||||
}, 10, 10);
|
}, 10, 10);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean teleport(final Entity entity)
|
public void teleportTo(final Entity entity)
|
||||||
{
|
{
|
||||||
return teleport(entity, null);
|
teleportTo(entity, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getHome() throws Exception
|
public Location getHome() throws Exception
|
||||||
@ -581,23 +579,23 @@ public class User extends PlayerExtension implements Comparable<User>
|
|||||||
teleportToHome(null);
|
teleportToHome(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean teleportToNow(Location loc) throws Exception
|
public void teleportToNow(Location loc) throws Exception
|
||||||
{
|
{
|
||||||
cancelTeleport();
|
cancelTeleport();
|
||||||
lastLocation = getLocation();
|
lastLocation = getLocation();
|
||||||
return getBase().teleport(getSafeDestination(loc));
|
getBase().teleportTo(getSafeDestination(loc));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean teleportToNow(Entity entity)
|
public void teleportToNow(Entity entity)
|
||||||
{
|
{
|
||||||
cancelTeleport();
|
cancelTeleport();
|
||||||
lastLocation = getLocation();
|
lastLocation = getLocation();
|
||||||
return getBase().teleport(entity);
|
getBase().teleportTo(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void teleportBack(final String chargeFor)
|
public void teleportBack(final String chargeFor)
|
||||||
{
|
{
|
||||||
teleport(lastLocation, chargeFor);
|
teleportTo(lastLocation, chargeFor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void teleportBack()
|
public void teleportBack()
|
||||||
@ -669,7 +667,7 @@ public class User extends PlayerExtension implements Comparable<User>
|
|||||||
{
|
{
|
||||||
lastLocation = getLocation();
|
lastLocation = getLocation();
|
||||||
Location loc = Essentials.getWarps().getWarp(warp);
|
Location loc = Essentials.getWarps().getWarp(warp);
|
||||||
teleport(loc, chargeFor);
|
teleportTo(loc, chargeFor);
|
||||||
sendMessage("§7Warping to " + warp + ".");
|
sendMessage("§7Warping to " + warp + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
|||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import com.earth2me.essentials.Essentials;
|
import com.earth2me.essentials.Essentials;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
|
||||||
public class Commandbroadcast extends EssentialsCommand
|
public class Commandbroadcast extends EssentialsCommand
|
||||||
@ -13,11 +14,11 @@ public class Commandbroadcast extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(Server server, Essentials parent, User user, String commandLabel, String[] args) throws Exception
|
public void run(Server server, Essentials parent, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||||
{
|
{
|
||||||
if (args.length < 1)
|
if (args.length < 1)
|
||||||
{
|
{
|
||||||
user.sendMessage("Usage: /" + commandLabel + " [msg]");
|
sender.sendMessage("Usage: /" + commandLabel + " [msg]");
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder message = new StringBuilder();
|
StringBuilder message = new StringBuilder();
|
||||||
|
@ -45,6 +45,6 @@ public class Commandjump extends EssentialsCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
user.canAfford(this);
|
user.canAfford(this);
|
||||||
user.teleport(loc, this.getName());
|
user.teleportTo(loc, this.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,6 @@ public class Commandme extends EssentialsCommand
|
|||||||
@Override
|
@Override
|
||||||
public void run(Server server, Essentials parent, User user, String commandLabel, String[] args) throws Exception
|
public void run(Server server, Essentials parent, User user, String commandLabel, String[] args) throws Exception
|
||||||
{
|
{
|
||||||
if (user.isMuted())
|
|
||||||
{ user.sendMessage("§7Your voice has been silenced");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length < 1)
|
if (args.length < 1)
|
||||||
{
|
{
|
||||||
user.sendMessage("§cUsage: /me [description]");
|
user.sendMessage("§cUsage: /me [description]");
|
||||||
|
@ -20,7 +20,7 @@ public class Commandtop extends EssentialsCommand
|
|||||||
int topZ = user.getLocation().getBlockZ();
|
int topZ = user.getLocation().getBlockZ();
|
||||||
int topY = user.getWorld().getHighestBlockYAt(topX, topZ);
|
int topY = user.getWorld().getHighestBlockYAt(topX, topZ);
|
||||||
user.charge(this);
|
user.charge(this);
|
||||||
user.teleport(new Location(user.getWorld(), user.getLocation().getX(), topY + 1, user.getLocation().getZ()), this.getName());
|
user.teleportTo(new Location(user.getWorld(), user.getLocation().getX(), topY + 1, user.getLocation().getZ()), this.getName());
|
||||||
user.sendMessage("§7Teleporting to top.");
|
user.sendMessage("§7Teleporting to top.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ public class Commandtp extends EssentialsCommand
|
|||||||
if (!p.isTeleEnabled()) throw new Exception(p.getDisplayName() + " has teleportation disabled.");
|
if (!p.isTeleEnabled()) throw new Exception(p.getDisplayName() + " has teleportation disabled.");
|
||||||
user.sendMessage("§7Teleporting...");
|
user.sendMessage("§7Teleporting...");
|
||||||
user.canAfford(this);
|
user.canAfford(this);
|
||||||
user.teleport(p, this.getName());
|
user.teleportTo(p, this.getName());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -27,14 +27,14 @@ public class Commandtpaccept extends EssentialsCommand
|
|||||||
user.canAfford(this);
|
user.canAfford(this);
|
||||||
user.sendMessage("§7Teleport request accepted.");
|
user.sendMessage("§7Teleport request accepted.");
|
||||||
p.sendMessage("§7Teleport request accepted.");
|
p.sendMessage("§7Teleport request accepted.");
|
||||||
user.teleport(p, this.getName());
|
user.teleportTo(p, this.getName());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
user.canAfford(this);
|
user.canAfford(this);
|
||||||
user.sendMessage("§7Teleport request accepted.");
|
user.sendMessage("§7Teleport request accepted.");
|
||||||
p.sendMessage("§7Teleport request accepted.");
|
p.sendMessage("§7Teleport request accepted.");
|
||||||
p.teleport(user, this.getName());
|
p.teleportTo(user, this.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,6 @@ public class Commandtppos extends EssentialsCommand
|
|||||||
user.canAfford(this);
|
user.canAfford(this);
|
||||||
user.teleportCooldown();
|
user.teleportCooldown();
|
||||||
user.sendMessage("§7Teleporting...");
|
user.sendMessage("§7Teleporting...");
|
||||||
user.teleport(user.getSafeDestination(l), this.getName());
|
user.teleportTo(user.getSafeDestination(l), this.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -34,9 +34,9 @@ public class Commandwhois extends EssentialsCommand
|
|||||||
sender.sendMessage("");
|
sender.sendMessage("");
|
||||||
sender.sendMessage(u.getDisplayName() + " is " + u.getName());
|
sender.sendMessage(u.getDisplayName() + " is " + u.getName());
|
||||||
sender.sendMessage(ChatColor.BLUE + " - Health: " + u.getHealth() + "/20");
|
sender.sendMessage(ChatColor.BLUE + " - Health: " + u.getHealth() + "/20");
|
||||||
sender.sendMessage(ChatColor.BLUE + " - Location: (" + u.getLocation().getBlockX() + ", " + u.getLocation().getBlockY() + ", " + u.getLocation().getBlockZ() + ")");
|
sender.sendMessage(ChatColor.BLUE + " - Location: (" + u.getLocation().getWorld().getName() + ", " + u.getLocation().getBlockX() + ", " + u.getLocation().getBlockY() + ", " + u.getLocation().getBlockZ() + ")");
|
||||||
if (!parent.getConfiguration().getBoolean("disable-eco", false)) sender.sendMessage(ChatColor.BLUE + " - Money: $" + u.getMoney());
|
if (!parent.getConfiguration().getBoolean("disable-eco", false)) sender.sendMessage(ChatColor.BLUE + " - Money: $" + u.getMoney());
|
||||||
sender.sendMessage(ChatColor.BLUE + " - Status: " + (parent.away.contains(u) ? "§cAway" : "Available"));
|
sender.sendMessage(ChatColor.BLUE + " - Status: " + (parent.away.contains(u) ? "§cAway§f" : "Available"));
|
||||||
sender.sendMessage(ChatColor.BLUE + " - IP Address: " + u.getAddress().getAddress().toString());
|
sender.sendMessage(ChatColor.BLUE + " - IP Address: " + u.getAddress().getAddress().toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,6 @@ public class Commandworld extends EssentialsCommand
|
|||||||
|
|
||||||
user.canAfford(this);
|
user.canAfford(this);
|
||||||
user.teleportCooldown();
|
user.teleportCooldown();
|
||||||
user.teleport(loc, this.getName());
|
user.teleportTo(loc, this.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,6 +181,7 @@ bed-sethome: false
|
|||||||
starting-balance: 0
|
starting-balance: 0
|
||||||
|
|
||||||
# worth-# defines the value of an item when it is sold to the server via /sell.
|
# worth-# defines the value of an item when it is sold to the server via /sell.
|
||||||
|
# For a premade list which you may copy and paste in: http://pastie.org/1707782
|
||||||
#worth-1: 1
|
#worth-1: 1
|
||||||
#worth-278: 1000
|
#worth-278: 1000
|
||||||
|
|
||||||
@ -234,14 +235,14 @@ mcsl-key: ''
|
|||||||
chat:
|
chat:
|
||||||
radius: 0
|
radius: 0
|
||||||
|
|
||||||
# If you want the default chat format, uncomment the next line and comment the other format.
|
# If set to the default chat format which "should" be compatible with ichat.
|
||||||
#format: '<{DISPLAYNAME}> {MESSAGE}'
|
format: '<{DISPLAYNAME}> {MESSAGE}'
|
||||||
format: '&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}'
|
#format: '&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}'
|
||||||
|
|
||||||
# You can also have group-specific formats:
|
# You can also have group-specific formats, uncomment to enable:
|
||||||
group-formats:
|
group-formats:
|
||||||
Default: '{WORLDNAME} {DISPLAYNAME}&7:&f {MESSAGE}'
|
# Default: '{WORLDNAME} {DISPLAYNAME}&7:&f {MESSAGE}'
|
||||||
Admins: '{WORLDNAME} &c[{GROUP}]&f {DISPLAYNAME}&7:&c {MESSAGE}'
|
# Admins: '{WORLDNAME} &c[{GROUP}]&f {DISPLAYNAME}&7:&c {MESSAGE}'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -268,7 +269,7 @@ protect:
|
|||||||
mysqlDb: 'jdbc:mysql://localhost:3306/minecraft'
|
mysqlDb: 'jdbc:mysql://localhost:3306/minecraft'
|
||||||
|
|
||||||
# For which block types would you like to be alerted?
|
# For which block types would you like to be alerted?
|
||||||
# You can find a list of IDs in plugins/Essentials/Items.csv after loading Essentials for the first time.
|
# You can find a list of IDs in plugins/Essentials/items.csv after loading Essentials for the first time.
|
||||||
alert:
|
alert:
|
||||||
# 10: lava
|
# 10: lava
|
||||||
# 11: still lava
|
# 11: still lava
|
||||||
@ -347,7 +348,7 @@ protect:
|
|||||||
# Should damage via lava be disabled? Items that fall into lava will still burn to a crisp. ;)
|
# Should damage via lava be disabled? Items that fall into lava will still burn to a crisp. ;)
|
||||||
lavadmg: false
|
lavadmg: false
|
||||||
|
|
||||||
# Should arrow damage be disabled
|
# Should arrows cause damage?
|
||||||
projectiles: false
|
projectiles: false
|
||||||
|
|
||||||
# This will disable damage from touching cacti.
|
# This will disable damage from touching cacti.
|
||||||
@ -382,4 +383,4 @@ newbies:
|
|||||||
# When we spawn for the first time, which spawnpoint do we use?
|
# When we spawn for the first time, which spawnpoint do we use?
|
||||||
spawnpoint: newbies
|
spawnpoint: newbies
|
||||||
|
|
||||||
# End of File <-- No seriously, you're done with configuration.
|
# End of File <-- No seriously, you're done with configuration.
|
||||||
|
@ -28,14 +28,62 @@ ironore,15,0
|
|||||||
iore,15,0
|
iore,15,0
|
||||||
coalore,16,0
|
coalore,16,0
|
||||||
core,16,0
|
core,16,0
|
||||||
|
tree,17,0
|
||||||
log,17,0
|
log,17,0
|
||||||
trunk,17,0
|
trunk,17,0
|
||||||
wood,17,0
|
wood,17,0
|
||||||
redwood,5,1
|
redtree,17,1
|
||||||
rwood,5,1
|
redlog,17,1
|
||||||
birchwood,5,2
|
redtrunk,17,1
|
||||||
birch,5,2
|
redwood,17,1
|
||||||
bwood,5,2
|
darktree,17,1
|
||||||
|
darklog,17,1
|
||||||
|
darktrunk,17,1
|
||||||
|
darkwood,17,1
|
||||||
|
blacktree,17,1
|
||||||
|
blacklog,17,1
|
||||||
|
blacktrunk,17,1
|
||||||
|
blackwood,17,1
|
||||||
|
rtree,17,1
|
||||||
|
rlog,17,1
|
||||||
|
rtrunk,17,1
|
||||||
|
rwood,17,1
|
||||||
|
dtree,17,1
|
||||||
|
dlog,17,1
|
||||||
|
dtrunk,17,1
|
||||||
|
dwood,17,1
|
||||||
|
bltree,17,1
|
||||||
|
bllog,17,1
|
||||||
|
bltrunk,17,1
|
||||||
|
blwood,17,1
|
||||||
|
birchtree,17,2
|
||||||
|
birchlog,17,2
|
||||||
|
birchtrunk,17,2
|
||||||
|
birchwood,17,2
|
||||||
|
pandatree,17,2
|
||||||
|
pandalog,17,2
|
||||||
|
pandatrunk,17,2
|
||||||
|
pandawood,17,2
|
||||||
|
whitetree,17,2
|
||||||
|
whitelog,17,2
|
||||||
|
whitetrunk,17,2
|
||||||
|
whitewood,17,2
|
||||||
|
bitree,17,2
|
||||||
|
bilog,17,2
|
||||||
|
bitrunk,17,2
|
||||||
|
biwood,17,2
|
||||||
|
btree,17,2
|
||||||
|
blog,17,2
|
||||||
|
btrunk,17,2
|
||||||
|
bwood,17,2
|
||||||
|
ptree,17,2
|
||||||
|
plog,17,2
|
||||||
|
ptrunk,17,2
|
||||||
|
pwood,17,2
|
||||||
|
wtree,17,2
|
||||||
|
wlog,17,2
|
||||||
|
wtrunk,17,2
|
||||||
|
wwood,17,2
|
||||||
leaves,18,0
|
leaves,18,0
|
||||||
sponge,19,0
|
sponge,19,0
|
||||||
glass,20,0
|
glass,20,0
|
||||||
|
|
@ -2,7 +2,10 @@ package com.earth2me.essentials.chat;
|
|||||||
|
|
||||||
import com.earth2me.essentials.Essentials;
|
import com.earth2me.essentials.Essentials;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.event.player.*;
|
import org.bukkit.event.player.PlayerChatEvent;
|
||||||
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
|
import org.bukkit.event.player.PlayerListener;
|
||||||
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
|
|
||||||
|
|
||||||
public class EssentialsChatPlayerListener extends PlayerListener
|
public class EssentialsChatPlayerListener extends PlayerListener
|
||||||
@ -16,7 +19,7 @@ public class EssentialsChatPlayerListener extends PlayerListener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("CallToThreadDumpStack")
|
@SuppressWarnings("CallToThreadDumpStack")
|
||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
public void onPlayerJoin(PlayerEvent event)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -52,20 +52,15 @@ public class EssentialsChatWorker
|
|||||||
|
|
||||||
public static void onPlayerChat(Server server, PlayerChatEvent event)
|
public static void onPlayerChat(Server server, PlayerChatEvent event)
|
||||||
{
|
{
|
||||||
|
if (event.isCancelled()) return;
|
||||||
User user = User.get(event.getPlayer());
|
User user = User.get(event.getPlayer());
|
||||||
updateDisplayName(user);
|
updateDisplayName(user);
|
||||||
|
|
||||||
if (user.isAuthorized("essentials.chat.color"))
|
if (user.isAuthorized("essentials.chat.color"))
|
||||||
event.setMessage(event.getMessage().replaceAll("&([0-9a-f])", "§$1"));
|
event.setMessage(event.getMessage().replaceAll("&([0-9a-f])", "§$1"));
|
||||||
|
|
||||||
event.setFormat(Essentials.getSettings().getChatFormat(user.getGroup())
|
event.setFormat(Essentials.getSettings().getChatFormat(user.getGroup()).replace('&', '§').replace("§§", "&").replace("{DISPLAYNAME}", "%1$s").replace("{GROUP}", user.getGroup()).replace("{MESSAGE}", "%2$s").replace("{WORLDNAME}", user.getWorld().getName()));
|
||||||
.replace('&', '§')
|
|
||||||
.replace("§§", "&")
|
|
||||||
.replace("{DISPLAYNAME}", "%1$s")
|
|
||||||
.replace("{GROUP}", user.getGroup())
|
|
||||||
.replace("{MESSAGE}", "%2$s")
|
|
||||||
.replace("{WORLDNAME}", user.getWorld().getName()));
|
|
||||||
|
|
||||||
int radius = Essentials.getSettings().getChatRadius();
|
int radius = Essentials.getSettings().getChatRadius();
|
||||||
if (radius < 1) return;
|
if (radius < 1) return;
|
||||||
|
|
||||||
@ -81,7 +76,7 @@ public class EssentialsChatWorker
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getMessage().startsWith("?") && event.getMessage().length() > 1)
|
if (event.getMessage().startsWith("?") && event.getMessage().length() > 1)
|
||||||
{
|
{
|
||||||
if (user.isAuthorized("essentials.chat.question"))
|
if (user.isAuthorized("essentials.chat.question"))
|
||||||
|
@ -1,172 +1,147 @@
|
|||||||
groups:
|
groups:
|
||||||
Default:
|
Default:
|
||||||
default: true
|
default: true
|
||||||
permissions:
|
permissions:
|
||||||
- essentials.help
|
- essentials.help
|
||||||
- essentials.home
|
- essentials.helpop
|
||||||
- essentials.motd
|
- essentials.list
|
||||||
- essentials.sethome
|
- essentials.motd
|
||||||
- essentials.spawn
|
- essentials.rules
|
||||||
inheritance: []
|
- essentials.spawn
|
||||||
info:
|
inheritance: []
|
||||||
prefix: ''
|
info:
|
||||||
build: false
|
prefix: '&e'
|
||||||
suffix: ''
|
build: false
|
||||||
SemiAdmin:
|
suffix: ''
|
||||||
default: false
|
SemiAdmin:
|
||||||
permissions:
|
default: false
|
||||||
- +groupmanager.mandemote
|
permissions:
|
||||||
- +groupmanager.manpromote
|
- -groupmanager.mantogglesave
|
||||||
- -groupmanager.*
|
- essentials
|
||||||
- '*'
|
- essentials.clearinventory
|
||||||
inheritance:
|
- essentials.cooldown.bypass
|
||||||
- moderator
|
- essentials.deljail
|
||||||
info:
|
- essentials.give
|
||||||
prefix: '&c'
|
- essentials.god
|
||||||
build: true
|
- essentials.heal
|
||||||
suffix: SemiAdmin
|
- essentials.heal.others
|
||||||
RedFaction:
|
- essentials.invsee
|
||||||
default: false
|
- essentials.item
|
||||||
permissions: []
|
- essentials.jails
|
||||||
inheritance:
|
- essentials.kickall
|
||||||
- peasant
|
- essentials.kit.*
|
||||||
info:
|
- essentials.mute
|
||||||
prefix: '&c'
|
- essentials.sell
|
||||||
roles-category: faction
|
- essentials.setjail
|
||||||
build: true
|
- essentials.signs.protection.override
|
||||||
suffix: Red
|
- essentials.spawmob
|
||||||
Farmer:
|
- essentials.teleport.cooldown.bypass
|
||||||
default: false
|
- essentials.teleport.timer.bypass
|
||||||
permissions:
|
- essentials.togglejail
|
||||||
- essentials.kit
|
- groupmanager.*
|
||||||
- essentials.kit.farmer
|
- essentials.burn
|
||||||
- essentials.spawnmob
|
inheritance:
|
||||||
inheritance: []
|
- moderator
|
||||||
info:
|
info:
|
||||||
roles-requirement:
|
prefix: '&c'
|
||||||
- BlueFaction
|
build: true
|
||||||
- RedFaction
|
suffix: ''
|
||||||
prefix: ''
|
Builder:
|
||||||
roles-category: job
|
default: false
|
||||||
build: false
|
permissions:
|
||||||
suffix: ''
|
- essentials.afk
|
||||||
Healer:
|
- essentials.back.ondeath
|
||||||
default: false
|
- essentials.balance
|
||||||
permissions:
|
- essentials.chat.shout
|
||||||
- essentials.kit
|
- essentials.compass
|
||||||
- essentials.kit.healer
|
- essentials.home
|
||||||
- essentials.heal
|
- essentials.kit
|
||||||
inheritance: []
|
- essentials.kit.tools
|
||||||
info:
|
- essentials.mail
|
||||||
roles-requirement:
|
- essentials.mail.send
|
||||||
- BlueFaction
|
- essentials.me
|
||||||
- RedFaction
|
- essentials.msg
|
||||||
prefix: ''
|
- essentials.nick
|
||||||
roles-category: job
|
- essentials.pay
|
||||||
build: false
|
- essentials.portal
|
||||||
suffix: ''
|
- essentials.protect
|
||||||
Fighter:
|
- essentials.sethome
|
||||||
default: false
|
- essentials.signs.buy.use
|
||||||
permissions:
|
- essentials.signs.disposal.create
|
||||||
- essentials.kit
|
- essentials.signs.disposal.use
|
||||||
- essentials.kit.fighter
|
- essentials.signs.free.use
|
||||||
inheritance: []
|
- essentials.signs.heal.use
|
||||||
info:
|
- essentials.signs.mail.create
|
||||||
prefix: ''
|
- essentials.signs.mail.use
|
||||||
roles-category: skill
|
- essentials.signs.protection.create
|
||||||
build: false
|
- essentials.signs.protection.use
|
||||||
suffix: ''
|
- essentials.signs.sell.use
|
||||||
Admin:
|
- essentials.signs.trade.create
|
||||||
default: false
|
- essentials.signs.trade.use
|
||||||
permissions:
|
- essentials.suicide
|
||||||
- '*'
|
- essentials.tpa
|
||||||
inheritance:
|
- essentials.tpaccept
|
||||||
- semiadmin
|
- essentials.tpahere
|
||||||
info:
|
- essentials.tpdeny
|
||||||
prefix: ''
|
- essentials.warp
|
||||||
build: true
|
- essentials.warp.list
|
||||||
suffix: ''
|
- essentials.worth
|
||||||
Miner:
|
inheritance:
|
||||||
default: false
|
- default
|
||||||
permissions:
|
info:
|
||||||
- essentials.kit
|
prefix: '&2'
|
||||||
- essentials.kit.miner
|
build: true
|
||||||
- flashlight.regular
|
suffix: ''
|
||||||
inheritance: []
|
Moderator:
|
||||||
info:
|
default: false
|
||||||
roles-requirement:
|
permissions:
|
||||||
- BlueFaction
|
- essentials.back
|
||||||
- RedFaction
|
- essentials.ban
|
||||||
prefix: ''
|
- essentials.banip
|
||||||
roles-category: job
|
- essentials.broadcast
|
||||||
build: false
|
- essentials.delwarp
|
||||||
suffix: ''
|
- essentials.depth
|
||||||
FlyingMan:
|
- essentials.eco
|
||||||
default: false
|
- essentials.getpos
|
||||||
permissions:
|
- essentials.jump
|
||||||
- nocheat.moving
|
- essentials.kick
|
||||||
inheritance: []
|
- essentials.kill
|
||||||
info:
|
- essentials.setwarp
|
||||||
roles-requirement: Fighter&SuperCart
|
- essentials.time
|
||||||
prefix: ''
|
- essentials.togglejail
|
||||||
roles-category: skill
|
- essentials.top
|
||||||
build: false
|
- essentials.tp
|
||||||
suffix: ''
|
- essentials.tphere
|
||||||
Peasant:
|
- essentials.tpo
|
||||||
default: false
|
- essentials.tpohere
|
||||||
permissions:
|
- essentials.tppos
|
||||||
- roles.joinrole
|
- essentials.tptoggle
|
||||||
- roles.leaverole
|
- essentials.unban
|
||||||
- roles.myroles
|
- essentials.unbanip
|
||||||
inheritance:
|
- essentials.whois
|
||||||
- default
|
- essentials.world
|
||||||
info:
|
- groupmanager.listgroups
|
||||||
prefix: '&e'
|
- groupmanager.mandemote
|
||||||
build: true
|
- groupmanager.manload
|
||||||
suffix: Peasant
|
- groupmanager.manpromote
|
||||||
BlueFaction:
|
- groupmanager.mansave
|
||||||
default: false
|
- groupmanager.manselect
|
||||||
permissions: []
|
- groupmanager.manuadd
|
||||||
inheritance:
|
- groupmanager.manudel
|
||||||
- peasant
|
- essentials.ext
|
||||||
info:
|
inheritance:
|
||||||
prefix: '&d'
|
- builder
|
||||||
roles-category: faction
|
info:
|
||||||
build: true
|
prefix: '&5'
|
||||||
suffix: Blue
|
build: true
|
||||||
Railer:
|
suffix: ''
|
||||||
default: false
|
Admin:
|
||||||
permissions:
|
default: false
|
||||||
- essentials.kit
|
permissions:
|
||||||
- essentials.kit.railer
|
- '*'
|
||||||
inheritance: []
|
inheritance:
|
||||||
info:
|
- semiadmin
|
||||||
roles-requirement: Miner
|
info:
|
||||||
prefix: ''
|
prefix: '&4'
|
||||||
roles-category: subjob
|
build: true
|
||||||
build: false
|
suffix: ''
|
||||||
suffix: ''
|
|
||||||
SuperCart:
|
|
||||||
default: false
|
|
||||||
permissions:
|
|
||||||
- minecartmania.*
|
|
||||||
inheritance: []
|
|
||||||
info:
|
|
||||||
roles-requirement: Railer
|
|
||||||
prefix: ''
|
|
||||||
roles-category: skill
|
|
||||||
build: false
|
|
||||||
suffix: ''
|
|
||||||
Moderator:
|
|
||||||
default: false
|
|
||||||
permissions:
|
|
||||||
- essentials.tp
|
|
||||||
- essentials.tphere
|
|
||||||
- essentials.item
|
|
||||||
- essentials.give
|
|
||||||
inheritance:
|
|
||||||
- default
|
|
||||||
info:
|
|
||||||
prefix: '&c'
|
|
||||||
build: true
|
|
||||||
suffix: Mod
|
|
||||||
|
@ -1,59 +1,15 @@
|
|||||||
users:
|
# "For a more advanced configuration example utilizing the advanced features of GroupManager, see http://pastebin.com/a8ZA0j5G"
|
||||||
aMiner:
|
users:
|
||||||
subgroups:
|
kimkandor:
|
||||||
- Miner
|
subgroups: []
|
||||||
permissions: []
|
permissions: []
|
||||||
group: BlueFaction
|
group: Admin
|
||||||
info:
|
mudzereli:
|
||||||
prefix: '&d'
|
subgroups: []
|
||||||
suffix: Miner
|
permissions: []
|
||||||
gmcouto:
|
group: Builder
|
||||||
subgroups: []
|
zenexer:
|
||||||
permissions: []
|
subgroups: []
|
||||||
group: SemiAdmin
|
permissions: []
|
||||||
tempRailer:
|
group: Admin
|
||||||
subgroups:
|
|
||||||
- Miner
|
|
||||||
- Railer
|
|
||||||
permissions: []
|
|
||||||
group: BlueFaction
|
|
||||||
info:
|
|
||||||
prefix: '&d'
|
|
||||||
suffix: Miner
|
|
||||||
anjocaido:
|
|
||||||
subgroups: []
|
|
||||||
permissions: []
|
|
||||||
group: Admin
|
|
||||||
info:
|
|
||||||
prefix: '&c'
|
|
||||||
suffix: King
|
|
||||||
aFarmer:
|
|
||||||
subgroups:
|
|
||||||
- Farmer
|
|
||||||
permissions: []
|
|
||||||
group: RedFaction
|
|
||||||
info:
|
|
||||||
prefix: '&d'
|
|
||||||
suffix: Farmer
|
|
||||||
zenexer:
|
|
||||||
subgroups: []
|
|
||||||
permissions:
|
|
||||||
- essentials.god
|
|
||||||
group: Moderator
|
|
||||||
Teste:
|
|
||||||
subgroups:
|
|
||||||
- Miner
|
|
||||||
- Railer
|
|
||||||
- SuperCart
|
|
||||||
- Fighter
|
|
||||||
- FlyingMan
|
|
||||||
permissions: []
|
|
||||||
group: BlueFaction
|
|
||||||
aHealer:
|
|
||||||
subgroups:
|
|
||||||
- Healer
|
|
||||||
permissions: []
|
|
||||||
group: RedFaction
|
|
||||||
info:
|
|
||||||
prefix: '&d'
|
|
||||||
suffix: Healer
|
|
||||||
|
@ -78,7 +78,6 @@
|
|||||||
<zipfileset src="${dist.jar}" excludes="META-INF/*" />
|
<zipfileset src="${dist.jar}" excludes="META-INF/*" />
|
||||||
<zipfileset src="../lib/mysql.jar" excludes="META-INF/*" />
|
<zipfileset src="../lib/mysql.jar" excludes="META-INF/*" />
|
||||||
<zipfileset src="../lib/sqlite.jar" excludes="META-INF/*" />
|
<zipfileset src="../lib/sqlite.jar" excludes="META-INF/*" />
|
||||||
<zipfileset src="../lib/c3p0-0.9.1.2.jar" excludes="META-INF/*" />
|
|
||||||
<manifest>
|
<manifest>
|
||||||
<attribute name="Classpath" value="Essentials.jar"/>
|
<attribute name="Classpath" value="Essentials.jar"/>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@ -26,7 +26,6 @@ dist.jar=${dist.dir}/original-EssentialsProtect.jar
|
|||||||
dist.javadoc.dir=${dist.dir}/javadoc
|
dist.javadoc.dir=${dist.dir}/javadoc
|
||||||
endorsed.classpath=
|
endorsed.classpath=
|
||||||
excludes=
|
excludes=
|
||||||
file.reference.c3p0-0.9.1.2.jar=..\\lib\\c3p0-0.9.1.2.jar
|
|
||||||
file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar
|
file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar
|
||||||
file.reference.mysql.jar=..\\lib\\mysql.jar
|
file.reference.mysql.jar=..\\lib\\mysql.jar
|
||||||
file.reference.sqlite.jar=..\\lib\\sqlite.jar
|
file.reference.sqlite.jar=..\\lib\\sqlite.jar
|
||||||
@ -38,8 +37,7 @@ javac.classpath=\
|
|||||||
${reference.Essentials.jar}:\
|
${reference.Essentials.jar}:\
|
||||||
${file.reference.mysql.jar}:\
|
${file.reference.mysql.jar}:\
|
||||||
${file.reference.sqlite.jar}:\
|
${file.reference.sqlite.jar}:\
|
||||||
${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\
|
${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}
|
||||||
${file.reference.c3p0-0.9.1.2.jar}
|
|
||||||
# Space-separated list of extra javac options
|
# Space-separated list of extra javac options
|
||||||
javac.compilerargs=
|
javac.compilerargs=
|
||||||
javac.deprecation=false
|
javac.deprecation=false
|
||||||
|
@ -1,13 +1,7 @@
|
|||||||
package com.earth2me.essentials.protect;
|
package com.earth2me.essentials.protect;
|
||||||
|
|
||||||
import com.earth2me.essentials.Essentials;
|
import com.earth2me.essentials.Essentials;
|
||||||
import com.earth2me.essentials.IConf;
|
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import com.earth2me.essentials.protect.data.IProtectedBlock;
|
|
||||||
import com.earth2me.essentials.protect.data.ProtectedBlockMemory;
|
|
||||||
import com.earth2me.essentials.protect.data.ProtectedBlockMySQL;
|
|
||||||
import com.earth2me.essentials.protect.data.ProtectedBlockSQLite;
|
|
||||||
import java.beans.PropertyVetoException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@ -21,7 +15,7 @@ import org.bukkit.plugin.PluginManager;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
|
||||||
public class EssentialsProtect extends JavaPlugin implements IConf
|
public class EssentialsProtect extends JavaPlugin
|
||||||
{
|
{
|
||||||
private EssentialsProtectBlockListener blockListener = null;
|
private EssentialsProtectBlockListener blockListener = null;
|
||||||
private EssentialsProtectPlayerListener playerListener = null;
|
private EssentialsProtectPlayerListener playerListener = null;
|
||||||
@ -39,8 +33,6 @@ public class EssentialsProtect extends JavaPlugin implements IConf
|
|||||||
public static ArrayList onUseAlert = null;
|
public static ArrayList onUseAlert = null;
|
||||||
public static ArrayList onBreakAlert = null;
|
public static ArrayList onBreakAlert = null;
|
||||||
|
|
||||||
private IProtectedBlock storage = null;
|
|
||||||
private static EssentialsProtect instance = null;
|
|
||||||
|
|
||||||
public EssentialsProtect()
|
public EssentialsProtect()
|
||||||
{
|
{
|
||||||
@ -50,18 +42,15 @@ public class EssentialsProtect extends JavaPlugin implements IConf
|
|||||||
{
|
{
|
||||||
PluginManager pm = this.getServer().getPluginManager();
|
PluginManager pm = this.getServer().getPluginManager();
|
||||||
Essentials ess = (Essentials)pm.getPlugin("Essentials");
|
Essentials ess = (Essentials)pm.getPlugin("Essentials");
|
||||||
if (!ess.isEnabled()) {
|
if (!ess.isEnabled())
|
||||||
pm.enablePlugin(ess);
|
pm.enablePlugin(ess);
|
||||||
}
|
|
||||||
|
|
||||||
instance = this;
|
|
||||||
reloadConfig();
|
|
||||||
|
|
||||||
playerListener = new EssentialsProtectPlayerListener(this);
|
playerListener = new EssentialsProtectPlayerListener(this);
|
||||||
blockListener = new EssentialsProtectBlockListener(this);
|
blockListener = new EssentialsProtectBlockListener(this);
|
||||||
entityListener = new EssentialsProtectEntityListener(this);
|
entityListener = new EssentialsProtectEntityListener(this);
|
||||||
pm.registerEvent(Type.PLAYER_PICKUP_ITEM, playerListener, Priority.Low, this);
|
|
||||||
pm.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.Low, this);
|
pm.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.Low, this);
|
||||||
|
// Why is this commented?
|
||||||
|
//pm.registerEvent(Type.BLOCK_DAMAGED, blockListener, Priority.High, this);
|
||||||
pm.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Highest, this);
|
pm.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Highest, this);
|
||||||
pm.registerEvent(Type.BLOCK_FROMTO, blockListener, Priority.Highest, this);
|
pm.registerEvent(Type.BLOCK_FROMTO, blockListener, Priority.Highest, this);
|
||||||
pm.registerEvent(Type.BLOCK_IGNITE, blockListener, Priority.Highest, this);
|
pm.registerEvent(Type.BLOCK_IGNITE, blockListener, Priority.Highest, this);
|
||||||
@ -71,6 +60,7 @@ public class EssentialsProtect extends JavaPlugin implements IConf
|
|||||||
pm.registerEvent(Type.BLOCK_BREAK, blockListener, Priority.Highest, this);
|
pm.registerEvent(Type.BLOCK_BREAK, blockListener, Priority.Highest, this);
|
||||||
pm.registerEvent(Type.CREATURE_SPAWN, entityListener, Priority.Highest, this);
|
pm.registerEvent(Type.CREATURE_SPAWN, entityListener, Priority.Highest, this);
|
||||||
|
|
||||||
|
loadSettings();
|
||||||
if (!this.getDescription().getVersion().equals(Essentials.getStatic().getDescription().getVersion())) {
|
if (!this.getDescription().getVersion().equals(Essentials.getStatic().getDescription().getVersion())) {
|
||||||
logger.log(Level.WARNING, "Version mismatch! Please update all Essentials jars to the same version.");
|
logger.log(Level.WARNING, "Version mismatch! Please update all Essentials jars to the same version.");
|
||||||
}
|
}
|
||||||
@ -102,23 +92,8 @@ public class EssentialsProtect extends JavaPlugin implements IConf
|
|||||||
onBreakAlert = null;
|
onBreakAlert = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void alert(User user, String item, String type)
|
public static void loadSettings()
|
||||||
{
|
{
|
||||||
Location loc = user.getLocation();
|
|
||||||
for (Player p : this.getServer().getOnlinePlayers())
|
|
||||||
{
|
|
||||||
User alertUser = User.get(p);
|
|
||||||
if (alertUser.isAuthorized("essentials.protect.alerts"))
|
|
||||||
alertUser.sendMessage(ChatColor.DARK_AQUA + "[" + user.getName() + "] " + ChatColor.WHITE + type + ChatColor.GOLD + item + " at: " + formatCoords(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String formatCoords(int x, int y, int z)
|
|
||||||
{
|
|
||||||
return x + "," + y + "," + z;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reloadConfig() {
|
|
||||||
dataSettings = Essentials.getSettings().getEpDBSettings();
|
dataSettings = Essentials.getSettings().getEpDBSettings();
|
||||||
genSettings = Essentials.getSettings().getEpSettings();
|
genSettings = Essentials.getSettings().getEpSettings();
|
||||||
guardSettings = Essentials.getSettings().getEpGuardSettings();
|
guardSettings = Essentials.getSettings().getEpGuardSettings();
|
||||||
@ -129,26 +104,17 @@ public class EssentialsProtect extends JavaPlugin implements IConf
|
|||||||
onUseAlert = Essentials.getSettings().getEpAlertOnUse();
|
onUseAlert = Essentials.getSettings().getEpAlertOnUse();
|
||||||
onBreakAlert = Essentials.getSettings().getEpAlertOnBreak();
|
onBreakAlert = Essentials.getSettings().getEpAlertOnBreak();
|
||||||
playerSettings = Essentials.getSettings().getEpPlayerSettings();
|
playerSettings = Essentials.getSettings().getEpPlayerSettings();
|
||||||
|
EssentialsProtectData.createSqlTable();
|
||||||
if (dataSettings.get("protect.datatype").equals("mysql")) {
|
|
||||||
try {
|
|
||||||
storage = new ProtectedBlockMySQL(dataSettings.get("protect.mysqlDb"), dataSettings.get("protect.username"), dataSettings.get("protect.password"));
|
|
||||||
} catch (PropertyVetoException ex) {
|
|
||||||
logger.log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
storage = new ProtectedBlockSQLite("jdbc:sqlite:plugins/Essentials/EssentialsProtect.db");
|
|
||||||
} catch (PropertyVetoException ex) {
|
|
||||||
logger.log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (genSettings.get("protect.memstore")) {
|
|
||||||
storage = new ProtectedBlockMemory(storage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IProtectedBlock getStorage() {
|
public void alert(User user, String item, String type)
|
||||||
return EssentialsProtect.instance.storage;
|
{
|
||||||
|
Location loc = user.getLocation();
|
||||||
|
for (Player p : this.getServer().getOnlinePlayers())
|
||||||
|
{
|
||||||
|
User alertUser = User.get(p);
|
||||||
|
if (alertUser.isAuthorized("essentials.protect.alerts"))
|
||||||
|
alertUser.sendMessage(ChatColor.DARK_AQUA + "[" + user.getName() + "] " + ChatColor.WHITE + type + ChatColor.GOLD + item + " at: " + EssentialsProtectData.formatCoords(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,24 +2,28 @@ package com.earth2me.essentials.protect;
|
|||||||
|
|
||||||
import com.earth2me.essentials.Essentials;
|
import com.earth2me.essentials.Essentials;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import java.util.ArrayList;
|
import org.bukkit.ChatColor;
|
||||||
import java.util.List;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockBurnEvent;
|
import org.bukkit.event.block.BlockBurnEvent;
|
||||||
import org.bukkit.event.block.BlockFromToEvent;
|
import org.bukkit.event.block.BlockFromToEvent;
|
||||||
import org.bukkit.event.block.BlockIgniteEvent;
|
import org.bukkit.event.block.BlockIgniteEvent;
|
||||||
|
import org.bukkit.event.block.BlockInteractEvent;
|
||||||
import org.bukkit.event.block.BlockListener;
|
import org.bukkit.event.block.BlockListener;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.event.block.BlockRightClickEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
|
||||||
public class EssentialsProtectBlockListener extends BlockListener
|
public class EssentialsProtectBlockListener extends BlockListener
|
||||||
{
|
{
|
||||||
private EssentialsProtect parent;
|
private EssentialsProtect parent;
|
||||||
|
private int railBlockX;
|
||||||
|
private int railBlockY;
|
||||||
|
private int railBlockZ;
|
||||||
|
private EssentialsProtectData spData;
|
||||||
|
|
||||||
public EssentialsProtectBlockListener(EssentialsProtect parent)
|
public EssentialsProtectBlockListener(EssentialsProtect parent)
|
||||||
{
|
{
|
||||||
@ -27,10 +31,17 @@ public class EssentialsProtectBlockListener extends BlockListener
|
|||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initialize()
|
||||||
|
{
|
||||||
|
if (spData != null) return;
|
||||||
|
spData = new EssentialsProtectData();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockPlace(BlockPlaceEvent event)
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
initialize();
|
||||||
ItemStack item = event.getItemInHand();
|
ItemStack item = event.getItemInHand();
|
||||||
User user = User.get(event.getPlayer());
|
User user = User.get(event.getPlayer());
|
||||||
|
|
||||||
@ -40,6 +51,7 @@ public class EssentialsProtectBlockListener extends BlockListener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Block blockPlaced = event.getBlockAgainst();
|
||||||
int id = event.getBlockPlaced().getTypeId();
|
int id = event.getBlockPlaced().getTypeId();
|
||||||
|
|
||||||
if (EssentialsProtect.checkProtectionItems(EssentialsProtect.blackListPlace, id) && !user.isAuthorized("essentials.protect.exemptplacement"))
|
if (EssentialsProtect.checkProtectionItems(EssentialsProtect.blackListPlace, id) && !user.isAuthorized("essentials.protect.exemptplacement"))
|
||||||
@ -53,48 +65,33 @@ public class EssentialsProtectBlockListener extends BlockListener
|
|||||||
parent.alert(user, item.getType().toString(), "placed: ");
|
parent.alert(user, item.getType().toString(), "placed: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
Block blockPlaced = event.getBlockPlaced();
|
if (spData.isBlockAboveProtectedRail(blockPlaced))
|
||||||
Block below = blockPlaced.getFace(BlockFace.DOWN);
|
{
|
||||||
if (below.getType() == Material.RAILS) {
|
|
||||||
if (EssentialsProtect.genSettings.get("protect.protect.prevent.block-on-rail"))
|
if (EssentialsProtect.genSettings.get("protect.protect.prevent.block-on-rail"))
|
||||||
{
|
{
|
||||||
if (EssentialsProtect.getStorage().isProtected(below, user.getName())) {
|
event.setCancelled(true);
|
||||||
event.setCancelled(true);
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Block> protect = new ArrayList<Block>();
|
if (item.getTypeId() == 66)
|
||||||
if (blockPlaced.getType() == Material.RAILS) {
|
{
|
||||||
if (EssentialsProtect.genSettings.get("protect.protect.rails"))
|
if (EssentialsProtect.genSettings.get("protect.protect.rails"))
|
||||||
{
|
{
|
||||||
if (user.isAuthorized("essentials.protect"))
|
if (user.isAuthorized("essentials.protect"))
|
||||||
{
|
{
|
||||||
protect.add(blockPlaced);
|
railBlockX = blockPlaced.getX();
|
||||||
|
railBlockY = blockPlaced.getY();
|
||||||
|
railBlockZ = blockPlaced.getZ();
|
||||||
|
|
||||||
|
spData.insertProtectionIntoDb(user.getWorld().getName(), user.getName(), railBlockX, railBlockY + 1, railBlockZ);
|
||||||
if (EssentialsProtect.genSettings.get("protect.protect.block-below"))
|
if (EssentialsProtect.genSettings.get("protect.protect.block-below"))
|
||||||
{
|
{
|
||||||
protect.add(blockPlaced.getFace(BlockFace.DOWN));
|
spData.insertProtectionIntoDb(user.getWorld().getName(), user.getName(), railBlockX, railBlockY, railBlockZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (blockPlaced.getType() == Material.SIGN_POST || blockPlaced.getType() == Material.WALL_SIGN) {
|
|
||||||
if (EssentialsProtect.genSettings.get("protect.protect.signs"))
|
|
||||||
{
|
|
||||||
if (user.isAuthorized("essentials.protect"))
|
|
||||||
{
|
|
||||||
protect.add(blockPlaced);
|
|
||||||
if (EssentialsProtect.genSettings.get("protect.protect.block-below"))
|
|
||||||
{
|
|
||||||
protect.add(event.getBlockAgainst());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (Block block : protect) {
|
|
||||||
EssentialsProtect.getStorage().protectBlock(block, user.getName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -131,7 +128,7 @@ public class EssentialsProtectBlockListener extends BlockListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBlockFromTo(BlockFromToEvent event)
|
public void onBlockFlow(BlockFromToEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
@ -190,6 +187,7 @@ public class EssentialsProtectBlockListener extends BlockListener
|
|||||||
public void onBlockBreak(BlockBreakEvent event)
|
public void onBlockBreak(BlockBreakEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
initialize();
|
||||||
User user = User.get(event.getPlayer());
|
User user = User.get(event.getPlayer());
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
if (EssentialsProtect.playerSettings.get("protect.disable.build") && !user.canBuild())
|
if (EssentialsProtect.playerSettings.get("protect.disable.build") && !user.canBuild())
|
||||||
@ -213,57 +211,28 @@ public class EssentialsProtectBlockListener extends BlockListener
|
|||||||
{
|
{
|
||||||
if (block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST || block.getType() == Material.RAILS)
|
if (block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST || block.getType() == Material.RAILS)
|
||||||
{
|
{
|
||||||
EssentialsProtect.getStorage().unprotectBlock(block);
|
spData.removeProtectionFromDB(block, true);
|
||||||
if (block.getType() == Material.RAILS || block.getType() == Material.SIGN_POST) {
|
|
||||||
Block below = block.getFace(BlockFace.DOWN);
|
|
||||||
EssentialsProtect.getStorage().unprotectBlock(below);
|
|
||||||
} else {
|
|
||||||
BlockFace[] faces = new BlockFace[] {
|
|
||||||
BlockFace.NORTH,
|
|
||||||
BlockFace.EAST,
|
|
||||||
BlockFace.SOUTH,
|
|
||||||
BlockFace.WEST
|
|
||||||
};
|
|
||||||
for (BlockFace blockFace : faces) {
|
|
||||||
Block against = block.getFace(blockFace);
|
|
||||||
EssentialsProtect.getStorage().unprotectBlock(against);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
EssentialsProtect.getStorage().unprotectBlock(block);
|
spData.removeProtectionFromDB(block);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
boolean canDestroy = spData.canDestroy(user.getWorld().getName(), user.getName(), block);
|
||||||
boolean isProtected = EssentialsProtect.getStorage().isProtected(block, user.getName());
|
if (canDestroy)
|
||||||
if (!isProtected) {
|
{
|
||||||
if (block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST || block.getType() == Material.RAILS)
|
if (block.getType() == Material.WALL_SIGN || block.getType() == Material.SIGN_POST || block.getType() == Material.RAILS)
|
||||||
{
|
{
|
||||||
EssentialsProtect.getStorage().unprotectBlock(block);
|
spData.removeProtectionFromDB(block, true);
|
||||||
if (block.getType() == Material.RAILS || block.getType() == Material.SIGN_POST) {
|
|
||||||
Block below = block.getFace(BlockFace.DOWN);
|
|
||||||
EssentialsProtect.getStorage().unprotectBlock(below);
|
|
||||||
} else {
|
|
||||||
BlockFace[] faces = new BlockFace[] {
|
|
||||||
BlockFace.NORTH,
|
|
||||||
BlockFace.EAST,
|
|
||||||
BlockFace.SOUTH,
|
|
||||||
BlockFace.WEST
|
|
||||||
};
|
|
||||||
for (BlockFace blockFace : faces) {
|
|
||||||
Block against = block.getFace(blockFace);
|
|
||||||
EssentialsProtect.getStorage().unprotectBlock(against);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
EssentialsProtect.getStorage().unprotectBlock(block);
|
spData.removeProtectionFromDB(block);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
|
@ -3,68 +3,92 @@ package com.earth2me.essentials.protect;
|
|||||||
import com.earth2me.essentials.Essentials;
|
import com.earth2me.essentials.Essentials;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.event.player.PlayerItemEvent;
|
||||||
import org.bukkit.event.player.PlayerListener;
|
import org.bukkit.event.player.PlayerListener;
|
||||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
|
||||||
public class EssentialsProtectPlayerListener extends PlayerListener
|
public class EssentialsProtectPlayerListener extends PlayerListener
|
||||||
{
|
{
|
||||||
private EssentialsProtect parent;
|
private EssentialsProtect parent;
|
||||||
|
private int signBlockX;
|
||||||
|
private int signBlockY;
|
||||||
|
private int signBlockZ;
|
||||||
|
private EssentialsProtectData spData = null;
|
||||||
|
|
||||||
public EssentialsProtectPlayerListener(EssentialsProtect parent)
|
public EssentialsProtectPlayerListener(EssentialsProtect parent)
|
||||||
{
|
{
|
||||||
Essentials.loadClasses();
|
Essentials.loadClasses();
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void initialize()
|
||||||
|
{
|
||||||
|
if (spData != null) return;
|
||||||
|
spData = new EssentialsProtectData();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerInteract(PlayerInteractEvent event)
|
public void onPlayerInteract(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
|
initialize();
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
ItemStack item = event.getItem();
|
||||||
User user = User.get(event.getPlayer());
|
User user = User.get(event.getPlayer());
|
||||||
|
Block blockClicked = event.getClickedBlock();
|
||||||
|
|
||||||
if (EssentialsProtect.playerSettings.get("protect.disable.build") && !user.canBuild())
|
if (EssentialsProtect.playerSettings.get("protect.disable.build") && !user.canBuild())
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.isAuthorized("essentials.protect.admin"))
|
|
||||||
{
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
boolean first = true;
|
|
||||||
for (String owner : EssentialsProtect.getStorage().getOwners(event.getClickedBlock())) {
|
|
||||||
if (!first) {
|
|
||||||
sb.append(", ");
|
|
||||||
}
|
|
||||||
first = false;
|
|
||||||
sb.append(owner);
|
|
||||||
}
|
|
||||||
String ownerNames = sb.toString();
|
|
||||||
if (ownerNames != null)
|
|
||||||
{
|
|
||||||
user.sendMessage(ChatColor.GOLD + "[EssentialsProtect] Protection owners: " + ownerNames);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPlayerPickupItem(PlayerPickupItemEvent event)
|
|
||||||
{
|
|
||||||
if(event.isCancelled()) return;
|
|
||||||
ItemStack item = event.getItem().getItemStack();
|
|
||||||
User user = User.get(event.getPlayer());
|
|
||||||
if (EssentialsProtect.checkProtectionItems(EssentialsProtect.usageList, item.getTypeId()) && !user.isAuthorized("essentials.protect.exemptusage"))
|
if (EssentialsProtect.checkProtectionItems(EssentialsProtect.usageList, item.getTypeId()) && !user.isAuthorized("essentials.protect.exemptusage"))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (user.isAuthorized("essentials.protect.admin"))
|
||||||
|
{
|
||||||
|
String ownerName = spData.getBlockOwner(user.getWorld().getName(), user.getName(),
|
||||||
|
blockClicked);
|
||||||
|
if (ownerName != null)
|
||||||
|
{
|
||||||
|
user.sendMessage(ChatColor.GOLD + "[EssentialsProtect] Protection owner: "
|
||||||
|
+ ownerName);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (EssentialsProtect.onUseAlert.contains(String.valueOf(item.getTypeId())))
|
if (EssentialsProtect.onUseAlert.contains(String.valueOf(item.getTypeId())))
|
||||||
{
|
{
|
||||||
parent.alert(user, item.getType().toString(), "used: ");
|
parent.alert(user, item.getType().toString(), "used: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (item.getTypeId() == 323)
|
||||||
|
{
|
||||||
|
if (EssentialsProtect.genSettings.get("protect.protect.signs"))
|
||||||
|
{
|
||||||
|
if (user.isAuthorized("essentials.protect"))
|
||||||
|
{
|
||||||
|
|
||||||
|
signBlockX = blockClicked.getX();
|
||||||
|
signBlockY = blockClicked.getY();
|
||||||
|
signBlockZ = blockClicked.getZ();
|
||||||
|
|
||||||
|
initialize();
|
||||||
|
spData.insertProtectionIntoDb(user.getWorld().getName(), user.getName(), signBlockX,
|
||||||
|
signBlockY + 1, signBlockZ);
|
||||||
|
|
||||||
|
if (EssentialsProtect.genSettings.get("protect.protect.block-below"))
|
||||||
|
{
|
||||||
|
spData.insertProtectionIntoDb(user.getWorld().getName(), user.getName(), signBlockX,
|
||||||
|
signBlockY, signBlockZ);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
76
EssentialsServerlist/build.xml
Normal file
76
EssentialsServerlist/build.xml
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE project [ <!ENTITY buildinc SYSTEM "../build.inc.xml"> ]>
|
||||||
|
<!-- You may freely edit this file. See commented blocks below for -->
|
||||||
|
<!-- some examples of how to customize the build. -->
|
||||||
|
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||||
|
<!-- By default, only the Clean and Build commands use this build script. -->
|
||||||
|
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||||
|
<!-- the Compile on Save feature is turned off for the project. -->
|
||||||
|
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||||
|
<!-- in the project's Project Properties dialog box.-->
|
||||||
|
<project name="EssentialsServerlist" default="default" basedir=".">
|
||||||
|
<description>Builds, tests, and runs the project EssentialsServerlist.</description>
|
||||||
|
<import file="nbproject/build-impl.xml"/>
|
||||||
|
&buildinc;
|
||||||
|
<!--
|
||||||
|
|
||||||
|
There exist several targets which are by default empty and which can be
|
||||||
|
used for execution of your tasks. These targets are usually executed
|
||||||
|
before and after some main targets. They are:
|
||||||
|
|
||||||
|
-pre-init: called before initialization of project properties
|
||||||
|
-post-init: called after initialization of project properties
|
||||||
|
-pre-compile: called before javac compilation
|
||||||
|
-post-compile: called after javac compilation
|
||||||
|
-pre-compile-single: called before javac compilation of single file
|
||||||
|
-post-compile-single: called after javac compilation of single file
|
||||||
|
-pre-compile-test: called before javac compilation of JUnit tests
|
||||||
|
-post-compile-test: called after javac compilation of JUnit tests
|
||||||
|
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||||
|
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||||
|
-pre-jar: called before JAR building
|
||||||
|
-post-jar: called after JAR building
|
||||||
|
-post-clean: called after cleaning build products
|
||||||
|
|
||||||
|
(Targets beginning with '-' are not intended to be called on their own.)
|
||||||
|
|
||||||
|
Example of inserting an obfuscator after compilation could look like this:
|
||||||
|
|
||||||
|
<target name="-post-compile">
|
||||||
|
<obfuscate>
|
||||||
|
<fileset dir="${build.classes.dir}"/>
|
||||||
|
</obfuscate>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
For list of available properties check the imported
|
||||||
|
nbproject/build-impl.xml file.
|
||||||
|
|
||||||
|
|
||||||
|
Another way to customize the build is by overriding existing main targets.
|
||||||
|
The targets of interest are:
|
||||||
|
|
||||||
|
-init-macrodef-javac: defines macro for javac compilation
|
||||||
|
-init-macrodef-junit: defines macro for junit execution
|
||||||
|
-init-macrodef-debug: defines macro for class debugging
|
||||||
|
-init-macrodef-java: defines macro for class execution
|
||||||
|
-do-jar-with-manifest: JAR building (if you are using a manifest)
|
||||||
|
-do-jar-without-manifest: JAR building (if you are not using a manifest)
|
||||||
|
run: execution of project
|
||||||
|
-javadoc-build: Javadoc generation
|
||||||
|
test-report: JUnit report generation
|
||||||
|
|
||||||
|
An example of overriding the target for project execution could look like this:
|
||||||
|
|
||||||
|
<target name="run" depends="EssentialsServerlist-impl.jar">
|
||||||
|
<exec dir="bin" executable="launcher.exe">
|
||||||
|
<arg file="${dist.jar}"/>
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
Notice that the overridden target depends on the jar target and not only on
|
||||||
|
the compile target as the regular run target does. Again, for a list of available
|
||||||
|
properties which you can use, check the target you are overriding in the
|
||||||
|
nbproject/build-impl.xml file.
|
||||||
|
|
||||||
|
-->
|
||||||
|
</project>
|
1072
EssentialsServerlist/nbproject/build-impl.xml
Normal file
1072
EssentialsServerlist/nbproject/build-impl.xml
Normal file
File diff suppressed because it is too large
Load Diff
8
EssentialsServerlist/nbproject/genfiles.properties
Normal file
8
EssentialsServerlist/nbproject/genfiles.properties
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
build.xml.data.CRC32=b3f32d5a
|
||||||
|
build.xml.script.CRC32=d07c143a
|
||||||
|
build.xml.stylesheet.CRC32=28e38971@1.38.2.45
|
||||||
|
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||||
|
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||||
|
nbproject/build-impl.xml.data.CRC32=28f52c06
|
||||||
|
nbproject/build-impl.xml.script.CRC32=bdef3982
|
||||||
|
nbproject/build-impl.xml.stylesheet.CRC32=19debb58@1.42.1.45
|
76
EssentialsServerlist/nbproject/project.properties
Normal file
76
EssentialsServerlist/nbproject/project.properties
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
annotation.processing.enabled=true
|
||||||
|
annotation.processing.enabled.in.editor=false
|
||||||
|
annotation.processing.run.all.processors=true
|
||||||
|
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||||
|
application.title=EssentialsServerlist
|
||||||
|
application.vendor=Paul
|
||||||
|
build.classes.dir=${build.dir}/classes
|
||||||
|
build.classes.excludes=**/*.java,**/*.form
|
||||||
|
# This directory is removed when the project is cleaned:
|
||||||
|
build.dir=build
|
||||||
|
build.generated.dir=${build.dir}/generated
|
||||||
|
build.generated.sources.dir=${build.dir}/generated-sources
|
||||||
|
# Only compile against the classpath explicitly listed here:
|
||||||
|
build.sysclasspath=ignore
|
||||||
|
build.test.classes.dir=${build.dir}/test/classes
|
||||||
|
build.test.results.dir=${build.dir}/test/results
|
||||||
|
# Uncomment to specify the preferred debugger connection transport:
|
||||||
|
#debug.transport=dt_socket
|
||||||
|
debug.classpath=\
|
||||||
|
${run.classpath}
|
||||||
|
debug.test.classpath=\
|
||||||
|
${run.test.classpath}
|
||||||
|
# This directory is removed when the project is cleaned:
|
||||||
|
dist.dir=dist
|
||||||
|
dist.jar=${dist.dir}/EssentialsServerlist.jar
|
||||||
|
dist.javadoc.dir=${dist.dir}/javadoc
|
||||||
|
endorsed.classpath=
|
||||||
|
excludes=
|
||||||
|
file.reference.craftbukkit-0.0.1-SNAPSHOT.jar-1=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar
|
||||||
|
includes=**
|
||||||
|
jar.compress=false
|
||||||
|
javac.classpath=\
|
||||||
|
${reference.Essentials.jar}:\
|
||||||
|
${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar-1}
|
||||||
|
# Space-separated list of extra javac options
|
||||||
|
javac.compilerargs=
|
||||||
|
javac.deprecation=false
|
||||||
|
javac.processorpath=\
|
||||||
|
${javac.classpath}
|
||||||
|
javac.source=1.5
|
||||||
|
javac.target=1.5
|
||||||
|
javac.test.classpath=\
|
||||||
|
${javac.classpath}:\
|
||||||
|
${build.classes.dir}:\
|
||||||
|
${libs.junit.classpath}:\
|
||||||
|
${libs.junit_4.classpath}
|
||||||
|
javac.test.processorpath=\
|
||||||
|
${javac.test.classpath}
|
||||||
|
javadoc.additionalparam=
|
||||||
|
javadoc.author=false
|
||||||
|
javadoc.encoding=${source.encoding}
|
||||||
|
javadoc.noindex=false
|
||||||
|
javadoc.nonavbar=false
|
||||||
|
javadoc.notree=false
|
||||||
|
javadoc.private=false
|
||||||
|
javadoc.splitindex=true
|
||||||
|
javadoc.use=true
|
||||||
|
javadoc.version=false
|
||||||
|
javadoc.windowtitle=
|
||||||
|
meta.inf.dir=${src.dir}/META-INF
|
||||||
|
platform.active=default_platform
|
||||||
|
project.Essentials=../Essentials
|
||||||
|
reference.Essentials.jar=${project.Essentials}/dist/Essentials.jar
|
||||||
|
run.classpath=\
|
||||||
|
${javac.classpath}:\
|
||||||
|
${build.classes.dir}
|
||||||
|
# Space-separated list of JVM arguments used when running the project
|
||||||
|
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
|
||||||
|
# or test-sys-prop.name=value to set system properties for unit tests):
|
||||||
|
run.jvmargs=
|
||||||
|
run.test.classpath=\
|
||||||
|
${javac.test.classpath}:\
|
||||||
|
${build.test.classes.dir}
|
||||||
|
source.encoding=UTF-8
|
||||||
|
src.dir=src
|
||||||
|
test.src.dir=test
|
28
EssentialsServerlist/nbproject/project.xml
Normal file
28
EssentialsServerlist/nbproject/project.xml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||||
|
<type>org.netbeans.modules.java.j2seproject</type>
|
||||||
|
<configuration>
|
||||||
|
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||||
|
<name>EssentialsServerlist</name>
|
||||||
|
<source-roots>
|
||||||
|
<root id="src.dir"/>
|
||||||
|
</source-roots>
|
||||||
|
<test-roots>
|
||||||
|
<root id="test.src.dir"/>
|
||||||
|
</test-roots>
|
||||||
|
</data>
|
||||||
|
<libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
|
||||||
|
<definitions>../lib\nblibraries.properties</definitions>
|
||||||
|
</libraries>
|
||||||
|
<references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
|
||||||
|
<reference>
|
||||||
|
<foreign-project>Essentials</foreign-project>
|
||||||
|
<artifact-type>jar</artifact-type>
|
||||||
|
<script>build.xml</script>
|
||||||
|
<target>jar</target>
|
||||||
|
<clean-target>clean</clean-target>
|
||||||
|
<id>jar</id>
|
||||||
|
</reference>
|
||||||
|
</references>
|
||||||
|
</configuration>
|
||||||
|
</project>
|
149
EssentialsServerlist/src/net/mcserverlist/bukkit/Mcsl.java
Normal file
149
EssentialsServerlist/src/net/mcserverlist/bukkit/Mcsl.java
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
package net.mcserverlist.bukkit;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.Essentials;
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.Event.Priority;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
|
||||||
|
public class Mcsl extends JavaPlugin
|
||||||
|
{
|
||||||
|
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||||
|
private McslPlayerListener playerListener;
|
||||||
|
public final String author;
|
||||||
|
|
||||||
|
public Mcsl() throws IOException
|
||||||
|
{
|
||||||
|
|
||||||
|
PluginDescriptionFile desc = this.getDescription();
|
||||||
|
|
||||||
|
// Compile author list
|
||||||
|
List<String> authors = new ArrayList<String>();
|
||||||
|
authors.add("Vimae Development");
|
||||||
|
int alen = authors.size();
|
||||||
|
if (alen == 1)
|
||||||
|
{
|
||||||
|
author = " by " + authors.get(0);
|
||||||
|
}
|
||||||
|
else if (alen > 1)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
StringBuilder bldr = new StringBuilder();
|
||||||
|
for (String a : desc.getAuthors())
|
||||||
|
{
|
||||||
|
if (i + 1 == alen)
|
||||||
|
{
|
||||||
|
if (alen > 2) bldr.append(",");
|
||||||
|
bldr.append(" and ");
|
||||||
|
}
|
||||||
|
else if (i++ > 0)
|
||||||
|
{
|
||||||
|
bldr.append(", ");
|
||||||
|
}
|
||||||
|
bldr.append(a);
|
||||||
|
}
|
||||||
|
bldr.insert(0, " by ");
|
||||||
|
author = bldr.toString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
author = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
|
||||||
|
{
|
||||||
|
McslCommands mcslCmd;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (McslCommands.valueOf(cmd.getName().toUpperCase()))
|
||||||
|
{
|
||||||
|
case WHITELIST:
|
||||||
|
whitelist(sender, WhitelistCommands.valueOf(args[0].toUpperCase()), args);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException ex)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.log(Level.WARNING, "MCSL encountered an unknown error.", ex);
|
||||||
|
sender.sendMessage("MCSL encountered an unknown error.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("LoggerStringConcat")
|
||||||
|
public void onEnable()
|
||||||
|
{
|
||||||
|
Plugin p = this.getServer().getPluginManager().getPlugin("Essentials");
|
||||||
|
if (p != null) {
|
||||||
|
if (!this.getServer().getPluginManager().isPluginEnabled(p)) {
|
||||||
|
this.getServer().getPluginManager().enablePlugin(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
playerListener = new McslPlayerListener(this);
|
||||||
|
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Monitor, this);
|
||||||
|
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Monitor, this);
|
||||||
|
getServer().getPluginManager().registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Lowest, this);
|
||||||
|
|
||||||
|
if (!this.getDescription().getVersion().equals(Essentials.getStatic().getDescription().getVersion())) {
|
||||||
|
logger.log(Level.WARNING, "Version mismatch! Please update all Essentials jars to the same version.");
|
||||||
|
}
|
||||||
|
logger.info(getDescription().getName() + " version " + getDescription().getVersion() + author + " enabled.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("LoggerStringConcat")
|
||||||
|
public void onDisable()
|
||||||
|
{
|
||||||
|
logger.info(getDescription().getName() + " version " + getDescription().getVersion() + " disabled.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void whitelist(CommandSender sender, WhitelistCommands cmd, String[] args)
|
||||||
|
{
|
||||||
|
if (!playerListener.isWhitelistEnabled())
|
||||||
|
{
|
||||||
|
sender.sendMessage("§cThe whitelist is disabled.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sender.isOp())
|
||||||
|
{
|
||||||
|
sender.sendMessage("§cYou must be an operator to manage the whitelist.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (cmd)
|
||||||
|
{
|
||||||
|
case RELOAD:
|
||||||
|
playerListener.whitelistReload();
|
||||||
|
sender.sendMessage("A whitelist updated has been queued.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum McslCommands
|
||||||
|
{
|
||||||
|
WHITELIST
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum WhitelistCommands
|
||||||
|
{
|
||||||
|
RELOAD
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,209 @@
|
|||||||
|
package net.mcserverlist.bukkit;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.Essentials;
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.*;
|
||||||
|
import java.util.logging.*;
|
||||||
|
import org.bukkit.*;
|
||||||
|
import org.bukkit.entity.*;
|
||||||
|
import org.bukkit.event.player.*;
|
||||||
|
|
||||||
|
|
||||||
|
public class McslPlayerListener extends PlayerListener
|
||||||
|
{
|
||||||
|
private final static Logger logger = Logger.getLogger("Minecraft");
|
||||||
|
private boolean running = true;
|
||||||
|
private final Server server;
|
||||||
|
private Thread thread;
|
||||||
|
private Whitelist whitelist = null;
|
||||||
|
private volatile boolean updateNeeded = true;
|
||||||
|
|
||||||
|
@SuppressWarnings("CallToThreadStartDuringObjectConstruction")
|
||||||
|
public McslPlayerListener(Mcsl parent)
|
||||||
|
{
|
||||||
|
this.server = parent.getServer();
|
||||||
|
|
||||||
|
// Get the data from the server.properties file as the server sees it, rather than reading it manually
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.whitelist = new Whitelist(server);
|
||||||
|
}
|
||||||
|
catch (Throwable ex)
|
||||||
|
{
|
||||||
|
// Disable the plugin
|
||||||
|
logger.log(Level.WARNING, "Error encountered while initializing MCServerlist plugin.", ex);
|
||||||
|
parent.getPluginLoader().disablePlugin(parent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run Update on a set interval of 1 minute with an initial delay of 10 seconds
|
||||||
|
thread = new Thread(new UpdateRunnable());
|
||||||
|
thread.setDaemon(true);
|
||||||
|
thread.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings("FinalizeDeclaration")
|
||||||
|
protected void finalize() throws Throwable
|
||||||
|
{
|
||||||
|
// Stop the timer
|
||||||
|
if (thread != null && thread.isAlive())
|
||||||
|
{
|
||||||
|
running = false;
|
||||||
|
thread.join();
|
||||||
|
}
|
||||||
|
|
||||||
|
super.finalize();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerLogin(PlayerLoginEvent event)
|
||||||
|
{
|
||||||
|
if (event.getResult() != PlayerLoginEvent.Result.ALLOWED)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
// Check the whitelist
|
||||||
|
if (!Essentials.getSettings().getWhitelistEnabled() || player.isOp() || whitelist == null || whitelist.isAllowed(player.getName()))
|
||||||
|
{
|
||||||
|
// Player is an op, there is no whitelist, or the player is whitelisted.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Player is not whitelisted.
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "This server employs a whitelist.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerJoin(PlayerEvent event)
|
||||||
|
{
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPlayerQuit(PlayerEvent event)
|
||||||
|
{
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWhitelistEnabled()
|
||||||
|
{
|
||||||
|
return whitelist != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void whitelistReload()
|
||||||
|
{
|
||||||
|
whitelist.update();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update()
|
||||||
|
{
|
||||||
|
updateNeeded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private class UpdateRunnable implements Runnable
|
||||||
|
{
|
||||||
|
@SuppressWarnings("SleepWhileInLoop")
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (updateNeeded)
|
||||||
|
{
|
||||||
|
updateNeeded = false;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Thread.sleep(60000);
|
||||||
|
}
|
||||||
|
catch (InterruptedException ex)
|
||||||
|
{
|
||||||
|
logger.info("Forcing MCServerlist update.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (running);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("CallToThreadDumpStack")
|
||||||
|
public void update()
|
||||||
|
{
|
||||||
|
// Check that we aren't receiving an event inappropriately
|
||||||
|
if (Essentials.getSettings().getMcslKey() == null || Essentials.getSettings().getMcslKey().equals("")) return;
|
||||||
|
// Compile a comma-space-delimted list of players
|
||||||
|
Player[] players = server.getOnlinePlayers();
|
||||||
|
StringBuilder list = new StringBuilder();
|
||||||
|
if (players.length > 0)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < players.length; i++)
|
||||||
|
{
|
||||||
|
if (i > 0) list.append(", ");
|
||||||
|
list.append(players[i].getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Compile POST data
|
||||||
|
StringBuilder data = new StringBuilder();
|
||||||
|
data.append("key=");
|
||||||
|
data.append(URLEncoder.encode(Essentials.getSettings().getMcslKey(), "UTF-8"));
|
||||||
|
data.append("&player_count=");
|
||||||
|
data.append(Integer.toString(players.length));
|
||||||
|
data.append("&max_players=");
|
||||||
|
data.append(Integer.toString(server.getMaxPlayers()));
|
||||||
|
data.append("&player_list=");
|
||||||
|
data.append(URLEncoder.encode(list.toString(), "UTF-8"));
|
||||||
|
|
||||||
|
OutputStreamWriter tx = null;
|
||||||
|
BufferedReader rx = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Send POST request
|
||||||
|
URL url = new URL("http://mcserverlist.net/api/update");
|
||||||
|
// Swap line for testing purposes
|
||||||
|
//URL url = new URL("http://localhost/mcsl/update.php");
|
||||||
|
HttpURLConnection http = (HttpURLConnection)url.openConnection();
|
||||||
|
http.setRequestMethod("POST");
|
||||||
|
http.setUseCaches(false);
|
||||||
|
http.setConnectTimeout(1000);
|
||||||
|
http.setAllowUserInteraction(false);
|
||||||
|
http.setInstanceFollowRedirects(true);
|
||||||
|
http.setRequestProperty("User-Agent", "Java;Mcsl");
|
||||||
|
http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
|
||||||
|
http.setRequestProperty("X-Mcsl-Key", Essentials.getSettings().getMcslKey());
|
||||||
|
http.setRequestProperty("X-Minecraft-Name", URLEncoder.encode(server.getName(), "UTF-8"));
|
||||||
|
http.setRequestProperty("X-Minecraft-Version", server.getVersion());
|
||||||
|
http.setDoInput(true);
|
||||||
|
http.setDoOutput(true);
|
||||||
|
tx = new OutputStreamWriter(http.getOutputStream());
|
||||||
|
tx.write(data.toString());
|
||||||
|
tx.flush();
|
||||||
|
|
||||||
|
// Get the HTTP response
|
||||||
|
rx = new BufferedReader(new InputStreamReader(http.getInputStream()));
|
||||||
|
for (String l = ""; rx.ready(); l = rx.readLine())
|
||||||
|
{
|
||||||
|
if ("".equals(l)) continue;
|
||||||
|
else if (l.startsWith("i:")) logger.info(l.substring(2));
|
||||||
|
else if (l.startsWith("w:")) logger.warning(l.substring(2));
|
||||||
|
else System.out.println(l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (tx != null) tx.close();
|
||||||
|
if (rx != null) rx.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.log(Level.WARNING, "Error communication with MCServerlist.", ex);
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
107
EssentialsServerlist/src/net/mcserverlist/bukkit/Whitelist.java
Normal file
107
EssentialsServerlist/src/net/mcserverlist/bukkit/Whitelist.java
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
package net.mcserverlist.bukkit;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.Essentials;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
|
||||||
|
|
||||||
|
public class Whitelist
|
||||||
|
{
|
||||||
|
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||||
|
private List<String> allowed = new ArrayList<String>();
|
||||||
|
private final Object allowedLock = new Object();
|
||||||
|
private Server server;
|
||||||
|
|
||||||
|
public Whitelist(Server server)
|
||||||
|
{
|
||||||
|
this.server = server;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update()
|
||||||
|
{
|
||||||
|
Thread thread = new Thread(new UpdateRunnable());
|
||||||
|
thread.setDaemon(true);
|
||||||
|
thread.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAllowed(String player)
|
||||||
|
{
|
||||||
|
String p = player.toLowerCase();
|
||||||
|
synchronized (allowedLock)
|
||||||
|
{
|
||||||
|
return allowed.contains(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class UpdateRunnable implements Runnable
|
||||||
|
{
|
||||||
|
@SuppressWarnings("CallToThreadDumpStack")
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
// Check that we aren't receiving an event inappropriately
|
||||||
|
if (Essentials.getSettings().getMcslKey() == null || Essentials.getSettings().getMcslKey().equals("")) return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
OutputStreamWriter tx = null;
|
||||||
|
BufferedReader rx = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Send GET request
|
||||||
|
URL url = new URL("http://mcserverlist.net/api/whitelist");
|
||||||
|
// Swap line for testing purposes
|
||||||
|
//URL url = new URL("http://localhost/mcsl/whitelist.php");
|
||||||
|
HttpURLConnection http = (HttpURLConnection)url.openConnection();
|
||||||
|
http.setRequestMethod("POST");
|
||||||
|
http.setUseCaches(false);
|
||||||
|
http.setConnectTimeout(1000);
|
||||||
|
http.setAllowUserInteraction(false);
|
||||||
|
http.setInstanceFollowRedirects(true);
|
||||||
|
http.setRequestProperty("User-Agent", "Java;Mcsl");
|
||||||
|
http.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
|
||||||
|
http.setRequestProperty("X-Mcsl-Key", Essentials.getSettings().getMcslKey());
|
||||||
|
http.setRequestProperty("X-Minecraft-Name", URLEncoder.encode(server.getName(), "UTF-8"));
|
||||||
|
http.setRequestProperty("X-Minecraft-Version", server.getVersion());
|
||||||
|
http.setDoInput(true);
|
||||||
|
http.setDoOutput(false);
|
||||||
|
|
||||||
|
// Get the HTTP response
|
||||||
|
rx = new BufferedReader(new InputStreamReader(http.getInputStream()));
|
||||||
|
List<String> allowed = new ArrayList<String>();
|
||||||
|
for (String l = ""; rx.ready(); l = rx.readLine())
|
||||||
|
{
|
||||||
|
if ("".equals(l)) continue;
|
||||||
|
else if (l.startsWith("i:")) logger.info(l.substring(2));
|
||||||
|
else if (l.startsWith("w:")) logger.warning(l.substring(2));
|
||||||
|
else allowed.add(l.toLowerCase()); // Add to whitelist
|
||||||
|
}
|
||||||
|
|
||||||
|
synchronized (Whitelist.this.allowedLock)
|
||||||
|
{
|
||||||
|
Whitelist.this.allowed = allowed;
|
||||||
|
allowed = null; // Remove our reference so that we don't accidentally use it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (tx != null) tx.close();
|
||||||
|
if (rx != null) rx.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
logger.log(Level.WARNING, "Error communication with MCServerlist.", ex);
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
EssentialsServerlist/src/plugin.yml
Normal file
5
EssentialsServerlist/src/plugin.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
name: EssentialsServerlist
|
||||||
|
main: net.mcserverlist.bukkit.Mcsl
|
||||||
|
version: TeamCity
|
||||||
|
website: http://mcserverlist.net/
|
||||||
|
description: Official MCServerlist API implementation
|
@ -4,7 +4,7 @@ import com.earth2me.essentials.Essentials;
|
|||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
import org.bukkit.event.player.PlayerListener;
|
import org.bukkit.event.player.PlayerListener;
|
||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ public class EssentialsSpawnPlayerListener extends PlayerListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
public void onPlayerJoin(PlayerEvent event)
|
||||||
{
|
{
|
||||||
Essentials.loadClasses();
|
Essentials.loadClasses();
|
||||||
User user = User.get(event.getPlayer());
|
User user = User.get(event.getPlayer());
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user