LICENSE updated
messages beautified small fixes and improvements
This commit is contained in:
parent
0f4786958d
commit
085306995b
11
LICENSE.md
11
LICENSE.md
@ -1,10 +1,19 @@
|
|||||||
# GPLv3
|
# GPLv3
|
||||||
* src/main/resources/plugin.yml
|
* src/main/resources/plugin.yml
|
||||||
|
* src/main/java/de/craftinc/replicator/BlockPlaceListener.java
|
||||||
|
* src/main/java/de/craftinc/replicator/BlockUtil.java
|
||||||
|
* src/main/java/de/craftinc/replicator/Commands.java
|
||||||
|
* src/main/java/de/craftinc/replicator/Messages.java
|
||||||
|
* src/main/java/de/craftinc/replicator/Pattern.java
|
||||||
|
* src/main/java/de/craftinc/replicator/PlayerInteractEntityListener.java
|
||||||
|
* src/main/java/de/craftinc/replicator/Plugin.java
|
||||||
|
* src/main/java/de/craftinc/replicator/Replicator.java
|
||||||
|
* src/main/java/de/craftinc/replicator/UpdateHelper.java
|
||||||
|
|
||||||
full text of GPLv3 can be found in the file "GPLv3"
|
full text of GPLv3 can be found in the file "GPLv3"
|
||||||
|
|
||||||
|
|
||||||
# LGPLv3
|
# LGPLv3
|
||||||
* src/main/java/de/craftinc/borderprotection/LocationSerializer.java
|
* src/main/java/de/craftinc/replicator/LocationSerializer.java
|
||||||
|
|
||||||
full text of LGPLv3 can be found in the file "LGPLv3"
|
full text of LGPLv3 can be found in the file "LGPLv3"
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
eigenschaften global
|
|
||||||
-list replikatoren
|
|
||||||
|
|
||||||
|
|
||||||
eigenschaften replikator:
|
|
||||||
-list owner
|
|
||||||
-list user
|
|
||||||
-location rep
|
|
||||||
-location pumpkin
|
|
||||||
|
|
||||||
-method: is_valid()
|
|
34
pom.xml
34
pom.xml
@ -33,23 +33,23 @@
|
|||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!--<plugin>-->
|
<plugin>
|
||||||
<!--<artifactId>exec-maven-plugin</artifactId>-->
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
<!--<groupId>org.codehaus.mojo</groupId>-->
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<!--<version>1.2.1</version>-->
|
<version>1.2.1</version>
|
||||||
<!--<executions>-->
|
<executions>
|
||||||
<!--<execution>-->
|
<execution>
|
||||||
<!--<id>Run Test Bukkit Server</id>-->
|
<id>Run Test Bukkit Server</id>
|
||||||
<!--<phase>package</phase>-->
|
<phase>package</phase>
|
||||||
<!--<goals>-->
|
<goals>
|
||||||
<!--<goal>exec</goal>-->
|
<goal>exec</goal>
|
||||||
<!--</goals>-->
|
</goals>
|
||||||
<!--<configuration>-->
|
<configuration>
|
||||||
<!--<executable>${basedir}/scripts/test-deployment.sh</executable>-->
|
<executable>${basedir}/scripts/test-deployment.sh</executable>
|
||||||
<!--</configuration>-->
|
</configuration>
|
||||||
<!--</execution>-->
|
</execution>
|
||||||
<!--</executions>-->
|
</executions>
|
||||||
<!--</plugin>-->
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
@ -36,10 +36,6 @@ public class BlockPlaceListener implements Listener
|
|||||||
for ( Location loc : replicators )
|
for ( Location loc : replicators )
|
||||||
{
|
{
|
||||||
Replicator rep = Replicator.getOrCreate(loc, event.getPlayer());
|
Replicator rep = Replicator.getOrCreate(loc, event.getPlayer());
|
||||||
if ( rep != null )
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ package de.craftinc.replicator;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
// FIXME: unused at the moment because the HashSet<Byte> seems not to be working as it is expected here...
|
||||||
public class BlockUtil
|
public class BlockUtil
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Craft Inc. Replicator
|
/* Craft Inc. Replicator
|
||||||
Copyright (C) 2013 Paul Schulze, Maximilian Häckel
|
Copyright (C) 2013 Paul Schulze, Maximilian Häckel, Moritz Kaltofen
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package de.craftinc.replicator;
|
package de.craftinc.replicator;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -39,7 +38,7 @@ public class Commands implements CommandExecutor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// commands
|
// commands
|
||||||
if ( command.getName().equalsIgnoreCase("replicate") || command.getAliases().get(0).equalsIgnoreCase("repli") )
|
if ( command.getName().equalsIgnoreCase("replicator") || command.getAliases().get(0).equalsIgnoreCase("repli") )
|
||||||
{
|
{
|
||||||
Player player = ( (Player) sender ).getPlayer();
|
Player player = ( (Player) sender ).getPlayer();
|
||||||
|
|
||||||
@ -80,9 +79,10 @@ public class Commands implements CommandExecutor
|
|||||||
{
|
{
|
||||||
// get block where the player is looking at
|
// get block where the player is looking at
|
||||||
Block potentialReplicatorBlock = player.getTargetBlock(null, 100);
|
Block potentialReplicatorBlock = player.getTargetBlock(null, 100);
|
||||||
Replicator.mochaccino.sendMessage("You are looking at "+potentialReplicatorBlock.getLocation().getBlockX()+","+potentialReplicatorBlock.getLocation().getBlockY()+","+potentialReplicatorBlock.getLocation().getBlockZ());
|
// Replicator.mochaccino.sendMessage("You are looking at "+potentialReplicatorBlock.getLocation().getBlockX()+","+potentialReplicatorBlock.getLocation().getBlockY()+","+potentialReplicatorBlock.getLocation().getBlockZ());
|
||||||
// get zero or more valid replicator centers
|
// get zero or more valid replicator centers
|
||||||
ArrayList<Replicator> replicators = Replicator.getReplicators(potentialReplicatorBlock.getLocation());
|
ArrayList<Replicator> replicators = Replicator
|
||||||
|
.getReplicators(potentialReplicatorBlock.getLocation());
|
||||||
|
|
||||||
if ( replicators.size() == 0 )
|
if ( replicators.size() == 0 )
|
||||||
{
|
{
|
||||||
@ -95,7 +95,7 @@ public class Commands implements CommandExecutor
|
|||||||
// replicator specified as argument
|
// replicator specified as argument
|
||||||
else if ( args.length == 2 )
|
else if ( args.length == 2 )
|
||||||
{
|
{
|
||||||
Replicator rep = Replicator.getByName(args[1], player.getName());
|
Replicator rep = Replicator.getByName(args[1]);
|
||||||
if ( rep == null )
|
if ( rep == null )
|
||||||
{
|
{
|
||||||
sender.sendMessage(Messages.noReplicatorWithName(args[1]));
|
sender.sendMessage(Messages.noReplicatorWithName(args[1]));
|
||||||
@ -128,7 +128,7 @@ public class Commands implements CommandExecutor
|
|||||||
|
|
||||||
// get zero or more valid replicator centers
|
// get zero or more valid replicator centers
|
||||||
ArrayList<Replicator> replicators = Replicator
|
ArrayList<Replicator> replicators = Replicator
|
||||||
.getOwnReplicators(potentialReplicatorBlock.getLocation(),player.getName());
|
.getOwnReplicators(potentialReplicatorBlock.getLocation(), player.getName());
|
||||||
|
|
||||||
// no replicator in sight
|
// no replicator in sight
|
||||||
if ( replicators.isEmpty() )
|
if ( replicators.isEmpty() )
|
||||||
@ -138,30 +138,14 @@ public class Commands implements CommandExecutor
|
|||||||
}
|
}
|
||||||
for ( Replicator replicator : replicators )
|
for ( Replicator replicator : replicators )
|
||||||
{
|
{
|
||||||
if ( args[0].equalsIgnoreCase("addowner") )
|
addOrDelOwnerOrUser(player.getName(), args[1], args[0], replicator);
|
||||||
{
|
|
||||||
replicator.addOwner(args[1],player.getName());
|
|
||||||
}
|
|
||||||
else if ( args[0].equalsIgnoreCase("delowner") )
|
|
||||||
{
|
|
||||||
replicator.rmOwner(args[1],player.getName());
|
|
||||||
}
|
|
||||||
else if ( args[0].equalsIgnoreCase("adduser") )
|
|
||||||
{
|
|
||||||
replicator.addUser(args[1],player.getName());
|
|
||||||
}
|
|
||||||
else if ( args[0].equalsIgnoreCase("deluser") )
|
|
||||||
{
|
|
||||||
replicator.rmUser(args[1],player.getName());
|
|
||||||
}
|
|
||||||
sender.sendMessage(Messages.addedOwner(args[1], replicator));
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// replicator name specified as argument
|
// replicator name specified as argument
|
||||||
else if ( args.length == 3 )
|
else if ( args.length == 3 )
|
||||||
{
|
{
|
||||||
Replicator replicator = Replicator.getByName(args[2], player.getName());
|
Replicator replicator = Replicator.getOwnByName(args[2], player.getName());
|
||||||
|
|
||||||
if ( replicator == null )
|
if ( replicator == null )
|
||||||
{
|
{
|
||||||
@ -169,24 +153,7 @@ public class Commands implements CommandExecutor
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( args[0].equalsIgnoreCase("addowner") )
|
addOrDelOwnerOrUser(player.getName(), args[1], args[0], replicator);
|
||||||
{
|
|
||||||
replicator.addOwner(args[1],player.getName());
|
|
||||||
}
|
|
||||||
else if ( args[0].equalsIgnoreCase("delowner") )
|
|
||||||
{
|
|
||||||
replicator.rmOwner(args[1],player.getName());
|
|
||||||
}
|
|
||||||
else if ( args[0].equalsIgnoreCase("adduser") )
|
|
||||||
{
|
|
||||||
replicator.addUser(args[1],player.getName());
|
|
||||||
}
|
|
||||||
else if ( args[0].equalsIgnoreCase("deluser") )
|
|
||||||
{
|
|
||||||
replicator.rmUser(args[1],player.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(Messages.addedOwner(player.getName(), replicator));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,4 +164,57 @@ public class Commands implements CommandExecutor
|
|||||||
sender.sendMessage(Messages.helpGeneral(( (Player) sender ).getPlayer()));
|
sender.sendMessage(Messages.helpGeneral(( (Player) sender ).getPlayer()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void addOrDelOwnerOrUser( String playerName, String changedPlayer, String command,
|
||||||
|
Replicator replicator )
|
||||||
|
{
|
||||||
|
if ( command.equalsIgnoreCase("addowner") )
|
||||||
|
{
|
||||||
|
if ( replicator.addOwner(changedPlayer, playerName) )
|
||||||
|
{
|
||||||
|
Plugin.instance.getServer().getPlayer(playerName)
|
||||||
|
.sendMessage(Messages.addedOwner(changedPlayer, replicator));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Plugin.instance.getServer().getPlayer(playerName).sendMessage(Messages.playerAlreadyIs(changedPlayer, "owner"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( command.equalsIgnoreCase("delowner") )
|
||||||
|
{
|
||||||
|
if ( replicator.rmOwner(changedPlayer, playerName) )
|
||||||
|
{
|
||||||
|
Plugin.instance.getServer().getPlayer(playerName)
|
||||||
|
.sendMessage(Messages.deletedOwner(changedPlayer, replicator));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Plugin.instance.getServer().getPlayer(playerName).sendMessage(Messages.noPlayerWithName(changedPlayer, "owner"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( command.equalsIgnoreCase("adduser") )
|
||||||
|
{
|
||||||
|
if ( replicator.addUser(changedPlayer, playerName) )
|
||||||
|
{
|
||||||
|
Plugin.instance.getServer().getPlayer(playerName)
|
||||||
|
.sendMessage(Messages.addedUser(changedPlayer, replicator));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Plugin.instance.getServer().getPlayer(playerName).sendMessage(Messages.playerAlreadyIs(changedPlayer, "user"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( command.equalsIgnoreCase("deluser") )
|
||||||
|
{
|
||||||
|
if ( replicator.rmUser(changedPlayer, playerName) )
|
||||||
|
{
|
||||||
|
Plugin.instance.getServer().getPlayer(playerName)
|
||||||
|
.sendMessage(Messages.deletedUser(changedPlayer, replicator));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Plugin.instance.getServer().getPlayer(playerName).sendMessage(Messages.noPlayerWithName(changedPlayer, "user"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,19 @@
|
|||||||
|
/* Craft Inc. Replicator
|
||||||
|
Copyright (C) 2013 Paul Schulze, Maximilian Häckel, Moritz Kaltofen, Tobias Ottenweller
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
package de.craftinc.replicator;
|
package de.craftinc.replicator;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Craft Inc. Replicator
|
/* Craft Inc. Replicator
|
||||||
Copyright (C) 2013 Paul Schulze, Maximilian Häckel
|
Copyright (C) 2013 Paul Schulze, Maximilian Häckel, Moritz Kaltofen
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -30,7 +30,8 @@ public class Messages
|
|||||||
private static String makeCmd( Player player, String command, String explanation, String[] permissions,
|
private static String makeCmd( Player player, String command, String explanation, String[] permissions,
|
||||||
String... args )
|
String... args )
|
||||||
{
|
{
|
||||||
if (permissions != null) {
|
if ( permissions != null )
|
||||||
|
{
|
||||||
for ( String perm : permissions )
|
for ( String perm : permissions )
|
||||||
{
|
{
|
||||||
if ( !player.hasPermission(perm) )
|
if ( !player.hasPermission(perm) )
|
||||||
@ -90,9 +91,6 @@ public class Messages
|
|||||||
public static String commandIssuedByNonPlayer
|
public static String commandIssuedByNonPlayer
|
||||||
= ChatColor.RED + "Only a player can use " + pluginName + " commands!";
|
= ChatColor.RED + "Only a player can use " + pluginName + " commands!";
|
||||||
|
|
||||||
public static String noPermissionUse =
|
|
||||||
ChatColor.RED + "Sorry, you don't have permission to use this replicator. Ask .... TODO"; //TODO
|
|
||||||
|
|
||||||
public static String noPermissionCheckversion =
|
public static String noPermissionCheckversion =
|
||||||
ChatColor.RED + "Sorry, you don't have permission to check for new versions.";
|
ChatColor.RED + "Sorry, you don't have permission to check for new versions.";
|
||||||
|
|
||||||
@ -116,20 +114,20 @@ public class Messages
|
|||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append(ChatColor.YELLOW + "The following replicators have been found:" + NEWLINE);
|
sb.append(ChatColor.YELLOW + "The following replicators have been found:" + NEWLINE);
|
||||||
if(replicators.size()>0)
|
if ( replicators.size() > 0 )
|
||||||
{
|
{
|
||||||
for ( Replicator r : replicators )
|
for ( Replicator r : replicators )
|
||||||
{
|
{
|
||||||
sb.append(ChatColor.GOLD + r.getName() + ":" + NEWLINE);
|
sb.append(ChatColor.GOLD).append(r.getName()).append(":").append(NEWLINE);
|
||||||
sb.append(ChatColor.GREEN + "Owners:" + NEWLINE);
|
sb.append(ChatColor.GREEN + "Owners:" + NEWLINE);
|
||||||
for ( String owner : r.getOwners() )
|
for ( String owner : r.getOwners() )
|
||||||
{
|
{
|
||||||
sb.append(ChatColor.WHITE + owner + " ");
|
sb.append(ChatColor.WHITE).append(owner).append(" ");
|
||||||
}
|
}
|
||||||
sb.append(NEWLINE + ChatColor.GREEN + "Users:" + NEWLINE);
|
sb.append(NEWLINE + ChatColor.GREEN + "Users:" + NEWLINE);
|
||||||
for ( String user : r.getUsers() )
|
for ( String user : r.getUsers() )
|
||||||
{
|
{
|
||||||
sb.append(ChatColor.WHITE + user + " ");
|
sb.append(ChatColor.WHITE).append(user).append(" ");
|
||||||
}
|
}
|
||||||
sb.append(NEWLINE);
|
sb.append(NEWLINE);
|
||||||
}
|
}
|
||||||
@ -144,14 +142,14 @@ public class Messages
|
|||||||
sb.append(ChatColor.YELLOW + "Replicators where you are owner:" + NEWLINE);
|
sb.append(ChatColor.YELLOW + "Replicators where you are owner:" + NEWLINE);
|
||||||
for ( Replicator r : repByOwner )
|
for ( Replicator r : repByOwner )
|
||||||
{
|
{
|
||||||
sb.append(ChatColor.WHITE + r.getName() + NEWLINE);
|
sb.append(ChatColor.WHITE).append(r.getName()).append(NEWLINE);
|
||||||
}
|
}
|
||||||
sb.append(NEWLINE);
|
sb.append(NEWLINE);
|
||||||
|
|
||||||
sb.append(ChatColor.YELLOW + "Replicators where you are user:" + NEWLINE);
|
sb.append(ChatColor.YELLOW + "Replicators where you are user:" + NEWLINE);
|
||||||
for ( Replicator r : repByUser )
|
for ( Replicator r : repByUser )
|
||||||
{
|
{
|
||||||
sb.append(ChatColor.WHITE + r.getName() + NEWLINE);
|
sb.append(ChatColor.WHITE).append(r.getName()).append(NEWLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
@ -165,21 +163,55 @@ public class Messages
|
|||||||
|
|
||||||
public static String addedOwner( String newOwner, Replicator replicator )
|
public static String addedOwner( String newOwner, Replicator replicator )
|
||||||
{
|
{
|
||||||
return ChatColor.GREEN + "Added " + ChatColor.GOLD + newOwner + " as owner for " + ChatColor.GOLD +
|
return ChatColor.GREEN + "Added " + ChatColor.GOLD + newOwner + ChatColor.GREEN + " as owner for "
|
||||||
replicator.getName();
|
+ ChatColor.GOLD + replicator.getName() + ChatColor.GREEN + ".";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String deletedOwner( String deletedOwner, Replicator replicator )
|
||||||
|
{
|
||||||
|
return ChatColor.GREEN + "Deleted owner status of " + ChatColor.GOLD + deletedOwner + ChatColor.GREEN +
|
||||||
|
" for replicator "
|
||||||
|
+ ChatColor.GOLD + replicator.getName() + ChatColor.GREEN + ".";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String addedUser( String newUser, Replicator replicator )
|
||||||
|
{
|
||||||
|
return ChatColor.GREEN + "Added " + ChatColor.GOLD + newUser + ChatColor.GREEN + " as user for "
|
||||||
|
+ ChatColor.GOLD + replicator.getName() + ChatColor.GREEN + ".";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String deletedUser( String deletedUser, Replicator replicator )
|
||||||
|
{
|
||||||
|
return ChatColor.GREEN + "Deleted user status of " + ChatColor.GOLD + deletedUser + ChatColor.GREEN +
|
||||||
|
" for replicator "
|
||||||
|
+ ChatColor.GOLD + replicator.getName() + ChatColor.GREEN + ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String newReplicator( Replicator replicator )
|
public static String newReplicator( Replicator replicator )
|
||||||
{
|
{
|
||||||
return ChatColor.GREEN + "Congratulations!" + ChatColor.YELLOW + " You have just built a working replicator with id: " +
|
return ChatColor.GREEN + "Congratulations!" + ChatColor.YELLOW +
|
||||||
|
" You have just built a working replicator with id: " +
|
||||||
ChatColor.GREEN + replicator.getName() + NEWLINE +
|
ChatColor.GREEN + replicator.getName() + NEWLINE +
|
||||||
" Put item frames with items you want to replicate onto the front side and right click them to replicate." + NEWLINE +
|
" Put item frames with items you want to replicate onto the front side and right click them to replicate." +
|
||||||
|
NEWLINE +
|
||||||
" Use " + ChatColor.GOLD + "/repli adduser|deluser" + ChatColor.YELLOW + " while looking at it to give" +
|
" Use " + ChatColor.GOLD + "/repli adduser|deluser" + ChatColor.YELLOW + " while looking at it to give" +
|
||||||
" give other players permission to use your replicator." + NEWLINE +
|
" give other players permission to use your replicator." + NEWLINE +
|
||||||
" Use " + ChatColor.GOLD + "/repli help" + " to see a full list of commands you can use.";
|
" Use " + ChatColor.GOLD + "/repli help" + ChatColor.YELLOW +
|
||||||
|
" to see a full list of commands you can use.";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String couldNotSave = ChatColor.RED + "Sorry! Could not save the replicators to disk. After a server " +
|
public static String couldNotSave =
|
||||||
"reload or restart the information about this replicator will be lost. You will " +
|
ChatColor.RED + "Sorry! Could not save the replicators to disk. After a server " +
|
||||||
"still be able to use it. Tell a mod or admin about that problem.";
|
"reload or restart the information about this replicator will be lost. You will " +
|
||||||
|
"still be able to use it. Tell a mod or admin about that problem.";
|
||||||
|
|
||||||
|
public static String noPlayerWithName( String changedPlayer, String ownerUser )
|
||||||
|
{
|
||||||
|
return ChatColor.RED + "There is no " + ownerUser + " named " + ChatColor.GOLD + changedPlayer + ChatColor.RED + ".";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String playerAlreadyIs( String changedPlayer, String ownerUser )
|
||||||
|
{
|
||||||
|
return ChatColor.RED + "Player " + ChatColor.GOLD + changedPlayer + ChatColor.RED + " is already " + ownerUser + ".";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package de.craftinc.replicator;
|
package de.craftinc.replicator;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
@ -60,14 +59,16 @@ public class PlayerInteractEntityListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
// do nothing if item frame is empty
|
// do nothing if item frame is empty
|
||||||
if (itemFrame.getItem().getType().equals(Material.AIR))
|
if ( itemFrame.getItem().getType().equals(Material.AIR) )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// find replicator centers which are suitable for this item frame
|
// find replicator centers which are suitable for this item frame
|
||||||
//Replicator.mochaccino.sendMessage(itemFrame.getAttachedFace() + "");
|
//Replicator.mochaccino.sendMessage(itemFrame.getAttachedFace() + "");
|
||||||
ArrayList<Replicator> replicators = Replicator.getUsableReplicators(event.getRightClicked().getLocation().getBlock().getRelative(itemFrame.getAttachedFace()).getLocation(),event.getPlayer().getName());
|
ArrayList<Replicator> replicators = Replicator.getUsableReplicators(
|
||||||
|
event.getRightClicked().getLocation().getBlock().getRelative(itemFrame.getAttachedFace()).getLocation(),
|
||||||
|
event.getPlayer().getName());
|
||||||
|
|
||||||
// do nothing if no replicator centers have been found
|
// do nothing if no replicator centers have been found
|
||||||
if ( replicators.isEmpty() )
|
if ( replicators.isEmpty() )
|
||||||
@ -88,8 +89,8 @@ public class PlayerInteractEntityListener implements Listener
|
|||||||
ItemStack stack = itemFrame.getItem();
|
ItemStack stack = itemFrame.getItem();
|
||||||
stack.setAmount(64);
|
stack.setAmount(64);
|
||||||
event.getPlayer().getWorld().dropItemNaturally(
|
event.getPlayer().getWorld().dropItemNaturally(
|
||||||
replicator.getCenter().getBlock().getRelative(Replicator.getDirection(replicator.getCenter())).getLocation(),
|
replicator.getCenter().getBlock().getRelative(Replicator.getDirection(replicator.getCenter()))
|
||||||
stack);
|
.getLocation(), stack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/* Craft Inc. Replicator
|
/* Craft Inc. Replicator
|
||||||
Copyright (C) 2013 Paul Schulze, Maximilian Häckel
|
Copyright (C) 2013 Paul Schulze, Maximilian Häckel, Moritz Kaltofen
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -49,7 +49,7 @@ public class Plugin extends JavaPlugin
|
|||||||
|
|
||||||
// commands
|
// commands
|
||||||
Commands commandExecutor = new Commands();
|
Commands commandExecutor = new Commands();
|
||||||
getCommand("replicate").setExecutor(commandExecutor);
|
getCommand("replicator").setExecutor(commandExecutor);
|
||||||
|
|
||||||
// register listeners
|
// register listeners
|
||||||
PluginManager pm = this.getServer().getPluginManager();
|
PluginManager pm = this.getServer().getPluginManager();
|
||||||
|
@ -86,7 +86,8 @@ public class Replicator implements ConfigurationSerializable
|
|||||||
this.users = new HashSet<String>();
|
this.users = new HashSet<String>();
|
||||||
this.owners.add(firstOwner);
|
this.owners.add(firstOwner);
|
||||||
this.center = center;
|
this.center = center;
|
||||||
name = center.getWorld().getName() + "," + center.getBlockX() + "," + center.getBlockY() + "," + center.getBlockZ();
|
name = center.getWorld().getName() + "," + center.getBlockX() + "," + center.getBlockY() + "," +
|
||||||
|
center.getBlockZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked unused")
|
@SuppressWarnings("unchecked unused")
|
||||||
@ -117,45 +118,51 @@ public class Replicator implements ConfigurationSerializable
|
|||||||
return users;
|
return users;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addUser( String user, String player )
|
public Boolean addUser( String user, String player )
|
||||||
{
|
{
|
||||||
this.users.add(user);
|
if ( users.add(user) )
|
||||||
Replicator.saveReplicators(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addOwner( String owner, String player )
|
|
||||||
{
|
|
||||||
this.owners.add(owner);
|
|
||||||
Replicator.saveReplicators(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean rmUser( String user, String player )
|
|
||||||
{
|
|
||||||
if ( this.users.remove(user) )
|
|
||||||
{
|
{
|
||||||
Replicator.saveReplicators(player);
|
Replicator.saveReplicators(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean rmOwner( String owner, String player )
|
public Boolean addOwner( String owner, String player )
|
||||||
{
|
{
|
||||||
if ( this.owners.remove(owner) )
|
if ( owners.add(owner) )
|
||||||
{
|
{
|
||||||
if(owners.isEmpty())
|
Replicator.saveReplicators(player);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean rmUser( String user, String player )
|
||||||
|
{
|
||||||
|
if ( users.remove(user) )
|
||||||
|
{
|
||||||
|
Replicator.saveReplicators(player);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean rmOwner( String owner, String player )
|
||||||
|
{
|
||||||
|
if ( owners.remove(owner) )
|
||||||
|
{
|
||||||
|
if ( owners.isEmpty() )
|
||||||
{
|
{
|
||||||
allReplicators.remove(this.center);
|
allReplicators.remove(center);
|
||||||
}
|
}
|
||||||
Replicator.saveReplicators(player);
|
Replicator.saveReplicators(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
return false;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOwner( String player )
|
public boolean hasOwner( String player )
|
||||||
{
|
{
|
||||||
for ( String owner : owners )
|
for ( String owner : owners )
|
||||||
{
|
{
|
||||||
@ -167,7 +174,7 @@ public class Replicator implements ConfigurationSerializable
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUser( String player )
|
public boolean hasUser( String player )
|
||||||
{
|
{
|
||||||
for ( String user : users )
|
for ( String user : users )
|
||||||
{
|
{
|
||||||
@ -179,6 +186,7 @@ public class Replicator implements ConfigurationSerializable
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("UnusedDeclaration")
|
||||||
public void setName( String newName, String player )
|
public void setName( String newName, String player )
|
||||||
{
|
{
|
||||||
this.name = newName;
|
this.name = newName;
|
||||||
@ -190,16 +198,12 @@ public class Replicator implements ConfigurationSerializable
|
|||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isUsable(String player)
|
public boolean isUsable( String player )
|
||||||
{
|
{
|
||||||
if ( this.isOwner(player) || this.isUser(player) )
|
return this.hasOwner(player) || this.hasUser(player);
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<Location> getReplicatorLocations(Location currentBlock)
|
public static ArrayList<Location> getReplicatorLocations( Location currentBlock )
|
||||||
{
|
{
|
||||||
//mochaccino.sendMessage("Hello Mochaccino!");
|
//mochaccino.sendMessage("Hello Mochaccino!");
|
||||||
ArrayList<Location> replicators = new ArrayList<Location>();
|
ArrayList<Location> replicators = new ArrayList<Location>();
|
||||||
@ -229,13 +233,17 @@ public class Replicator implements ConfigurationSerializable
|
|||||||
|
|
||||||
private static Material[][][] getPattern( Location center )
|
private static Material[][][] getPattern( Location center )
|
||||||
{
|
{
|
||||||
if ( getDirection(center).equals(BlockFace.NORTH) )
|
BlockFace direction = getDirection(center);
|
||||||
|
if ( direction == null )
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if ( direction.equals(BlockFace.NORTH) )
|
||||||
return Pattern.getNorth();
|
return Pattern.getNorth();
|
||||||
if ( getDirection(center).equals(BlockFace.SOUTH) )
|
if ( direction.equals(BlockFace.SOUTH) )
|
||||||
return Pattern.getSouth();
|
return Pattern.getSouth();
|
||||||
if ( getDirection(center).equals(BlockFace.WEST) )
|
if ( direction.equals(BlockFace.WEST) )
|
||||||
return Pattern.getWest();
|
return Pattern.getWest();
|
||||||
if ( getDirection(center).equals(BlockFace.EAST) )
|
if ( direction.equals(BlockFace.EAST) )
|
||||||
return Pattern.getEast();
|
return Pattern.getEast();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -294,8 +302,8 @@ public class Replicator implements ConfigurationSerializable
|
|||||||
* Gets a replicator with the given location. If no replicator exists a new one is created.
|
* Gets a replicator with the given location. If no replicator exists a new one is created.
|
||||||
* Returns null if player is not owner or user of the replicator.
|
* Returns null if player is not owner or user of the replicator.
|
||||||
*
|
*
|
||||||
* @param loc center of the replicator
|
* @param loc center of the replicator
|
||||||
* @param player the player entity
|
* @param player the player entity
|
||||||
* @return Replicator
|
* @return Replicator
|
||||||
*/
|
*/
|
||||||
public static Replicator getOrCreate( Location loc, Player player )
|
public static Replicator getOrCreate( Location loc, Player player )
|
||||||
@ -305,7 +313,7 @@ public class Replicator implements ConfigurationSerializable
|
|||||||
// replicator already exists
|
// replicator already exists
|
||||||
if ( rep != null )
|
if ( rep != null )
|
||||||
{
|
{
|
||||||
if ( rep.isOwner(player.getName()) || rep.isUser(player.getName()) )
|
if ( rep.hasOwner(player.getName()) || rep.hasUser(player.getName()) )
|
||||||
{
|
{
|
||||||
return rep;
|
return rep;
|
||||||
}
|
}
|
||||||
@ -327,75 +335,111 @@ public class Replicator implements ConfigurationSerializable
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all Replicators, which includes the Block at Location loc.
|
* Returns all Replicators, which includes the Block at Location loc.
|
||||||
* @param loc Location of the current Block
|
*
|
||||||
|
* @param loc Location of the current Block
|
||||||
* @return ArrayList of Replicators
|
* @return ArrayList of Replicators
|
||||||
*/
|
*/
|
||||||
public static ArrayList<Replicator> getReplicators(Location loc)
|
public static ArrayList<Replicator> getReplicators( Location loc )
|
||||||
{
|
{
|
||||||
ArrayList<Location> locs = getReplicatorLocations(loc);
|
ArrayList<Location> locs = getReplicatorLocations(loc);
|
||||||
ArrayList<Replicator> reps = new ArrayList<Replicator>();
|
ArrayList<Replicator> reps = new ArrayList<Replicator>();
|
||||||
for(Location center:locs)
|
for ( Location center : locs )
|
||||||
{
|
{
|
||||||
if(allReplicators.get(center)!=null)
|
if ( allReplicators.get(center) != null )
|
||||||
reps.add(allReplicators.get(center));
|
reps.add(allReplicators.get(center));
|
||||||
}
|
}
|
||||||
return reps;
|
return reps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<Replicator> getUsableReplicators(Location loc, String player)
|
public static ArrayList<Replicator> getUsableReplicators( Location loc, String player )
|
||||||
{
|
{
|
||||||
ArrayList<Location> locs = getReplicatorLocations(loc);
|
ArrayList<Location> locs = getReplicatorLocations(loc);
|
||||||
ArrayList<Replicator> reps = new ArrayList<Replicator>();
|
ArrayList<Replicator> reps = new ArrayList<Replicator>();
|
||||||
for(Location center:locs)
|
for ( Location center : locs )
|
||||||
{
|
{
|
||||||
Replicator rep = allReplicators.get(center);
|
Replicator rep = allReplicators.get(center);
|
||||||
if(rep!=null&&rep.isUsable(player))
|
if ( rep != null && rep.isUsable(player) )
|
||||||
reps.add(rep);
|
reps.add(rep);
|
||||||
}
|
}
|
||||||
return reps;
|
return reps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ArrayList<Replicator> getOwnReplicators(Location loc, String player)
|
public static ArrayList<Replicator> getOwnReplicators( Location loc, String player )
|
||||||
{
|
{
|
||||||
ArrayList<Location> locs = getReplicatorLocations(loc);
|
ArrayList<Location> locs = getReplicatorLocations(loc);
|
||||||
ArrayList<Replicator> reps = new ArrayList<Replicator>();
|
ArrayList<Replicator> reps = new ArrayList<Replicator>();
|
||||||
for(Location center:locs)
|
for ( Location center : locs )
|
||||||
{
|
{
|
||||||
Replicator rep = allReplicators.get(center);
|
Replicator rep = allReplicators.get(center);
|
||||||
if(rep!=null&&rep.isOwner(player))
|
if ( rep != null && rep.hasOwner(player) )
|
||||||
reps.add(rep);
|
reps.add(rep);
|
||||||
}
|
}
|
||||||
return reps;
|
return reps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a replicator with the specified name. Returns null if player
|
* Get a replicator with the specified name without any permission checks.
|
||||||
* is not owner or user or if replicator does not exist.
|
* Returns null if replicator with that name does not exist.
|
||||||
*
|
*
|
||||||
* @param repName name of the replicator
|
* @param repName name of the replicator
|
||||||
* @param playerName name of the player
|
|
||||||
* @return Replicator
|
* @return Replicator
|
||||||
*/
|
*/
|
||||||
public static Replicator getByName( String repName, String playerName )
|
public static Replicator getByName( String repName )
|
||||||
{
|
{
|
||||||
for ( Replicator rep : allReplicators.values() )
|
for ( Replicator rep : allReplicators.values() )
|
||||||
{
|
{
|
||||||
if ( rep.getName().equals(repName) )
|
if ( rep.getName().equals(repName) )
|
||||||
{
|
{
|
||||||
if(rep.isUsable(playerName))
|
return rep;
|
||||||
{
|
|
||||||
return rep;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a replicator with the specified name where the given player is owner
|
||||||
|
* else returns null.
|
||||||
|
*
|
||||||
|
* @param repName name of the replicator
|
||||||
|
* @param playerName name of the player who has to be owner
|
||||||
|
* @return Replicator
|
||||||
|
*/
|
||||||
|
public static Replicator getOwnByName( String repName, String playerName )
|
||||||
|
{
|
||||||
|
Replicator rep = getByName(repName);
|
||||||
|
if ( rep.hasOwner(playerName) )
|
||||||
|
{
|
||||||
|
return rep;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a replicator with the specified name where the given player is at least user
|
||||||
|
* else returns null.
|
||||||
|
*
|
||||||
|
* @param repName name of the replicator
|
||||||
|
* @param playerName name of the player who has to be at least user
|
||||||
|
* @return Replicator
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("UnusedDeclaration")
|
||||||
|
public static Replicator getUsableByName( String repName, String playerName )
|
||||||
|
{
|
||||||
|
Replicator rep = getByName(repName);
|
||||||
|
if ( rep.isUsable(playerName) )
|
||||||
|
{
|
||||||
|
return rep;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static ArrayList<Replicator> getReplicatorsByOwner( String playerName )
|
public static ArrayList<Replicator> getReplicatorsByOwner( String playerName )
|
||||||
{
|
{
|
||||||
ArrayList<Replicator> reps = new ArrayList<Replicator>();
|
ArrayList<Replicator> reps = new ArrayList<Replicator>();
|
||||||
for ( Replicator rep : allReplicators.values() )
|
for ( Replicator rep : allReplicators.values() )
|
||||||
{
|
{
|
||||||
if ( rep.isOwner(playerName) )
|
if ( rep.hasOwner(playerName) )
|
||||||
{
|
{
|
||||||
reps.add(rep);
|
reps.add(rep);
|
||||||
}
|
}
|
||||||
@ -408,7 +452,7 @@ public class Replicator implements ConfigurationSerializable
|
|||||||
ArrayList<Replicator> reps = new ArrayList<Replicator>();
|
ArrayList<Replicator> reps = new ArrayList<Replicator>();
|
||||||
for ( Replicator rep : allReplicators.values() )
|
for ( Replicator rep : allReplicators.values() )
|
||||||
{
|
{
|
||||||
if ( rep.isUser(playerName) )
|
if ( rep.hasUser(playerName) )
|
||||||
{
|
{
|
||||||
//mochaccino.sendMessage("You are User for "+rep.getName());
|
//mochaccino.sendMessage("You are User for "+rep.getName());
|
||||||
reps.add(rep);
|
reps.add(rep);
|
||||||
@ -435,9 +479,10 @@ public class Replicator implements ConfigurationSerializable
|
|||||||
replicatorsFileConf.getList(keyReplicators);
|
replicatorsFileConf.getList(keyReplicators);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveReplicators(String playerName)
|
public static void saveReplicators( String playerName )
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
replicatorsFileConf.set(keyReplicators, new ArrayList<Object>(allReplicators.values()));
|
replicatorsFileConf.set(keyReplicators, new ArrayList<Object>(allReplicators.values()));
|
||||||
replicatorsFileConf.save(replicatorsFile);
|
replicatorsFileConf.save(replicatorsFile);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Craft Inc. Replicator
|
# Craft Inc. Replicator
|
||||||
# Copyright (C) 2013 Paul Schulze, Maximilian Häckel
|
# Copyright (C) 2013 Paul Schulze, Maximilian Häckel, Moritz Kaltofen
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -22,8 +22,8 @@ authors: [ddidderr, beuth_el_max]
|
|||||||
website: http://www.craftinc.de/craftinc-replicator
|
website: http://www.craftinc.de/craftinc-replicator
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
replicate:
|
replicator:
|
||||||
description: Shows help for Craft Inc. Replicate
|
description: Shows help for Craft Inc. Replicator
|
||||||
aliases: [repli]
|
aliases: [repli]
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
|
Loading…
Reference in New Issue
Block a user